Commit cf8193df authored by Alexandre Julliard's avatar Alexandre Julliard

include: Make wine_dbg_log() into an inline function.

parent 9911cfde
...@@ -276,6 +276,38 @@ int __cdecl __wine_dbg_output( const char *str ) ...@@ -276,6 +276,38 @@ int __cdecl __wine_dbg_output( const char *str )
} }
/*********************************************************************** /***********************************************************************
* __wine_dbg_header (NTDLL.@)
*/
int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function )
{
static const char * const classes[] = { "fixme", "err", "warn", "trace" };
struct debug_info *info = get_info();
char buffer[200], *pos = buffer;
if (!(__wine_dbg_get_channel_flags( channel ) & (1 << cls))) return -1;
/* only print header if we are at the beginning of the line */
if (info->out_pos > info->output) return 0;
if (init_done)
{
if (TRACE_ON(timestamp))
{
ULONG ticks = NtGetTickCount();
pos += sprintf( pos, "%3u.%03u:", ticks / 1000, ticks % 1000 );
}
if (TRACE_ON(pid)) pos += sprintf( pos, "%04x:", GetCurrentProcessId() );
pos += sprintf( pos, "%04x:", GetCurrentThreadId() );
}
if (function && cls < ARRAY_SIZE( classes ))
snprintf( pos, sizeof(buffer) - (pos - buffer), "%s:%s:%s ",
classes[cls], channel->name, function );
return append_output( info, buffer, strlen( buffer ));
}
/***********************************************************************
* NTDLL_dbg_vprintf * NTDLL_dbg_vprintf
*/ */
static int NTDLL_dbg_vprintf( const char *format, va_list args ) static int NTDLL_dbg_vprintf( const char *format, va_list args )
......
...@@ -1507,6 +1507,7 @@ ...@@ -1507,6 +1507,7 @@
# Debugging # Debugging
@ cdecl -norelay __wine_dbg_get_channel_flags(ptr) @ cdecl -norelay __wine_dbg_get_channel_flags(ptr)
@ cdecl -norelay __wine_dbg_header(long long str)
@ cdecl -norelay __wine_dbg_output(str) @ cdecl -norelay __wine_dbg_output(str)
@ cdecl -norelay __wine_dbg_strdup(str) @ cdecl -norelay __wine_dbg_strdup(str)
......
...@@ -161,6 +161,8 @@ extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_f ...@@ -161,6 +161,8 @@ extern void __wine_dbg_set_functions( const struct __wine_debug_functions *new_f
struct __wine_debug_functions *old_funcs, size_t size ); struct __wine_debug_functions *old_funcs, size_t size );
extern const char * __cdecl __wine_dbg_strdup( const char *str ); extern const char * __cdecl __wine_dbg_strdup( const char *str );
extern int __cdecl __wine_dbg_output( const char *str ); extern int __cdecl __wine_dbg_output( const char *str );
extern int __cdecl __wine_dbg_header( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *function );
/* /*
* Exported definitions and macros * Exported definitions and macros
...@@ -170,9 +172,6 @@ extern int __cdecl __wine_dbg_output( const char *str ); ...@@ -170,9 +172,6 @@ extern int __cdecl __wine_dbg_output( const char *str );
quotes. The string will be valid for some time, but not indefinitely quotes. The string will be valid for some time, but not indefinitely
as strings are re-used. */ as strings are re-used. */
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);
#if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT) #if (defined(__x86_64__) || defined(__aarch64__)) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
# define __wine_dbg_cdecl __cdecl # define __wine_dbg_cdecl __cdecl
# define __wine_dbg_va_list __builtin_ms_va_list # define __wine_dbg_va_list __builtin_ms_va_list
...@@ -209,6 +208,31 @@ static inline int __wine_dbg_cdecl wine_dbg_printf( const char *format, ... ) ...@@ -209,6 +208,31 @@ static inline int __wine_dbg_cdecl wine_dbg_printf( const char *format, ... )
return __wine_dbg_output( buffer ); return __wine_dbg_output( buffer );
} }
static int __wine_dbg_cdecl wine_dbg_log( enum __wine_debug_class cls,
struct __wine_debug_channel *channel, const char *func,
const char *format, ... ) __WINE_PRINTF_ATTR(4,5);
static inline int __wine_dbg_cdecl wine_dbg_log( enum __wine_debug_class cls,
struct __wine_debug_channel *channel,
const char *function, const char *format, ... )
{
char buffer[1024];
__wine_dbg_va_list args;
int ret;
if (*format == '\1') /* special magic to avoid standard prefix */
{
format++;
function = NULL;
}
if ((ret = __wine_dbg_header( cls, channel, function )) == -1) return ret;
__wine_dbg_va_start( args, format );
vsnprintf( buffer, sizeof(buffer), format, args );
__wine_dbg_va_end( args );
ret += __wine_dbg_output( buffer );
return ret;
}
static inline const char *wine_dbgstr_an( const char *str, int n ) static inline const char *wine_dbgstr_an( const char *str, int n )
{ {
static const char hex[16] = "0123456789abcdef"; static const char hex[16] = "0123456789abcdef";
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#define __wine_dbg_get_channel_flags __wine_dbg_get_channel_flags_inline #define __wine_dbg_get_channel_flags __wine_dbg_get_channel_flags_inline
#define wine_dbg_sprintf wine_dbg_sprintf_inline #define wine_dbg_sprintf wine_dbg_sprintf_inline
#define wine_dbg_printf wine_dbg_printf_inline #define wine_dbg_printf wine_dbg_printf_inline
#define wine_dbg_log wine_dbg_log_inline
#define wine_dbgstr_an wine_dbgstr_an_inline #define wine_dbgstr_an wine_dbgstr_an_inline
#define wine_dbgstr_wn wine_dbgstr_wn_inline #define wine_dbgstr_wn wine_dbgstr_wn_inline
#include "wine/debug.h" #include "wine/debug.h"
...@@ -252,6 +253,7 @@ const char *wine_dbg_sprintf( const char *format, ... ) ...@@ -252,6 +253,7 @@ const char *wine_dbg_sprintf( const char *format, ... )
/* varargs wrapper for funcs.dbg_vlog */ /* varargs wrapper for funcs.dbg_vlog */
#undef wine_dbg_log
int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *channel, int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *channel,
const char *func, const char *format, ... ) const char *func, const char *format, ... )
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment