00001
00002 #ifndef __WINE_DEBUGTOOLS_H
00003 #define __WINE_DEBUGTOOLS_H
00004
00005 #ifdef __WINE__
00006
00007 #include <stdarg.h>
00008 #include "config.h"
00009 #include "windef.h"
00010
00011 struct _GUID;
00012
00013
00014
00015 enum __DEBUG_CLASS { __DBCL_FIXME, __DBCL_ERR, __DBCL_WARN, __DBCL_TRACE, __DBCL_COUNT };
00016
00017 #ifndef NO_TRACE_MSGS
00018 # define __GET_DEBUGGING_trace(dbch) ((dbch)[0] & (1 << __DBCL_TRACE))
00019 #else
00020 # define __GET_DEBUGGING_trace(dbch) 0
00021 #endif
00022
00023 #ifndef NO_DEBUG_MSGS
00024 # define __GET_DEBUGGING_warn(dbch) ((dbch)[0] & (1 << __DBCL_WARN))
00025 # define __GET_DEBUGGING_fixme(dbch) ((dbch)[0] & (1 << __DBCL_FIXME))
00026 #else
00027 # define __GET_DEBUGGING_warn(dbch) 0
00028 # define __GET_DEBUGGING_fixme(dbch) 0
00029 #endif
00030
00031
00032 #define __GET_DEBUGGING_err(dbch) ((dbch)[0] & (1 << __DBCL_ERR))
00033
00034 #define __GET_DEBUGGING(dbcl,dbch) __GET_DEBUGGING_##dbcl(dbch)
00035 #define __SET_DEBUGGING(dbcl,dbch,on) \
00036 ((on) ? ((dbch)[0] |= 1 << (dbcl)) : ((dbch)[0] &= ~(1 << (dbcl))))
00037
00038 #ifndef __GNUC__
00039 #define __FUNCTION__ ""
00040 #endif
00041
00042 #define __DPRINTF(dbcl,dbch) \
00043 (!__GET_DEBUGGING(dbcl,(dbch)) || (dbg_header_##dbcl((dbch),__FUNCTION__),0)) ? \
00044 (void)0 : (void)dbg_printf
00045
00046
00047
00048
00049
00050
00051 extern LPCSTR debugstr_an (LPCSTR s, int n);
00052 extern LPCSTR debugstr_wn (LPCWSTR s, int n);
00053 extern LPCSTR debugres_a (LPCSTR res);
00054 extern LPCSTR debugres_w (LPCWSTR res);
00055 extern LPCSTR debugstr_guid( const struct _GUID *id );
00056 extern LPCSTR debugstr_hex_dump (const void *ptr, int len);
00057 extern int dbg_header_err( const char *dbg_channel, const char *func );
00058 extern int dbg_header_warn( const char *dbg_channel, const char *func );
00059 extern int dbg_header_fixme( const char *dbg_channel, const char *func );
00060 extern int dbg_header_trace( const char *dbg_channel, const char *func );
00061 extern int dbg_vprintf( const char *format, va_list args );
00062
00063 static inline LPCSTR debugstr_a( LPCSTR s ) { return debugstr_an( s, 80 ); }
00064 static inline LPCSTR debugstr_w( LPCWSTR s ) { return debugstr_wn( s, 80 ); }
00065
00066 #ifdef __GNUC__
00067 extern int dbg_printf(const char *format, ...) __attribute__((format (printf,1,2)));
00068 #else
00069 extern int dbg_printf(const char *format, ...);
00070 #endif
00071
00072 #define TRACE_(X) TRACE
00073 #define WARN_(X) TRACE
00074 #define WARN TRACE
00075 #define ERR_(X) printf
00076 #define ERR printf
00077 #define FIXME_(X) TRACE
00078 #define FIXME TRACE
00079
00080 #define TRACE_ON(X) 1
00081 #define ERR_ON(X) 1
00082
00083 #define DECLARE_DEBUG_CHANNEL(ch) \
00084 extern char dbch_##ch[];
00085 #define DEFAULT_DEBUG_CHANNEL(ch) \
00086 extern char dbch_##ch[]; static char * const __dbch_default = dbch_##ch;
00087
00088 #define DPRINTF dbg_printf
00089 #define MESSAGE dbg_printf
00090
00091 #endif
00092
00093 #endif