2 #ifndef __WINE_DEBUGTOOLS_H
3 #define __WINE_DEBUGTOOLS_H
5 #ifdef __WINE__ /* Debugging interface is internal to Wine */
13 /* Internal definitions (do not use these directly) */
15 enum __DEBUG_CLASS { __DBCL_FIXME, __DBCL_ERR, __DBCL_WARN, __DBCL_TRACE, __DBCL_COUNT };
18 # define __GET_DEBUGGING_trace(dbch) ((dbch)[0] & (1 << __DBCL_TRACE))
20 # define __GET_DEBUGGING_trace(dbch) 0
24 # define __GET_DEBUGGING_warn(dbch) ((dbch)[0] & (1 << __DBCL_WARN))
25 # define __GET_DEBUGGING_fixme(dbch) ((dbch)[0] & (1 << __DBCL_FIXME))
27 # define __GET_DEBUGGING_warn(dbch) 0
28 # define __GET_DEBUGGING_fixme(dbch) 0
31 /* define error macro regardless of what is configured */
32 #define __GET_DEBUGGING_err(dbch) ((dbch)[0] & (1 << __DBCL_ERR))
34 #define __GET_DEBUGGING(dbcl,dbch) __GET_DEBUGGING_##dbcl(dbch)
35 #define __SET_DEBUGGING(dbcl,dbch,on) \
36 ((on) ? ((dbch)[0] |= 1 << (dbcl)) : ((dbch)[0] &= ~(1 << (dbcl))))
39 #define __FUNCTION__ ""
42 #define __DPRINTF(dbcl,dbch) \
43 (!__GET_DEBUGGING(dbcl,(dbch)) || (__wine_dbg_header_##dbcl((dbch),__FUNCTION__),0)) ? \
44 (void)0 : (void)wine_dbg_printf
46 extern int __wine_dbg_header_err( const char *dbg_channel, const char *func );
47 extern int __wine_dbg_header_warn( const char *dbg_channel, const char *func );
48 extern int __wine_dbg_header_fixme( const char *dbg_channel, const char *func );
49 extern int __wine_dbg_header_trace( const char *dbg_channel, const char *func );
51 /* Exported definitions and macros */
53 /* These function return a printable version of a string, including
54 quotes. The string will be valid for some time, but not indefinitely
55 as strings are re-used. */
56 extern const char *debugstr_an (const char * s, int n);
57 extern const char *debugstr_wn (const WCHAR *s, int n);
58 extern const char *debugstr_guid( const struct _GUID *id );
60 extern int wine_dbg_vprintf( const char *format, va_list args );
62 inline static const char *debugstr_a( const char *s ) { return debugstr_an( s, 80 ); }
63 inline static const char *debugstr_w( const WCHAR *s ) { return debugstr_wn( s, 80 ); }
64 inline static const char *debugres_a( const char *s ) { return debugstr_an( s, 80 ); }
65 inline static const char *debugres_w( const WCHAR *s ) { return debugstr_wn( s, 80 ); }
68 extern int wine_dbg_printf(const char *format, ...) __attribute__((format (printf,1,2)));
70 extern int wine_dbg_printf(const char *format, ...);
73 #define TRACE __DPRINTF(trace,__wine_dbch___default)
74 #define TRACE_(ch) __DPRINTF(trace,__wine_dbch_##ch)
75 #define TRACE_ON(ch) __GET_DEBUGGING(trace,__wine_dbch_##ch)
77 #define WARN __DPRINTF(warn,__wine_dbch___default)
78 #define WARN_(ch) __DPRINTF(warn,__wine_dbch_##ch)
79 #define WARN_ON(ch) __GET_DEBUGGING(warn,__wine_dbch_##ch)
81 #define FIXME __DPRINTF(fixme,__wine_dbch___default)
82 #define FIXME_(ch) __DPRINTF(fixme,__wine_dbch_##ch)
83 #define FIXME_ON(ch) __GET_DEBUGGING(fixme,__wine_dbch_##ch)
85 #undef ERR /* Solaris got an 'ERR' define in <sys/reg.h> */
86 #define ERR __DPRINTF(err,__wine_dbch___default)
87 #define ERR_(ch) __DPRINTF(err,__wine_dbch_##ch)
88 #define ERR_ON(ch) __GET_DEBUGGING(err,__wine_dbch_##ch)
90 #define DECLARE_DEBUG_CHANNEL(ch) \
91 extern char __wine_dbch_##ch[];
92 #define DEFAULT_DEBUG_CHANNEL(ch) \
93 extern char __wine_dbch_##ch[]; static char * const __wine_dbch___default = __wine_dbch_##ch;
95 #define DPRINTF wine_dbg_printf
96 #define MESSAGE wine_dbg_printf
100 #endif /* __WINE_DEBUGTOOLS_H */