Hey guys,
I don't know if you've ever wished the relay traces were indented by
the level of the call, so you can get a better feel for who calls what
from where, but I thought it would be nifty. I've attached a patch
for dlls/ntdll/relay.c that gives you this. You see the call level
next to the thread id, then twice that number of spaces, then the
usual relay information. I'd paste an example, but it would just get
line wrapped, so patch your tree and give it a shot!
--
James Hawkins
diff --git a/dlls/ntdll/relay.c b/dlls/ntdll/relay.c
index b9f5cc0..2e9ab58 100644
--- a/dlls/ntdll/relay.c
+++ b/dlls/ntdll/relay.c
@@ -338,6 +338,8 @@ static inline void RELAY_PrintArgs( int
}
}
+static int level = 0;
+
extern LONGLONG call_entry_point( void *func, int nb_args, const int *args );
__ASM_GLOBAL_FUNC( call_entry_point,
"\tpushl %ebp\n"
@@ -375,24 +377,28 @@ static LONGLONG WINAPI relay_call_from_3
BYTE flags = HIBYTE(HIWORD(idx));
struct relay_private_data *data = descr->private;
struct relay_entry_point *entry_point = data->entry_points + ordinal;
+char spaces[100];
if (!TRACE_ON(relay))
ret = call_entry_point( entry_point->orig_func, nb_args, stack + 1 );
else
{
+memset(spaces, ' ', level * 2);
+spaces[level * 2] = '\0';
+
if (entry_point->name)
-DPRINTF( "%04lx:Call %s.%s(", GetCurrentThreadId(), data->dllname, entry_point->name );
+DPRINTF( "%04lx:%i:%sCall %s.%s(", GetCurrentThreadId(), level++, spaces, data->dllname, entry_point->name );
else
-DPRINTF( "%04lx:Call %s.%u(", GetCurrentThreadId(), data->dllname, data->base + ordinal );
+DPRINTF( "%04lx:%i:%sCall %s.%u(", GetCurrentThreadId(), level++, spaces, data->dllname, data->base + ordinal );
RELAY_PrintArgs( stack + 1, nb_args, descr->arg_types[ordinal] );
DPRINTF( ") ret=%08x\n", stack[0] );
ret = call_entry_point( entry_point->orig_func, nb_args, stack + 1 );
if (entry_point->name)
-DPRINTF( "%04lx:Ret %s.%s()", GetCurrentThreadId(), data->dllname, entry_point->name );
+DPRINTF( "%04lx:%i:%sRet %s.%s()", GetCurrentThreadId(), --level, spaces, data->dllname, entry_point->name );
else
-DPRINTF( "%04lx:Ret %s.%u()", GetCurrentThreadId(), data->dllname, data->base + ordinal );
+DPRINTF( "%04lx:%i:%sRet %s.%u()", GetCurrentThreadId(), --level, spaces, data->dllname, data->base + ordinal );
if (flags & 1) /* 64-bit return value */
DPRINTF( " retval=%08x%08x ret=%08x\n",
@@ -419,6 +425,7 @@ void WINAPI __regs_relay_call_from_32_re
BYTE *orig_func = entry_point->orig_func;
int *args = (int *)context->Esp;
int args_copy[32];
+char spaces[100];
/* restore the context to what it was before the relay thunk */
context->Eax = orig_eax;
@@ -428,10 +435,13 @@ void WINAPI __regs_relay_call_from_32_re
if (TRACE_ON(relay))
{
+memset(spaces, ' ', level * 2);
+spaces[level * 2] = '\0';
+
if (entry_point->name)
-DPRINTF( "%04lx:Call %s.%s(", GetCurrentThreadId(), data->dllname, entry_point->name );
+DPRINTF( "%04lx:%i:%sCall %s.%s(", GetCurrentThreadId(), level++, spaces, data->dllname, entry_point->name );
else
-DPRINTF( "%04lx:Call %s.%u(", GetCurrentThreadId(), data->dllname, data->base + ordinal );
+DPRINTF( "%04lx:%i:%sCall %s.%u(", GetCurrentThreadId(), level++, spaces, data->dllname, data->base + ordinal );
RELAY_PrintArgs( args, nb_args, descr->arg_types[ordinal] );
DPRINTF( ") ret=%08x\n", ret_addr );
@@ -456,12 +466,12 @@ void WINAPI __regs_relay_call_from_32_re
if (TRACE_ON(relay))
{
if (entry_point->name)
-DPRINTF( "%04lx:Ret %s.%s() retval=%08lx ret=%08lx\n",
- GetCurrentThreadId(), data->dllname, entry_point->name,
+DPRINTF( "%04lx:%i:%sRet %s.%s() retval=%08lx ret=%08lx\n",
+ GetCurrentThreadId(), --level, spaces, data->dllname, entry_point->name,
context->Eax, context->Eip );
else
-DPRINTF( "%04lx:Ret %s.%u() retval=%08lx ret=%08lx\n",
- GetCurrentThreadId(), data->dllname, data->base + ordinal,
+DPRINTF( "%04lx:%i:%sRet %s.%u() retval=%08lx ret=%08lx\n",
+ GetCurrentThreadId(), --level, spaces, data->dllname, data->base + ordinal,
context->Eax, context->Eip );
DPRINTF( "%04lx: eax=%08lx ebx=%08lx ecx=%08lx edx=%08lx esi=%08lx edi=%08lx "
"ebp=%08lx esp=%08lx ds=%04lx es=%04lx fs=%04lx gs=%04lx flags=%08lx\n",