Release 980927
[wine.git] / include / debugtools.h
blob7b6356b01f9a44b2a84e27dc4391e85b8e21beba
2 #ifndef __WINE_DEBUGTOOLS_H
3 #define __WINE_DEBUGTOOLS_H
5 #ifdef __WINE__ /* Debugging interface is internal to Wine */
7 #include <stdio.h>
8 #include "config.h"
9 #include "debugstr.h"
11 #define DEBUG_RUNTIME
12 #define stddeb stderr
14 #define DEBUG_CLASS_COUNT 4
16 extern short debug_msg_enabled[][DEBUG_CLASS_COUNT];
18 #define dbg_str(name) debug_str_##name
19 #define dbg_buf(name) debug_buf_##name
21 #define dbg_decl_str(name, size) \
22 char dbg_str(name)[size], *dbg_buf(name)=dbg_str(name)
24 #define dbg_reset_str(name) \
25 dbg_buf(name)=dbg_str(name)
27 #define dsprintf(name, format, args...) \
28 dbg_buf(name)+=sprintf(dbg_buf(name), format, ## args)
30 #define dbg_ch_index(ch) (dbch_##ch)
31 #define dbg_cl_index(cl) (dbcl_##cl)
33 #define DEBUGGING(cl, ch) \
34 (dbg_ch_index(ch) >=0 && dbg_cl_index(cl) >= 0 && \
35 debug_msg_enabled[dbg_ch_index(ch)][dbg_cl_index(cl)])
37 #define DPRINTF(format, args...) fprintf(stddeb, format, ## args)
39 #define DPRINTF_(cl, ch, format, args...) \
40 do {if(!DEBUGGING(cl, ch)) ; \
41 else DPRINTF(# cl ":" # ch ":%s " format, __FUNCTION__ , ## args); } while (0)
43 /* use configure to allow user to compile out debugging messages */
45 #ifndef NO_TRACE_MSGS
46 #define TRACE(ch, fmt, args...) DPRINTF_(trace, ch, fmt, ## args)
47 #else
48 #define TRACE(ch, fmt, args...)
49 #endif /* NO_TRACE_MSGS */
51 #ifndef NO_DEBUG_MSGS
52 #define WARN(ch, fmt, args...) DPRINTF_(warn, ch, fmt, ## args)
53 #define FIXME(ch, fmt, args...) DPRINTF_(fixme, ch, fmt, ## args)
54 #define DUMP(format, args...) DPRINTF(format, ## args)
55 #else
56 #define WARN(ch, fmt, args...)
57 #define FIXME(ch, fmt, args...)
58 #define DUMP(format, args...)
59 #endif /* NO_DEBUG_MSGS */
61 /* define error macro regardless of what is configured */
62 #define ERR(ch, fmt, args...) DPRINTF_(err, ch, fmt, ## args)
63 #define MSG(format, args...) fprintf(stderr, format, ## args)
65 /* if the debug message is compiled out, make these return false */
66 #ifndef NO_TRACE_MSGS
67 #define TRACE_ON(ch) DEBUGGING(trace, ch)
68 #else
69 #define TRACE_ON(ch) 0
70 #endif /* NO_TRACE_MSGS */
72 #ifndef NO_DEBUG_MSGS
73 #define WARN_ON(ch) DEBUGGING(warn, ch)
74 #define FIXME_ON(ch) DEBUGGING(fixme, ch)
75 #else
76 #define WARN_ON(ch) 0
77 #define FIXME_ON(ch) 0
78 #endif /* NO_DEBUG_MSGS */
80 #define ERR_ON(ch) DEBUGGING(err, ch)
82 #endif /* __WINE__ */
84 #endif /* __WINE_DEBUGTOOLS_H */