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)) || (dbg_header_##dbcl((dbch),__FUNCTION__),0)) ? \
44 (void)0 : (void)dbg_printf
46 /* Exported definitions and macros */
48 /* These function return a printable version of a string, including
49 quotes. The string will be valid for some time, but not indefinitely
50 as strings are re-used. */
51 extern LPCSTR
debugstr_an (LPCSTR s
, int n
);
52 extern LPCSTR
debugstr_wn (LPCWSTR s
, int n
);
53 extern LPCSTR
debugres_a (LPCSTR res
);
54 extern LPCSTR
debugres_w (LPCWSTR res
);
55 extern LPCSTR
debugstr_guid( const struct _GUID
*id
);
56 extern LPCSTR
debugstr_hex_dump (const void *ptr
, int len
);
57 extern int dbg_header_err( const char *dbg_channel
, const char *func
);
58 extern int dbg_header_warn( const char *dbg_channel
, const char *func
);
59 extern int dbg_header_fixme( const char *dbg_channel
, const char *func
);
60 extern int dbg_header_trace( const char *dbg_channel
, const char *func
);
61 extern int dbg_vprintf( const char *format
, va_list args
);
63 static inline LPCSTR
debugstr_a( LPCSTR s
) { return debugstr_an( s
, 80 ); }
64 static inline LPCSTR
debugstr_w( LPCWSTR s
) { return debugstr_wn( s
, 80 ); }
67 extern int dbg_printf(const char *format
, ...) __attribute__((format (printf
,1,2)));
69 extern int dbg_printf(const char *format
, ...);
72 #define TRACE __DPRINTF(trace,__dbch_default)
73 #define TRACE_(ch) __DPRINTF(trace,dbch_##ch)
74 #define TRACE_ON(ch) __GET_DEBUGGING(trace,dbch_##ch)
76 #define WARN __DPRINTF(warn,__dbch_default)
77 #define WARN_(ch) __DPRINTF(warn,dbch_##ch)
78 #define WARN_ON(ch) __GET_DEBUGGING(warn,dbch_##ch)
80 #define FIXME __DPRINTF(fixme,__dbch_default)
81 #define FIXME_(ch) __DPRINTF(fixme,dbch_##ch)
82 #define FIXME_ON(ch) __GET_DEBUGGING(fixme,dbch_##ch)
84 #undef ERR /* Solaris got an 'ERR' define in <sys/reg.h> */
85 #define ERR __DPRINTF(err,__dbch_default)
86 #define ERR_(ch) __DPRINTF(err,dbch_##ch)
87 #define ERR_ON(ch) __GET_DEBUGGING(err,dbch_##ch)
89 #define DECLARE_DEBUG_CHANNEL(ch) \
90 extern char dbch_##ch[];
91 #define DEFAULT_DEBUG_CHANNEL(ch) \
92 extern char dbch_##ch[]; static char * const __dbch_default = dbch_##ch;
94 #define DPRINTF dbg_printf
95 #define MESSAGE dbg_printf
99 #endif /* __WINE_DEBUGTOOLS_H */