1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#ifndef __WINE_WINE_DEBUG_H
#define __WINE_WINE_DEBUG_H
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <glib.h>
G_BEGIN_DECLS
enum __wine_debug_class
{
DBCL_FIXME,
DBCL_ERR,
DBCL_WARN,
DBCL_TRACE,
DBCL_INIT = 7
};
static inline const char *wine_dbgstr_an( const char * s, int n )
{
if (!s) return "";
return s;
}
const char *wine_dbg_sprintf( const char *format, ...) G_GNUC_PRINTF (1, 2);;
#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 )
{
return wine_dbgstr_an( s, -1 );
}
static inline const char *wine_dbgstr_guid( const uint8_t *id )
{
return wine_dbg_sprintf( "{%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7],
id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]);
}
static inline const char *wine_dbgstr_longlong( unsigned long long ll )
{
if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
}
static inline const char *debugstr_an( const char * s, int n ) { return wine_dbgstr_an( s, n ); }
static inline const char *debugstr_guid( const uint8_t *id ) { return wine_dbgstr_guid( id ); }
static inline const char *debugstr_a( const char *s ) { return wine_dbgstr_an( s, -1 ); }
#ifndef TRACE_ON
#define TRACE_ON 0
#endif
#define TRACE(fmt, ...) G_STMT_START{ \
if (TRACE_ON) { \
g_debug(G_STRLOC " " fmt, ## __VA_ARGS__); \
} \
}G_STMT_END
G_END_DECLS
#endif
|