1
|
1
|
|
2 #ifndef __WINE_DEBUGTOOLS_H
|
|
3 #define __WINE_DEBUGTOOLS_H
|
|
4
|
|
5 #include <stdarg.h>
|
|
6 #include "config.h"
|
|
7 #include "windef.h"
|
|
8
|
|
9 struct _GUID;
|
|
10
|
|
11 /* Internal definitions (do not use these directly) */
|
|
12
|
|
13 enum __DEBUG_CLASS { __DBCL_FIXME, __DBCL_ERR, __DBCL_WARN, __DBCL_TRACE, __DBCL_COUNT };
|
|
14
|
|
15 #ifndef NO_TRACE_MSGS
|
|
16 # define __GET_DEBUGGING_trace(dbch) ((dbch)[0] & (1 << __DBCL_TRACE))
|
|
17 #else
|
|
18 # define __GET_DEBUGGING_trace(dbch) 0
|
|
19 #endif
|
|
20
|
|
21 #ifndef NO_DEBUG_MSGS
|
|
22 # define __GET_DEBUGGING_warn(dbch) ((dbch)[0] & (1 << __DBCL_WARN))
|
|
23 # define __GET_DEBUGGING_fixme(dbch) ((dbch)[0] & (1 << __DBCL_FIXME))
|
|
24 #else
|
|
25 # define __GET_DEBUGGING_warn(dbch) 0
|
|
26 # define __GET_DEBUGGING_fixme(dbch) 0
|
|
27 #endif
|
|
28
|
|
29 /* define error macro regardless of what is configured */
|
|
30 #define __GET_DEBUGGING_err(dbch) ((dbch)[0] & (1 << __DBCL_ERR))
|
|
31
|
|
32 #define __GET_DEBUGGING(dbcl,dbch) __GET_DEBUGGING_##dbcl(dbch)
|
|
33 #define __SET_DEBUGGING(dbcl,dbch,on) \
|
|
34 ((on) ? ((dbch)[0] |= 1 << (dbcl)) : ((dbch)[0] &= ~(1 << (dbcl))))
|
|
35
|
|
36 #ifndef __GNUC__
|
|
37 #define __FUNCTION__ ""
|
|
38 #endif
|
|
39
|
|
40 #define __DPRINTF(dbcl,dbch) \
|
|
41 (!__GET_DEBUGGING(dbcl,(dbch)) || (dbg_header_##dbcl((dbch),__FUNCTION__),0)) ? \
|
|
42 (void)0 : (void)dbg_printf
|
|
43
|
|
44 /* Exported definitions and macros */
|
|
45
|
|
46 /* These function return a printable version of a string, including
|
|
47 quotes. The string will be valid for some time, but not indefinitely
|
|
48 as strings are re-used. */
|
|
49 extern LPCSTR debugstr_an (LPCSTR s, int n);
|
|
50 extern LPCSTR debugstr_wn (LPCWSTR s, int n);
|
|
51 extern LPCSTR debugres_a (LPCSTR res);
|
|
52 extern LPCSTR debugres_w (LPCWSTR res);
|
|
53 extern LPCSTR debugstr_guid( const struct _GUID *id );
|
|
54 extern LPCSTR debugstr_hex_dump (const void *ptr, int len);
|
|
55 extern int dbg_header_err( const char *dbg_channel, const char *func );
|
|
56 extern int dbg_header_warn( const char *dbg_channel, const char *func );
|
|
57 extern int dbg_header_fixme( const char *dbg_channel, const char *func );
|
|
58 extern int dbg_header_trace( const char *dbg_channel, const char *func );
|
|
59 extern int dbg_vprintf( const char *format, va_list args );
|
|
60
|
|
61 static inline LPCSTR debugstr_a( LPCSTR s ) { return debugstr_an( s, 80 ); }
|
|
62 static inline LPCSTR debugstr_w( LPCWSTR s ) { return debugstr_wn( s, 80 ); }
|
|
63
|
|
64 #ifdef __GNUC__
|
|
65 extern int dbg_printf(const char *format, ...) __attribute__((format (printf,1,2)));
|
|
66 #else
|
|
67 extern int dbg_printf(const char *format, ...);
|
|
68 #endif
|
|
69
|
|
70 #define TRACE_(X) TRACE
|
|
71 #define WARN_(X) TRACE
|
|
72 #define WARN TRACE
|
|
73 #define ERR_(X) printf
|
|
74 #define ERR printf
|
|
75 #define FIXME_(X) TRACE
|
|
76 #define FIXME TRACE
|
|
77
|
|
78 #define TRACE_ON(X) 1
|
|
79 #define ERR_ON(X) 1
|
|
80
|
|
81 #define DECLARE_DEBUG_CHANNEL(ch) \
|
|
82 extern char dbch_##ch[];
|
|
83 #define DEFAULT_DEBUG_CHANNEL(ch) \
|
|
84 extern char dbch_##ch[]; static char * const __dbch_default = dbch_##ch;
|
|
85
|
|
86 #define DPRINTF dbg_printf
|
|
87 #define MESSAGE dbg_printf
|
|
88
|
|
89 #endif /* __WINE_DEBUGTOOLS_H */
|