Authors: Chris Morgan <cmorgan@wpi.edu>, James Abbatiello <abbejy@wpi.edu>
[wine/multimedia.git] / include / debugtools.h
blobc1fdfa32cdae868465c5de0b790b4f8cad197baf
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
13 /* Internal definitions (do not use these directly) */
15 enum __DEBUG_CLASS { __DBCL_FIXME, __DBCL_ERR, __DBCL_WARN, __DBCL_TRACE, __DBCL_COUNT };
17 extern char debug_msg_enabled[][__DBCL_COUNT];
19 extern const char * const debug_cl_name[__DBCL_COUNT];
20 extern const char * const debug_ch_name[];
22 #define __DEBUGGING(dbcl,dbch) (debug_msg_enabled[(dbch)][(dbcl)])
24 #ifndef __GNUC__
25 #define __FUNCTION__ ""
26 #endif
28 #define __DPRINTF(dbcl,dbch) \
29 (!__DEBUGGING(dbcl,dbch) || \
30 (dbg_printf("%s:%s:%s ", debug_cl_name[(dbcl)], debug_ch_name[(dbch)], __FUNCTION__),0)) \
31 ? 0 : dbg_printf
33 #define __DUMMY_DPRINTF() 1 ? 0 : ((int (*)(char *, ...)) NULL)
36 /* Exported definitions and macros */
39 #define dbg_str(name) debug_str_##name
40 #define dbg_buf(name) debug_buf_##name
42 #define dbg_decl_str(name, size) \
43 char dbg_str(name)[size], *dbg_buf(name)=dbg_str(name)
45 #define dbg_reset_str(name) \
46 dbg_buf(name)=dbg_str(name)
48 #define dsprintf(name, format, args...) \
49 dbg_buf(name)+=sprintf(dbg_buf(name), format, ## args)
51 /* use configure to allow user to compile out debugging messages */
53 #ifndef NO_TRACE_MSGS
54 #define TRACE __DPRINTF(__DBCL_TRACE,DBCH_DEFAULT)
55 #define TRACE_(ch) __DPRINTF(__DBCL_TRACE,dbch_##ch)
56 #define TRACE_ON(ch) __DEBUGGING(__DBCL_TRACE,dbch_##ch)
57 #else
58 #define TRACE_(ch) __DUMMY_DPRINTF
59 #define TRACE_ON(ch) 0
60 #endif /* NO_TRACE_MSGS */
62 #ifndef NO_DEBUG_MSGS
63 #define WARN __DPRINTF(__DBCL_WARN,DBCH_DEFAULT)
64 #define WARN_(ch) __DPRINTF(__DBCL_WARN,dbch_##ch)
65 #define WARN_ON(ch) __DEBUGGING(__DBCL_WARN,dbch_##ch)
66 #define FIXME __DPRINTF(__DBCL_FIXME,DBCH_DEFAULT)
67 #define FIXME_(ch) __DPRINTF(__DBCL_FIXME,dbch_##ch)
68 #define FIXME_ON(ch) __DEBUGGING(__DBCL_FIXME,dbch_##ch)
69 #else
70 #define WARN __DUMMY_DPRINTF
71 #define WARN_(ch) __DUMMY_DPRINTF
72 #define WARN_ON(ch) 0
73 #define FIXME __DUMMY_DPRINTF
74 #define FIXME_(ch) __DUMMY_DPRINTF
75 #define FIXME_ON(ch) 0
76 #endif /* NO_DEBUG_MSGS */
78 /* define error macro regardless of what is configured */
79 /* Solaris got an 'ERR' define in <sys/reg.h> */
80 #undef ERR
81 #define ERR __DPRINTF(__DBCL_ERR,DBCH_DEFAULT)
82 #define ERR_(ch) __DPRINTF(__DBCL_ERR,dbch_##ch)
83 #define ERR_ON(ch) __DEBUGGING(__DBCL_ERR,dbch_##ch)
85 #define DECLARE_DEBUG_CHANNEL(ch) \
86 extern const int dbch_##ch;
87 #define DEFAULT_DEBUG_CHANNEL(ch) \
88 extern const int dbch_##ch; static const int *const DBCH_DEFAULT = &dbch_##ch;
90 #ifdef OLD_DEBUG_MACROS
91 /* transition macros */
92 #undef TRACE
93 #undef WARN
94 #undef FIXME
95 #undef ERR
96 #define TRACE(ch, fmt, args...) TRACE_(ch)(fmt, ## args)
97 #define WARN(ch, fmt, args...) WARN_(ch)(fmt, ## args)
98 #define FIXME(ch, fmt, args...) FIXME_(ch)(fmt, ## args)
99 #define ERR(ch, fmt, args...) ERR_(ch)(fmt, ## args)
100 #define MSG(format, args...) fprintf(stderr, format, ## args)
101 #define DPRINTF dbg_printf
102 #define DUMP dbg_printf
103 #endif
105 #endif /* __WINE__ */
107 #endif /* __WINE_DEBUGTOOLS_H */