Release 980517
[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 "debugstr.h"
9
10 #define DEBUG_RUNTIME
11 #define stddeb  stderr
12
13 #define DEBUG_CLASS_COUNT 4
14
15 extern short debug_msg_enabled[][DEBUG_CLASS_COUNT];
16
17 #define dbg_str(name) debug_str_##name
18 #define dbg_buf(name) debug_buf_##name
19
20 #define dbg_decl_str(name, size) \
21   char dbg_str(name)[size], *dbg_buf(name)=dbg_str(name)
22
23 #define dbg_reset_str(name) \
24   dbg_buf(name)=dbg_str(name)
25
26 #define dsprintf(name, format, args...) \
27   dbg_buf(name)+=sprintf(dbg_buf(name), format, ## args)
28
29 #define dbg_ch_index(ch) (dbch_##ch)
30 #define dbg_cl_index(cl) (dbcl_##cl)
31
32 #define DEBUGGING(cl, ch) \
33   (dbg_ch_index(ch) >=0 && dbg_cl_index(cl) >= 0 && \
34    debug_msg_enabled[dbg_ch_index(ch)][dbg_cl_index(cl)])
35
36 #define DPRINTF(format, args...) fprintf(stddeb, format, ## args)
37
38 #define DPRINTF_(cl, ch, format, args...) \
39   if(!DEBUGGING(cl, ch)) ; \
40   else DPRINTF(# cl ":" # ch ":%s " format, __FUNCTION__ , ## args)
41
42 #define TRACE(ch, fmt, args...) DPRINTF_(trace, ch, fmt, ## args)
43 #define WARN(ch, fmt, args...)  DPRINTF_(warn,  ch, fmt, ## args)
44 #define FIXME(ch, fmt, args...) DPRINTF_(fixme, ch, fmt, ## args)
45 #define ERR(ch, fmt, args...)   DPRINTF_(err, ch, fmt, ## args)
46
47 #define DUMP(format, args...)   DPRINTF(format, ## args)
48 #define MSG(format, args...)    fprintf(stderr, format, ## args)
49
50 #define FIXME_ON(ch)  DEBUGGING(fixme, ch)
51 #define ERR_ON(ch)    DEBUGGING(err, ch)
52 #define WARN_ON(ch)   DEBUGGING(warn, ch)
53 #define TRACE_ON(ch)  DEBUGGING(trace, ch)
54
55 #endif  /* __WINE__ */
56
57 #endif  /* __WINE_DEBUGTOOLS_H */