Release 980301
[wine] / include / debugtools.h
1
2 #ifndef __DEBUGTOOLS_H
3 #define __DEBUGTOOLS_H
4
5 #include <stdio.h>
6
7 #define DEBUG_RUNTIME
8 #define stddeb  stdout
9 #define stdnimp stdout
10
11 #define DEBUG_CLASS_COUNT 4
12
13 extern short debug_msg_enabled[][DEBUG_CLASS_COUNT];
14 extern const char* debug_ch_name[];
15 extern const char* debug_cl_name[];
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...) \
37   fprintf(stddeb, format, ## args)
38
39 #define dprintf_(cl, ch, format, args...) \
40             if(!debugging_(cl, ch)) ; \
41             else dprintf("%s:%s:%s:%d:%s: "format, \
42                          debug_cl_name[dbg_cl_index(cl)], \
43                          debug_ch_name[dbg_ch_index(ch)], \
44                          __FILE__, __LINE__, __FUNCTION__ , ## args)
45
46
47
48 #define debugging_fixme(ch) debugging_(fixme, ch)
49 #define debugging_err(ch) debugging_(err, ch)
50 #define debugging_warn(ch) debugging_(warn, ch)
51 #define debugging_info(ch) debugging_(info, ch)
52
53 #define dprintf_fixme(ch, format, args...) dprintf_(fixme, ch, format, ## args)
54 #define dprintf_err(ch, format, args...) dprintf_(err, ch, format, ## args)
55 #define dprintf_warn(ch, format, args...) dprintf_(warn, ch, format, ## args)
56 #define dprintf_info(ch, format, args...) dprintf_(info, ch, format, ## args)
57
58 #define dbcl_fixme 0
59 #define dbcl_err   1
60 #define dbcl_warn  2
61 #define dbcl_info  3
62
63 #endif
64
65
66