Commit 822e1424 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Support magic \1 prefix in debug format for relay traces.

parent ec14c220
......@@ -173,7 +173,9 @@ static int NTDLL_dbg_vlog( enum __wine_debug_class cls, struct __wine_debug_chan
if (TRACE_ON(pid))
ret += wine_dbg_printf( "%04x:", GetCurrentProcessId() );
ret += wine_dbg_printf( "%04x:", GetCurrentThreadId() );
if (cls < sizeof(classes)/sizeof(classes[0]))
if (*format == '\1') /* special magic to avoid standard prefix */
format++;
else if (cls < sizeof(classes)/sizeof(classes[0]))
ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel->name, function );
}
if (format)
......
......@@ -49,7 +49,6 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
WINE_DECLARE_DEBUG_CHANNEL(snoop);
WINE_DECLARE_DEBUG_CHANNEL(loaddll);
WINE_DECLARE_DEBUG_CHANNEL(imports);
WINE_DECLARE_DEBUG_CHANNEL(pid);
#ifdef _WIN64
#define DEFAULT_SECURITY_COOKIE_64 (((ULONGLONG)0x00002b99 << 32) | 0x2ddfa232)
......@@ -1087,36 +1086,21 @@ static void call_tls_callbacks( HMODULE module, UINT reason )
for (callback = (const PIMAGE_TLS_CALLBACK *)dir->AddressOfCallBacks; *callback; callback++)
{
if (TRACE_ON(relay))
{
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
DPRINTF("%04x:Call TLS callback (proc=%p,module=%p,reason=%s,reserved=0)\n",
GetCurrentThreadId(), *callback, module, reason_names[reason] );
}
TRACE_(relay)("\1Call TLS callback (proc=%p,module=%p,reason=%s,reserved=0)\n",
*callback, module, reason_names[reason] );
__TRY
{
call_dll_entry_point( (DLLENTRYPROC)*callback, module, reason, NULL );
}
__EXCEPT_ALL
{
if (TRACE_ON(relay))
{
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
DPRINTF("%04x:exception in TLS callback (proc=%p,module=%p,reason=%s,reserved=0)\n",
GetCurrentThreadId(), callback, module, reason_names[reason] );
}
TRACE_(relay)("\1exception in TLS callback (proc=%p,module=%p,reason=%s,reserved=0)\n",
callback, module, reason_names[reason] );
return;
}
__ENDTRY
if (TRACE_ON(relay))
{
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
DPRINTF("%04x:Ret TLS callback (proc=%p,module=%p,reason=%s,reserved=0)\n",
GetCurrentThreadId(), *callback, module, reason_names[reason] );
}
TRACE_(relay)("\1Ret TLS callback (proc=%p,module=%p,reason=%s,reserved=0)\n",
*callback, module, reason_names[reason] );
}
}
......@@ -1143,11 +1127,8 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved
size_t len = min( wm->ldr.BaseDllName.Length, sizeof(mod_name)-sizeof(WCHAR) );
memcpy( mod_name, wm->ldr.BaseDllName.Buffer, len );
mod_name[len / sizeof(WCHAR)] = 0;
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
DPRINTF("%04x:Call PE DLL (proc=%p,module=%p %s,reason=%s,res=%p)\n",
GetCurrentThreadId(), entry, module, debugstr_w(mod_name),
reason_names[reason], lpReserved );
TRACE_(relay)("\1Call PE DLL (proc=%p,module=%p %s,reason=%s,res=%p)\n",
entry, module, debugstr_w(mod_name), reason_names[reason], lpReserved );
}
else TRACE("(%p %s,%s,%p) - CALL\n", module, debugstr_w(wm->ldr.BaseDllName.Buffer),
reason_names[reason], lpReserved );
......@@ -1160,13 +1141,8 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved
}
__EXCEPT_ALL
{
if (TRACE_ON(relay))
{
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
DPRINTF("%04x:exception in PE entry point (proc=%p,module=%p,reason=%s,res=%p)\n",
GetCurrentThreadId(), entry, module, reason_names[reason], lpReserved );
}
TRACE_(relay)("\1exception in PE entry point (proc=%p,module=%p,reason=%s,res=%p)\n",
entry, module, reason_names[reason], lpReserved );
status = GetExceptionCode();
}
__ENDTRY
......@@ -1175,14 +1151,10 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved
to the dll. We cannot assume that this module has not been
deleted. */
if (TRACE_ON(relay))
{
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
DPRINTF("%04x:Ret PE DLL (proc=%p,module=%p %s,reason=%s,res=%p) retval=%x\n",
GetCurrentThreadId(), entry, module, debugstr_w(mod_name),
reason_names[reason], lpReserved, retv );
}
else TRACE("(%p,%s,%p) - RETURN %d\n", module, reason_names[reason], lpReserved, retv );
TRACE_(relay)("\1Ret PE DLL (proc=%p,module=%p %s,reason=%s,res=%p) retval=%x\n",
entry, module, debugstr_w(mod_name), reason_names[reason], lpReserved, retv );
else
TRACE("(%p,%s,%p) - RETURN %d\n", module, reason_names[reason], lpReserved, retv );
return status;
}
......
......@@ -40,9 +40,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(relay);
#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
WINE_DECLARE_DEBUG_CHANNEL(timestamp);
WINE_DECLARE_DEBUG_CHANNEL(pid);
struct relay_descr /* descriptor for a module */
{
void *magic; /* signature */
......@@ -308,23 +305,17 @@ static inline void RELAY_PrintArgs( const INT_PTR *args, int nb_args, unsigned i
if ((typemask & 3) && !IS_INTARG(*args))
{
if (typemask & 2)
DPRINTF( "%08lx %s", *args, debugstr_w((LPCWSTR)*args) );
TRACE( "%08lx %s", *args, debugstr_w((LPCWSTR)*args) );
else
DPRINTF( "%08lx %s", *args, debugstr_a((LPCSTR)*args) );
TRACE( "%08lx %s", *args, debugstr_a((LPCSTR)*args) );
}
else DPRINTF( "%08lx", *args );
if (nb_args) DPRINTF( "," );
else TRACE( "%08lx", *args );
if (nb_args) TRACE( "," );
args++;
typemask >>= 2;
}
}
static void print_timestamp(void)
{
ULONG ticks = NtGetTickCount();
DPRINTF( "%3u.%03u:", ticks / 1000, ticks % 1000 );
}
/***********************************************************************
* relay_trace_entry
*
......@@ -340,17 +331,12 @@ DECLSPEC_HIDDEN void * WINAPI relay_trace_entry( struct relay_descr *descr,
if (TRACE_ON(relay))
{
if (TRACE_ON(timestamp)) print_timestamp();
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
if (entry_point->name)
DPRINTF( "%04x:Call %s.%s(", GetCurrentThreadId(), data->dllname, entry_point->name );
TRACE( "\1Call %s.%s(", data->dllname, entry_point->name );
else
DPRINTF( "%04x:Call %s.%u(", GetCurrentThreadId(), data->dllname, data->base + ordinal );
TRACE( "\1Call %s.%u(", data->dllname, data->base + ordinal );
RELAY_PrintArgs( stack + 1, nb_args, descr->arg_types[ordinal] );
DPRINTF( ") ret=%08lx\n", stack[0] );
TRACE( ") ret=%08lx\n", stack[0] );
}
return entry_point->orig_func;
}
......@@ -366,23 +352,16 @@ DECLSPEC_HIDDEN void WINAPI relay_trace_exit( struct relay_descr *descr, unsigne
struct relay_private_data *data = descr->private;
struct relay_entry_point *entry_point = data->entry_points + ordinal;
if (!TRACE_ON(relay)) return;
if (TRACE_ON(timestamp)) print_timestamp();
if (TRACE_ON(pid))
DPRINTF( "%04x:", GetCurrentProcessId() );
if (entry_point->name)
DPRINTF( "%04x:Ret %s.%s()", GetCurrentThreadId(), data->dllname, entry_point->name );
TRACE( "\1Ret %s.%s()", data->dllname, entry_point->name );
else
DPRINTF( "%04x:Ret %s.%u()", GetCurrentThreadId(), data->dllname, data->base + ordinal );
TRACE( "\1Ret %s.%u()", data->dllname, data->base + ordinal );
if (flags & 1) /* 64-bit return value */
DPRINTF( " retval=%08x%08x ret=%08lx\n",
TRACE( " retval=%08x%08x ret=%08lx\n",
(UINT)(retval >> 32), (UINT)retval, stack[0] );
else
DPRINTF( " retval=%08lx ret=%08lx\n", (UINT_PTR)retval, stack[0] );
TRACE( " retval=%08lx ret=%08lx\n", (UINT_PTR)retval, stack[0] );
}
#ifdef __i386__
......@@ -952,7 +931,7 @@ static void SNOOP_PrintArg(DWORD x)
{
int i,nostring;
DPRINTF("%08x",x);
TRACE_(snoop)("%08x",x);
if (IS_INTARG(x) || TRACE_ON(seh)) return; /* trivial reject to avoid faults */
__TRY
{
......@@ -965,7 +944,7 @@ static void SNOOP_PrintArg(DWORD x)
i++;
}
if (!nostring && i > 5)
DPRINTF(" %s",debugstr_an((LPSTR)x,i));
TRACE_(snoop)(" %s",debugstr_an((LPSTR)x,i));
else /* try unicode */
{
LPWSTR s=(LPWSTR)x;
......@@ -976,7 +955,7 @@ static void SNOOP_PrintArg(DWORD x)
if (s[i]>0x100) {nostring=1;break;}
i++;
}
if (!nostring && i > 5) DPRINTF(" %s",debugstr_wn((LPWSTR)x,i));
if (!nostring && i > 5) TRACE_(snoop)(" %s",debugstr_wn((LPWSTR)x,i));
}
}
__EXCEPT_PAGE_FAULT
......@@ -1049,26 +1028,24 @@ void WINAPI DECLSPEC_HIDDEN __regs_SNOOP_Entry( void **stack )
if (!TRACE_ON(snoop)) return;
if (TRACE_ON(timestamp))
print_timestamp();
if (fun->name) DPRINTF("%04x:CALL %s.%s(",GetCurrentThreadId(),dll->name,fun->name);
else DPRINTF("%04x:CALL %s.%d(",GetCurrentThreadId(),dll->name,dll->ordbase+ret->ordinal);
if (fun->name) TRACE_(snoop)("\1CALL %s.%s(", dll->name, fun->name);
else TRACE_(snoop)("\1CALL %s.%d(", dll->name, dll->ordbase+ret->ordinal);
if (fun->nrofargs>0) {
max = fun->nrofargs; if (max>16) max=16;
for (i=0;i<max;i++)
{
SNOOP_PrintArg( (DWORD)stack[i + 2] );
if (i<fun->nrofargs-1) DPRINTF(",");
if (i<fun->nrofargs-1) TRACE_(snoop)(",");
}
if (max!=fun->nrofargs)
DPRINTF(" ...");
TRACE_(snoop)(" ...");
} else if (fun->nrofargs<0) {
DPRINTF("<unknown, check return>");
TRACE_(snoop)("<unknown, check return>");
ret->args = RtlAllocateHeap(GetProcessHeap(),
0,16*sizeof(DWORD));
memcpy(ret->args, stack + 2, sizeof(DWORD)*16);
}
DPRINTF(") ret=%08x\n",(DWORD)ret->origreturn);
TRACE_(snoop)(") ret=%08x\n",(DWORD)ret->origreturn);
}
void WINAPI DECLSPEC_HIDDEN __regs_SNOOP_Return( void **stack )
......@@ -1091,16 +1068,13 @@ void WINAPI DECLSPEC_HIDDEN __regs_SNOOP_Return( void **stack )
return;
}
if (TRACE_ON(timestamp))
print_timestamp();
if (ret->args) {
int i,max;
if (fun->name)
DPRINTF("%04x:RET %s.%s(", GetCurrentThreadId(), ret->dll->name, fun->name);
TRACE_(snoop)("\1RET %s.%s(", ret->dll->name, fun->name);
else
DPRINTF("%04x:RET %s.%d(", GetCurrentThreadId(),
ret->dll->name,ret->dll->ordbase+ret->ordinal);
TRACE_(snoop)("\1RET %s.%d(", ret->dll->name, ret->dll->ordbase+ret->ordinal);
max = fun->nrofargs;
if (max>16) max=16;
......@@ -1108,21 +1082,19 @@ void WINAPI DECLSPEC_HIDDEN __regs_SNOOP_Return( void **stack )
for (i=0;i<max;i++)
{
SNOOP_PrintArg(ret->args[i]);
if (i<max-1) DPRINTF(",");
if (i<max-1) TRACE_(snoop)(",");
}
DPRINTF(") retval=%08x ret=%08x\n", retval, (DWORD)ret->origreturn );
TRACE_(snoop)(") retval=%08x ret=%08x\n", retval, (DWORD)ret->origreturn );
RtlFreeHeap(GetProcessHeap(),0,ret->args);
ret->args = NULL;
}
else
{
if (fun->name)
DPRINTF("%04x:RET %s.%s() retval=%08x ret=%08x\n",
GetCurrentThreadId(),
ret->dll->name, fun->name, retval, (DWORD)ret->origreturn);
TRACE_(snoop)("\1RET %s.%s() retval=%08x ret=%08x\n",
ret->dll->name, fun->name, retval, (DWORD)ret->origreturn);
else
DPRINTF("%04x:RET %s.%d() retval=%08x ret=%08x\n",
GetCurrentThreadId(),
TRACE_(snoop)("\1RET %s.%d() retval=%08x ret=%08x\n",
ret->dll->name,ret->dll->ordbase+ret->ordinal,
retval, (DWORD)ret->origreturn);
}
......
......@@ -479,8 +479,7 @@ static void thread_startup( void *param )
attach_dlls( (void *)1 );
if (TRACE_ON(relay))
DPRINTF( "%04x:Starting thread proc %p (arg=%p)\n", GetCurrentThreadId(), func, arg );
TRACE_(relay)( "\1Starting thread proc %p (arg=%p)\n", func, arg );
call_thread_entry_point( (LPTHREAD_START_ROUTINE)func, arg );
}
......
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