Fixed --disable-debug config option.
[wine] / include / debugtools.h
1
2 #ifndef __WINE_DEBUGTOOLS_H
3 #define __WINE_DEBUGTOOLS_H
4
5 #ifdef __WINE__  /* Debugging interface is internal to Wine */
6
7 #include <stdio.h>
8 #include "config.h"
9 #include "debugstr.h"
10
11 #define DEBUG_RUNTIME
12 #define stddeb  stderr
13
14 #define DEBUG_CLASS_COUNT 4
15
16 extern short debug_msg_enabled[][DEBUG_CLASS_COUNT];
17
18 #define dbg_str(name) debug_str_##name
19 #define dbg_buf(name) debug_buf_##name
20
21 #define dbg_decl_str(name, size) \
22   char dbg_str(name)[size], *dbg_buf(name)=dbg_str(name)
23
24 #define dbg_reset_str(name) \
25   dbg_buf(name)=dbg_str(name)
26
27 #define dsprintf(name, format, args...) \
28   dbg_buf(name)+=sprintf(dbg_buf(name), format, ## args)
29
30 #define dbg_ch_index(ch) (dbch_##ch)
31 #define dbg_cl_index(cl) (dbcl_##cl)
32
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)])
36
37 #define DPRINTF(format, args...) fprintf(stddeb, format, ## args)
38
39 #define DPRINTF_(cl, ch, format, args...) \
40   do {if(!DEBUGGING(cl, ch)) ; \
41   else DPRINTF(# cl ":" # ch ":%s " format, __FUNCTION__ , ## args); } while (0)
42
43 /* use configure to allow user to compile out debugging messages */
44
45 #ifndef NO_TRACE_MSGS
46 #define TRACE(ch, fmt, args...) DPRINTF_(trace, ch, fmt, ## args)
47 #else
48 #define TRACE(ch, fmt, args...) do { } while (0)
49 #endif /* NO_TRACE_MSGS */
50
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...) do { } while (0)
57 #define FIXME(ch, fmt, args...) do { } while (0)
58 #define DUMP(format, args...) do { } while (0)
59 #endif /* NO_DEBUG_MSGS */
60
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)
64
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 */
71
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 */
79
80 #define ERR_ON(ch)    DEBUGGING(err, ch)
81
82 #endif  /* __WINE__ */
83
84 #endif  /* __WINE_DEBUGTOOLS_H */