vfs: check userland buffers before reading them.
[haiku.git] / headers / private / graphics / common / debug_ext.h
blob9ac65abc5576086a74f5bd963c877a19ce721df2
1 /*
2 Copyright (c) 2002, Thomas Kurschel
5 Part of Radeon driver
7 Extended debugging functions
8 */
11 #ifndef __DEBUG_EXT_H__
12 #define __DEBUG_EXT_H__
14 // this is a dprintf wrapper
16 // there are three kinds of messages:
17 // flow: used to trace execution
18 // info: tells things that are important but not an error
19 // error: used if something has gone wrong
21 // common usage is
22 // SHOW_{FLOW,INFO,ERROR}( seriousness, format string, parameters... );
23 // SHOW_{FLOW,INFO,ERROR}0( seriousness, string );
25 // with
26 // seriousness: the smaller the more serious (0..3)
27 // format string, parameters: normal printf stuff
29 // to specify the module that created the message you have
30 // to define a string called
31 // DEBUG_MSG_PREFIX
32 // you dynamically speficify the maximum seriousness level by defining
33 // the following variables/macros
34 // debug_level_flow
35 // debug_level_info
36 // debug_level_error
38 // you _can_ statically specify the maximum seriuosness level by defining
39 // DEBUG_MAX_LEVEL_FLOW
40 // DEBUG_MAX_LEVEL_INFO
41 // DEBUG_MAX_LEVEL_ERRROR
43 // you _can_ ask to delay execution after each printed message
44 // by defining the duration (in ms) via
45 // DEBUG_WAIT_ON_MSG (for flow and info)
46 // DEBUG_WAIT_ON_ERROR (for error)
48 #ifdef DEBUG_WAIT_ON_MSG
49 #define DEBUG_WAIT snooze( DEBUG_WAIT_ON_MSG );
50 #else
51 #define DEBUG_WAIT
52 #endif
54 #ifdef DEBUG_WAIT_ON_ERROR
55 #define DEBUG_WAIT_ERROR snooze( DEBUG_WAIT_ON_ERROR );
56 #else
57 #define DEBUG_WAIT_ERROR
58 #endif
60 #ifndef DEBUG_MAX_LEVEL_FLOW
61 #define DEBUG_MAX_LEVEL_FLOW 4
62 #endif
64 #ifndef DEBUG_MAX_LEVEL_INFO
65 #define DEBUG_MAX_LEVEL_INFO 4
66 #endif
68 #ifndef DEBUG_MAX_LEVEL_ERROR
69 #define DEBUG_MAX_LEVEL_ERROR 4
70 #endif
72 #ifndef DEBUG_MSG_PREFIX
73 #error you need to define DEBUG_MSG_PREFIX with the module name
74 #endif
76 #define FUNC_NAME DEBUG_MSG_PREFIX, __FUNCTION__
78 #define SHOW_FLOW(seriousness, format, param...) \
79 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
80 dprintf( "%s%s: " format "\n", FUNC_NAME, param ); DEBUG_WAIT \
81 }} while( 0 )
83 #define SHOW_FLOW0(seriousness, format) \
84 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
85 dprintf( "%s%s: " format "\n", FUNC_NAME); DEBUG_WAIT \
86 }} while( 0 )
88 #define SHOW_INFO(seriousness, format, param...) \
89 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
90 dprintf( "%s%s: " format "\n", FUNC_NAME, param ); DEBUG_WAIT \
91 }} while( 0 )
93 #define SHOW_INFO0(seriousness, format) \
94 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
95 dprintf( "%s%s: " format "\n", FUNC_NAME); DEBUG_WAIT \
96 }} while( 0 )
98 #define SHOW_ERROR(seriousness, format, param...) \
99 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
100 dprintf( "%s%s: " format "\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \
101 }} while( 0 )
103 #define SHOW_ERROR0(seriousness, format) \
104 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
105 dprintf( "%s%s: " format "\n", FUNC_NAME); DEBUG_WAIT_ERROR \
106 }} while( 0 )
108 #endif