From 50951b63b356b846b3826a7a9d8189589798f674 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Mon, 22 Oct 2012 14:13:39 +0200 Subject: butcher debugging interfaces --- libmsi/Makefile.am | 2 +- libmsi/alter.c | 1 - libmsi/create.c | 1 - libmsi/database.c | 1 - libmsi/delete.c | 1 - libmsi/distinct.c | 1 - libmsi/drop.c | 1 - libmsi/handle.c | 1 - libmsi/insert.c | 1 - libmsi/msi.c | 1 - libmsi/msipriv.h | 1 - libmsi/msiquery.c | 1 - libmsi/record.c | 1 - libmsi/select.c | 1 - libmsi/sql-parser.y | 1 - libmsi/storages.c | 1 - libmsi/streams.c | 1 - libmsi/string.c | 1 - libmsi/suminfo.c | 1 - libmsi/table.c | 3 +- libmsi/update.c | 1 - libmsi/where.c | 1 - libmsi/wine/debug.h | 243 +++++++++++++++------------------------------------- 23 files changed, 69 insertions(+), 199 deletions(-) (limited to 'libmsi') diff --git a/libmsi/Makefile.am b/libmsi/Makefile.am index c492f07..5425385 100644 --- a/libmsi/Makefile.am +++ b/libmsi/Makefile.am @@ -1,6 +1,6 @@ lib_LTLIBRARIES = libmsi.la -AM_CPPFLAGS = -I$(srcdir) -I. -D__WINESRC__ -DUNICODE +AM_CPPFLAGS = -I$(srcdir) -I. -DUNICODE AM_CFLAGS = -Wunused -Wimplicit AM_YFLAGS = -d BUILT_SOURCES = sql-parser.c sql-parser.h diff --git a/libmsi/alter.c b/libmsi/alter.c index 8b11351..d1b1477 100644 --- a/libmsi/alter.c +++ b/libmsi/alter.c @@ -32,7 +32,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); typedef struct tagMSIALTERVIEW { diff --git a/libmsi/create.c b/libmsi/create.c index c679d6b..19b51db 100644 --- a/libmsi/create.c +++ b/libmsi/create.c @@ -34,7 +34,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); /* below is the query interface to a table */ diff --git a/libmsi/database.c b/libmsi/database.c index d2ec11a..33f3242 100644 --- a/libmsi/database.c +++ b/libmsi/database.c @@ -40,7 +40,6 @@ #include "initguid.h" -WINE_DEFAULT_DEBUG_CHANNEL(msi); /* * .MSI file format diff --git a/libmsi/delete.c b/libmsi/delete.c index 4472409..dcbdae5 100644 --- a/libmsi/delete.c +++ b/libmsi/delete.c @@ -33,7 +33,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); /* diff --git a/libmsi/distinct.c b/libmsi/distinct.c index 04f09fa..ca63f6b 100644 --- a/libmsi/distinct.c +++ b/libmsi/distinct.c @@ -33,7 +33,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); typedef struct tagDISTINCTSET { diff --git a/libmsi/drop.c b/libmsi/drop.c index f0b5803..f79b66a 100644 --- a/libmsi/drop.c +++ b/libmsi/drop.c @@ -32,7 +32,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); typedef struct tagMSIDROPVIEW { diff --git a/libmsi/handle.c b/libmsi/handle.c index 381239f..3c38bf8 100644 --- a/libmsi/handle.c +++ b/libmsi/handle.c @@ -31,7 +31,6 @@ #include "msiquery.h" #include "msipriv.h" -WINE_DEFAULT_DEBUG_CHANNEL(msi); static CRITICAL_SECTION MSI_handle_cs; static CRITICAL_SECTION_DEBUG MSI_handle_cs_debug = diff --git a/libmsi/insert.c b/libmsi/insert.c index c404929..8e07a14 100644 --- a/libmsi/insert.c +++ b/libmsi/insert.c @@ -34,7 +34,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); /* below is the query interface to a table */ diff --git a/libmsi/msi.c b/libmsi/msi.c index 0a388b5..a93d01a 100644 --- a/libmsi/msi.c +++ b/libmsi/msi.c @@ -49,7 +49,6 @@ #include "wine/debug.h" #include "wine/unicode.h" -WINE_DEFAULT_DEBUG_CHANNEL(msi); static const WCHAR installerW[] = {'\\','I','n','s','t','a','l','l','e','r',0}; diff --git a/libmsi/msipriv.h b/libmsi/msipriv.h index f064a07..b35e366 100644 --- a/libmsi/msipriv.h +++ b/libmsi/msipriv.h @@ -38,7 +38,6 @@ #include "winnls.h" #include "winver.h" #include "wine/list.h" -#include "wine/debug.h" static const BOOL is_64bit = sizeof(void *) > sizeof(int); BOOL is_wow64; diff --git a/libmsi/msiquery.c b/libmsi/msiquery.c index 84e6eb5..ba9f3f3 100644 --- a/libmsi/msiquery.c +++ b/libmsi/msiquery.c @@ -39,7 +39,6 @@ #include "initguid.h" -WINE_DEFAULT_DEBUG_CHANNEL(msi); static void MSI_CloseView( MSIOBJECTHDR *arg ) { diff --git a/libmsi/record.c b/libmsi/record.c index 5c22279..83ccee8 100644 --- a/libmsi/record.c +++ b/libmsi/record.c @@ -41,7 +41,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); #define MSIFIELD_NULL 0 #define MSIFIELD_INT 1 diff --git a/libmsi/select.c b/libmsi/select.c index 982cf6a..1faacd4 100644 --- a/libmsi/select.c +++ b/libmsi/select.c @@ -33,7 +33,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); /* below is the query interface to a table */ diff --git a/libmsi/sql-parser.y b/libmsi/sql-parser.y index 859f405..5bd1721 100644 --- a/libmsi/sql-parser.y +++ b/libmsi/sql-parser.y @@ -39,7 +39,6 @@ static int sql_error(const char *str); -WINE_DEFAULT_DEBUG_CHANNEL(msi); typedef struct tag_SQL_input { diff --git a/libmsi/storages.c b/libmsi/storages.c index 56c97f8..b068e62 100644 --- a/libmsi/storages.c +++ b/libmsi/storages.c @@ -36,7 +36,6 @@ #include "wine/debug.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); #define NUM_STORAGES_COLS 2 #define MAX_STORAGES_NAME_LEN 62 diff --git a/libmsi/streams.c b/libmsi/streams.c index 71616e9..3e4d8e2 100644 --- a/libmsi/streams.c +++ b/libmsi/streams.c @@ -34,7 +34,6 @@ #include "wine/debug.h" #include "wine/unicode.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); #define NUM_STREAMS_COLS 2 diff --git a/libmsi/string.c b/libmsi/string.c index 065c04a..f4a9215 100644 --- a/libmsi/string.c +++ b/libmsi/string.c @@ -39,7 +39,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); struct msistring { diff --git a/libmsi/suminfo.c b/libmsi/suminfo.c index 8205070..9acbe7b 100644 --- a/libmsi/suminfo.c +++ b/libmsi/suminfo.c @@ -38,7 +38,6 @@ #include "propvarutil.h" #include "msiserver.h" -WINE_DEFAULT_DEBUG_CHANNEL(msi); const CLSID FMTID_SummaryInformation = { 0xf29f85e0, 0x4ff9, 0x1068, {0xab, 0x91, 0x08, 0x00, 0x2b, 0x27, 0xb3, 0xd9}}; diff --git a/libmsi/table.c b/libmsi/table.c index 93b0268..ea662d6 100644 --- a/libmsi/table.c +++ b/libmsi/table.c @@ -39,7 +39,6 @@ #include "wine/debug.h" #include "wine/unicode.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); #define MSITABLE_HASH_TABLE_SIZE 37 @@ -2401,7 +2400,7 @@ static void dump_table( const string_table *st, const USHORT *rawdata, UINT raws for( i=0; i<(rawsize/2); i++ ) { sval = msi_string_lookup_id( st, rawdata[i] ); - MESSAGE(" %04x %s\n", rawdata[i], debugstr_w(sval) ); + TRACE(" %04x %s\n", rawdata[i], debugstr_w(sval) ); } } diff --git a/libmsi/update.c b/libmsi/update.c index d0e3c28..181123a 100644 --- a/libmsi/update.c +++ b/libmsi/update.c @@ -33,7 +33,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); /* below is the query interface to a table */ diff --git a/libmsi/where.c b/libmsi/where.c index 36c8ec8..46a7910 100644 --- a/libmsi/where.c +++ b/libmsi/where.c @@ -36,7 +36,6 @@ #include "query.h" -WINE_DEFAULT_DEBUG_CHANNEL(msidb); /* below is the query interface to a table */ typedef struct tagMSIROWENTRY diff --git a/libmsi/wine/debug.h b/libmsi/wine/debug.h index ba6fabe..cb5da28 100644 --- a/libmsi/wine/debug.h +++ b/libmsi/wine/debug.h @@ -22,142 +22,34 @@ #define __WINE_WINE_DEBUG_H #include +#include +#include +#include #include +#include +#include #ifndef GUID_DEFINED #include #endif -#ifdef __WINE_WINE_TEST_H -#error This file should not be used in Wine tests -#endif - #ifdef __cplusplus extern "C" { #endif -struct _GUID; - /* * Internal definitions (do not use these directly) */ enum __wine_debug_class { - __WINE_DBCL_FIXME, - __WINE_DBCL_ERR, - __WINE_DBCL_WARN, - __WINE_DBCL_TRACE, - - __WINE_DBCL_INIT = 7 /* lazy init flag */ -}; - -struct __wine_debug_channel -{ - unsigned char flags; - char name[15]; -}; - -#ifndef WINE_NO_TRACE_MSGS -# define __WINE_GET_DEBUGGING_TRACE(dbch) ((dbch)->flags & (1 << __WINE_DBCL_TRACE)) -#else -# define __WINE_GET_DEBUGGING_TRACE(dbch) 0 -#endif - -#ifndef WINE_NO_DEBUG_MSGS -# define __WINE_GET_DEBUGGING_WARN(dbch) ((dbch)->flags & (1 << __WINE_DBCL_WARN)) -# define __WINE_GET_DEBUGGING_FIXME(dbch) ((dbch)->flags & (1 << __WINE_DBCL_FIXME)) -#else -# define __WINE_GET_DEBUGGING_WARN(dbch) 0 -# define __WINE_GET_DEBUGGING_FIXME(dbch) 0 -#endif - -/* define error macro regardless of what is configured */ -#define __WINE_GET_DEBUGGING_ERR(dbch) ((dbch)->flags & (1 << __WINE_DBCL_ERR)) - -#define __WINE_GET_DEBUGGING(dbcl,dbch) __WINE_GET_DEBUGGING##dbcl(dbch) - -#define __WINE_IS_DEBUG_ON(dbcl,dbch) \ - (__WINE_GET_DEBUGGING##dbcl(dbch) && (__wine_dbg_get_channel_flags(dbch) & (1 << __WINE_DBCL##dbcl))) - -#ifdef __GNUC__ - -#define __WINE_DPRINTF(dbcl,dbch) \ - do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \ - struct __wine_debug_channel * const __dbch = (dbch); \ - const enum __wine_debug_class __dbcl = __WINE_DBCL##dbcl; \ - __WINE_DBG_LOG - -#define __WINE_DBG_LOG(args...) \ - wine_dbg_log( __dbcl, __dbch, __FUNCTION__, args); } } while(0) - -#define __WINE_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args))) - - -#ifdef WINE_NO_TRACE_MSGS -#define WINE_TRACE(args...) do { } while(0) -#define WINE_TRACE_(ch) WINE_TRACE -#endif - -#ifdef WINE_NO_DEBUG_MSGS -#define WINE_WARN(args...) do { } while(0) -#define WINE_WARN_(ch) WINE_WARN -#define WINE_FIXME(args...) do { } while(0) -#define WINE_FIXME_(ch) WINE_FIXME -#endif - -#elif defined(__SUNPRO_C) - -#define __WINE_DPRINTF(dbcl,dbch) \ - do { if(__WINE_GET_DEBUGGING(dbcl,(dbch))) { \ - struct __wine_debug_channel * const __dbch = (dbch); \ - const enum __WINE_DEBUG_CLASS __dbcl = __WINE_DBCL##dbcl; \ - __WINE_DBG_LOG - -#define __WINE_DBG_LOG(...) \ - wine_dbg_log( __dbcl, __dbch, __func__, __VA_ARGS__); } } while(0) - -#define __WINE_PRINTF_ATTR(fmt,args) - -#ifdef WINE_NO_TRACE_MSGS -#define WINE_TRACE(...) do { } while(0) -#define WINE_TRACE_(ch) WINE_TRACE -#endif - -#ifdef WINE_NO_DEBUG_MSGS -#define WINE_WARN(...) do { } while(0) -#define WINE_WARN_(ch) WINE_WARN -#define WINE_FIXME(...) do { } while(0) -#define WINE_FIXME_(ch) WINE_FIXME -#endif - -#else /* !__GNUC__ && !__SUNPRO_C */ - -#define __WINE_DPRINTF(dbcl,dbch) \ - (!__WINE_GET_DEBUGGING(dbcl,(dbch)) || \ - (wine_dbg_log(__WINE_DBCL##dbcl,(dbch),__FILE__,"%d: ",__LINE__) == -1)) ? \ - (void)0 : (void)wine_dbg_printf - -#define __WINE_PRINTF_ATTR(fmt, args) + DBCL_FIXME, + DBCL_ERR, + DBCL_WARN, + DBCL_TRACE, -#endif /* !__GNUC__ && !__SUNPRO_C */ - -struct __wine_debug_functions -{ - char * (*get_temp_buffer)( size_t n ); - void (*release_temp_buffer)( char *buffer, size_t n ); - const char * (*dbgstr_an)( const char * s, int n ); - const char * (*dbgstr_wn)( const WCHAR *s, int n ); - int (*dbg_vprintf)( const char *format, va_list args ); - int (*dbg_vlog)( enum __wine_debug_class cls, struct __wine_debug_channel *channel, - const char *function, const char *format, va_list args ); + DBCL_INIT = 7 /* lazy init flag */ }; -extern unsigned char __wine_dbg_get_channel_flags( struct __wine_debug_channel *channel ); -extern int __wine_dbg_set_channel_flags( struct __wine_debug_channel *channel, - unsigned char set, unsigned char clear ); -extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_funcs, - struct __wine_debug_functions *old_funcs, size_t size ); - /* * Exported definitions and macros */ @@ -165,13 +57,55 @@ extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_f /* These functions return a printable version of a string, including quotes. The string will be valid for some time, but not indefinitely as strings are re-used. */ -extern const char *wine_dbgstr_an( const char * s, int n ); -extern const char *wine_dbgstr_wn( const WCHAR *s, int n ); -extern const char *wine_dbg_sprintf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2); +static inline const char *wine_dbgstr_an( const char * s, int n ) +{ + if (!s) return ""; + return s; +} +static inline const char *wine_dbgstr_wn( const WCHAR *s, int n ) +{ + static LPSTR p_ret[10]; + static int i; + + LPSTR ret; + DWORD len; + + if (!s) return ""; + i = (i + 1) % 10; + ret = p_ret[i]; + len = WideCharToMultiByte( CP_ACP, 0, s, -1, NULL, 0, NULL, NULL); + ret = realloc( ret, len ); + if (ret) + WideCharToMultiByte( CP_ACP, 0, s, -1, ret, len, NULL, NULL ); + return ret; +} + +static inline const char *wine_dbg_sprintf( const char *format, ...) +{ + static LPSTR p_ret[10]; + static int i; + + LPSTR ret; + DWORD len; + va_list ap; -extern int wine_dbg_printf( const char *format, ... ) __WINE_PRINTF_ATTR(1,2); -extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func, - const char *format, ... ) __WINE_PRINTF_ATTR(4,5); + va_start(ap, format); + len = _vscprintf(format, ap); + va_end(ap); + + i = (i + 1) % 10; + ret = p_ret[i]; + ret = realloc(ret, len + 1); + + va_start(ap, format); + vsprintf(ret, format, ap); + va_end(ap); + return ret; +} + +#define wine_dbg_printf(format,...) (printf(format, ## __VA_ARGS__), fflush(stdout)) +#define WINE_DPRINTF(class, function, format, ...) \ + wine_dbg_printf(#class ":%s:" format, function, ## __VA_ARGS__) static inline const char *wine_dbgstr_a( const char *s ) { @@ -219,67 +153,24 @@ static inline const char *wine_dbgstr_longlong( ULONGLONG ll ) else return wine_dbg_sprintf( "%lx", (unsigned long)ll ); } -#ifndef WINE_TRACE -#define WINE_TRACE __WINE_DPRINTF(_TRACE,__wine_dbch___default) -#define WINE_TRACE_(ch) __WINE_DPRINTF(_TRACE,&__wine_dbch_##ch) -#endif -#define WINE_TRACE_ON(ch) __WINE_IS_DEBUG_ON(_TRACE,&__wine_dbch_##ch) - -#ifndef WINE_WARN -#define WINE_WARN __WINE_DPRINTF(_WARN,__wine_dbch___default) -#define WINE_WARN_(ch) __WINE_DPRINTF(_WARN,&__wine_dbch_##ch) -#endif -#define WINE_WARN_ON(ch) __WINE_IS_DEBUG_ON(_WARN,&__wine_dbch_##ch) - -#ifndef WINE_FIXME -#define WINE_FIXME __WINE_DPRINTF(_FIXME,__wine_dbch___default) -#define WINE_FIXME_(ch) __WINE_DPRINTF(_FIXME,&__wine_dbch_##ch) -#endif -#define WINE_FIXME_ON(ch) __WINE_IS_DEBUG_ON(_FIXME,&__wine_dbch_##ch) - -#define WINE_ERR __WINE_DPRINTF(_ERR,__wine_dbch___default) -#define WINE_ERR_(ch) __WINE_DPRINTF(_ERR,&__wine_dbch_##ch) -#define WINE_ERR_ON(ch) __WINE_IS_DEBUG_ON(_ERR,&__wine_dbch_##ch) - -#define WINE_DECLARE_DEBUG_CHANNEL(ch) \ - static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch } -#define WINE_DEFAULT_DEBUG_CHANNEL(ch) \ - static struct __wine_debug_channel __wine_dbch_##ch = { ~0, #ch }; \ - static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_##ch - -#define WINE_DPRINTF wine_dbg_printf -#define WINE_MESSAGE wine_dbg_printf - -#ifdef __WINESRC__ /* Wine uses shorter names that are very likely to conflict with other software */ static inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); } static inline const char *debugstr_wn( const WCHAR *s, int n ) { return wine_dbgstr_wn( s, n ); } -static inline const char *debugstr_guid( const struct _GUID *id ) { return wine_dbgstr_guid(id); } +static inline const char *debugstr_guid( const GUID *id ) { return wine_dbgstr_guid( id ); } static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); } static inline const char *debugstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); } -#define TRACE WINE_TRACE -#define TRACE_(ch) WINE_TRACE_(ch) -#define TRACE_ON(ch) WINE_TRACE_ON(ch) - -#define WARN WINE_WARN -#define WARN_(ch) WINE_WARN_(ch) -#define WARN_ON(ch) WINE_WARN_ON(ch) - -#define FIXME WINE_FIXME -#define FIXME_(ch) WINE_FIXME_(ch) -#define FIXME_ON(ch) WINE_FIXME_ON(ch) - #undef ERR /* Solaris got an 'ERR' define in */ -#define ERR WINE_ERR -#define ERR_(ch) WINE_ERR_(ch) -#define ERR_ON(ch) WINE_ERR_ON(ch) - -#define DPRINTF WINE_DPRINTF -#define MESSAGE WINE_MESSAGE +#define TRACE(fmt, ...) (void)0 // WINE_DPRINTF(TRACE, __func__, fmt, ## __VA_ARGS__) +#define TRACE_ON(channel) 0 +#define WARN(fmt, ...) (void)0 // WINE_DPRINTF(WARN, __func__, fmt, ## __VA_ARGS__) +#define WARN_ON(channel) 0 +#define FIXME(fmt, ...) (void)0 // WINE_DPRINTF(FIXME, __func__, fmt, ## __VA_ARGS__) +#define FIXME_ON(channel) 0 +#define ERR(fmt, ...) (void)0 // WINE_DPRINTF(ERR, __func__, fmt, ## __VA_ARGS__) +#define ERR_ON(channel) 0 -#endif /* __WINESRC__ */ #ifdef __cplusplus } -- cgit