Remember the allocated string to free it.
[wine/multimedia.git] / include / debugtools.h
blob2abc0f7865ce3f8356469da4b44b1cb49c79b614
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 __GET_DEBUGGING(dbcl,dbch) (__debug_msg_enabled[(dbch)][(dbcl)])
23 #define __SET_DEBUGGING(dbcl,dbch,on) (__debug_msg_enabled[(dbch)][(dbcl)] = (on))
25 #ifndef __GNUC__
26 #define __FUNCTION__ ""
27 #endif
29 #define __DPRINTF(dbcl,dbch) \
30 (!__GET_DEBUGGING(dbcl,dbch) || \
31 (dbg_printf("%s:%s:%s ", debug_cl_name[(dbcl)], debug_ch_name[(dbch)], __FUNCTION__),0)) \
32 ? 0 : dbg_printf
34 #define __DUMMY_DPRINTF 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
37 /* Exported definitions and macros */
39 /* use configure to allow user to compile out debugging messages */
40 #ifndef NO_TRACE_MSGS
41 #define TRACE __DPRINTF(__DBCL_TRACE,*DBCH_DEFAULT)
42 #define TRACE_(ch) __DPRINTF(__DBCL_TRACE,dbch_##ch)
43 #define TRACE_ON(ch) __GET_DEBUGGING(__DBCL_TRACE,dbch_##ch)
44 #else
45 #define TRACE __DUMMY_DPRINTF
46 #define TRACE_(ch) __DUMMY_DPRINTF
47 #define TRACE_ON(ch) 0
48 #endif /* NO_TRACE_MSGS */
50 #ifndef NO_DEBUG_MSGS
51 #define WARN __DPRINTF(__DBCL_WARN,*DBCH_DEFAULT)
52 #define WARN_(ch) __DPRINTF(__DBCL_WARN,dbch_##ch)
53 #define WARN_ON(ch) __GET_DEBUGGING(__DBCL_WARN,dbch_##ch)
54 #define FIXME __DPRINTF(__DBCL_FIXME,*DBCH_DEFAULT)
55 #define FIXME_(ch) __DPRINTF(__DBCL_FIXME,dbch_##ch)
56 #define FIXME_ON(ch) __GET_DEBUGGING(__DBCL_FIXME,dbch_##ch)
57 #else
58 #define WARN __DUMMY_DPRINTF
59 #define WARN_(ch) __DUMMY_DPRINTF
60 #define WARN_ON(ch) 0
61 #define FIXME __DUMMY_DPRINTF
62 #define FIXME_(ch) __DUMMY_DPRINTF
63 #define FIXME_ON(ch) 0
64 #endif /* NO_DEBUG_MSGS */
66 /* define error macro regardless of what is configured */
67 /* Solaris got an 'ERR' define in <sys/reg.h> */
68 #undef ERR
69 #define ERR __DPRINTF(__DBCL_ERR,*DBCH_DEFAULT)
70 #define ERR_(ch) __DPRINTF(__DBCL_ERR,dbch_##ch)
71 #define ERR_ON(ch) __GET_DEBUGGING(__DBCL_ERR,dbch_##ch)
73 #define DECLARE_DEBUG_CHANNEL(ch) \
74 extern const int dbch_##ch;
75 #define DEFAULT_DEBUG_CHANNEL(ch) \
76 extern const int dbch_##ch; static const int *const DBCH_DEFAULT = &dbch_##ch;
78 #define DPRINTF dbg_printf
79 #define MESSAGE dbg_printf
81 #endif /* __WINE__ */
83 #endif /* __WINE_DEBUGTOOLS_H */