use the -newos toolchain even if -elf is present.
[newos.git] / include / kernel / debug_ext.h
blob64176371f3d883caf1e6bb64e34b6b478e7162c4
1 /*
2 ** Copyright 2002, Thomas Kurschel. All rights reserved.
3 ** Distributed under the terms of the NewOS License.
4 */
6 #ifndef __DEBUG_EXT_H__
7 #define __DEBUG_EXT_H__
9 // this is a dprintf wrapper
11 // there are three kinds of messages:
12 // flow: used to trace execution
13 // info: tells things that are important but not an error
14 // error: used if something has gone wrong
16 // common usage is
17 // SHOW_{FLOW,INFO,ERROR}( seriousness, format string, parameters... );
18 // SHOW_{FLOW,INFO,ERROR}0( seriousness, string );
20 // with
21 // seriousness: the smaller the more serious (0..3)
22 // format string, parameters: normal printf stuff
24 // to specify the module that created the message you have
25 // to define a string called
26 // DEBUG_MSG_PREFIX
27 // you dynamically speficify the maximum seriousness level by defining
28 // the following variables/macros
29 // debug_level_flow
30 // debug_level_info
31 // debug_level_error
33 // you _can_ statically specify the maximum seriuosness level by defining
34 // DEBUG_MAX_LEVEL_FLOW
35 // DEBUG_MAX_LEVEL_INFO
36 // DEBUG_MAX_LEVEL_ERRROR
38 // you _can_ ask to delay execution after each printed message
39 // by defining the duration (in ms) via
40 // DEBUG_WAIT_ON_MSG (for flow and info)
41 // DEBUG_WAIT_ON_ERROR (for error)
43 #ifdef DEBUG_WAIT_ON_MSG
44 #define DEBUG_WAIT thread_snooze( DEBUG_WAIT_ON_MSG );
45 #else
46 #define DEBUG_WAIT
47 #endif
49 #ifdef DEBUG_WAIT_ON_ERROR
50 #define DEBUG_WAIT_ERROR thread_snooze( DEBUG_WAIT_ON_ERROR );
51 #else
52 #define DEBUG_WAIT_ERROR
53 #endif
55 #ifndef DEBUG_MAX_LEVEL_FLOW
56 #define DEBUG_MAX_LEVEL_FLOW 255
57 #endif
59 #ifndef DEBUG_MAX_LEVEL_INFO
60 #define DEBUG_MAX_LEVEL_INFO 255
61 #endif
63 #ifndef DEBUG_MAX_LEVEL_ERROR
64 #define DEBUG_MAX_LEVEL_ERROR 255
65 #endif
67 #ifndef DEBUG_MSG_PREFIX
68 #error you need to define DEBUG_MSG_PREFIX with the module name
69 #endif
71 #define FUNC_NAME DEBUG_MSG_PREFIX, __FUNCTION__, ": "
73 #define SHOW_FLOW(seriousness, format, param...) \
74 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
75 dprintf( "%s%s%s"format"\n", FUNC_NAME, param ); DEBUG_WAIT \
76 }} while( 0 )
78 #define SHOW_FLOW0(seriousness, format) \
79 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
80 dprintf( "%s%s%s"format"\n", FUNC_NAME); DEBUG_WAIT \
81 }} while( 0 )
83 #define SHOW_INFO(seriousness, format, param...) \
84 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
85 dprintf( "%s%s%s"format"\n", FUNC_NAME, param ); DEBUG_WAIT \
86 }} while( 0 )
88 #define SHOW_INFO0(seriousness, format) \
89 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
90 dprintf( "%s%s%s"format"\n", FUNC_NAME); DEBUG_WAIT \
91 }} while( 0 )
93 #define SHOW_ERROR(seriousness, format, param...) \
94 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
95 dprintf( "%s%s%s"format"\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \
96 }} while( 0 )
98 #define SHOW_ERROR0(seriousness, format) \
99 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
100 dprintf( "%s%s%s"format"\n", FUNC_NAME); DEBUG_WAIT_ERROR \
101 }} while( 0 )
103 #endif