Traces: fs -> tid

Francois Gouget fgouget at free.fr
Tue Apr 10 02:07:23 CDT 2001


   I noticed that fs was replaced by tid in relay (and snoop & co too
now). I propose a slightly different version based on the following
premises:

 * when suspecting a threading problem it could be nice to tag each
trace with the id of the thread that emits it

 * when there's no thread issue, then fs and tid are unnecessary and
only clutter the traces by making lines longer and harder to read

 * I find that lines are more readable if the thread id comes first as
it's always the same length and doesn't mess up the alignment of the
other fields

   So this patch adds a debug channel called 'tid' which activates
printing the tid as the first field of all traces. Actually, it might
make sense to merge 'tid' with the 'thread' debug channel.

   'Screenshot':

08063178:Call user32.DispatchMessageA(405b6e50) ret=00402135
08063178:trace:relay:WINPROC_CallWndProc (wndproc=0x401c74,hwnd=00000138,msg=WM_SYSCOMMAND,wp=0000f060,lp=00000000)
08063178:Call user32.DefWindowProcA(00000138,00000112,0000f060,00000000) ret=0040206c


   Comments?



Changelog:

 * dlls/ntdll/ntdll.spec
   Declare the tid debug channel

 * dlls/ntdll/debugtools.c,
   relay32/relay386.c,
   relay32/snoop.c
   Output the current thread id as the first field if tid is turned on


--
Francois Gouget         fgouget at free.fr        http://fgouget.free.fr/
                           La terre est une bêta...

-------------- next part --------------
Index: dlls/ntdll/ntdll.spec
===================================================================
RCS file: /home/cvs/wine/wine/dlls/ntdll/ntdll.spec,v
retrieving revision 1.44
diff -u -r1.44 ntdll.spec
--- dlls/ntdll/ntdll.spec	2001/04/09 18:34:50	1.44
+++ dlls/ntdll/ntdll.spec	2001/04/10 05:49:26
@@ -5,7 +5,7 @@
                 file fixup global heap int int10 int16 int17 int19 int21 int31
                 io loaddll local module ntdll process profile reg relay resource
                 segment seh selector server snoop string system tape task thread
-                thunk timer toolhelp ver virtual vxd win32)
+                thunk tid timer toolhelp ver virtual vxd win32)
 
 #note that the Zw... functions are alternate names for the 
 #Nt... functions.  (see www.sysinternals.com for details)
Index: dlls/ntdll/debugtools.c
===================================================================
RCS file: /home/cvs/wine/wine/dlls/ntdll/debugtools.c,v
retrieving revision 1.6
diff -u -r1.6 debugtools.c
--- dlls/ntdll/debugtools.c	2001/03/21 23:54:59	1.6
+++ dlls/ntdll/debugtools.c	2001/04/10 05:49:25
@@ -15,6 +15,9 @@
 #include "winnt.h"
 #include "wtypes.h"
 
+DECLARE_DEBUG_CHANNEL(tid);
+
+
 /* ---------------------------------------------------------------------- */
 
 struct debug_info
@@ -248,8 +251,11 @@
     int ret = 0;
 
     va_start(valist, format);
-    if (cls < __DBCL_COUNT)
-        ret = wine_dbg_printf( "%s:%s:%s ", classes[cls], channel + 1, function );
+    if (cls < __DBCL_COUNT) {
+        if (TRACE_ON(tid))
+            ret = wine_dbg_printf( "%08lx:", GetCurrentThreadId() );
+        ret += wine_dbg_printf( "%s:%s:%s ", classes[cls], channel + 1, function );
+    }
     if (format)
         ret += wine_dbg_vprintf( format, valist );
     va_end(valist);
Index: relay32/relay386.c
===================================================================
RCS file: /home/cvs/wine/wine/relay32/relay386.c,v
retrieving revision 1.33
diff -u -r1.33 relay386.c
--- relay32/relay386.c	2001/04/09 18:47:10	1.33
+++ relay32/relay386.c	2001/04/10 05:49:32
@@ -17,6 +17,7 @@
 #include "debugtools.h"
 
 DEFAULT_DEBUG_CHANNEL(relay);
+DECLARE_DEBUG_CHANNEL(tid);
 
 char **debug_relay_excludelist = NULL, **debug_relay_includelist = NULL;
 
@@ -183,9 +184,11 @@
 
     get_entry_point( buffer, relay );
 
+    if (TRACE_ON(tid))
+        DPRINTF("%08lx:",GetCurrentThreadId());
     DPRINTF( "Call %s(", buffer );
     RELAY_PrintArgs( args, nb_args, relay->argtypes );
-    DPRINTF( ") ret=%08x tid=%08lx\n", ret_addr, GetCurrentThreadId() );
+    DPRINTF( ") ret=%08x\n", ret_addr );
     ret64 = (relay->argtypes & 0x80000000) && (nb_args < 16);
 
     /* the user driver functions may be called with the window lock held */
@@ -278,12 +281,14 @@
             assert(FALSE);
         }
     }
+    if (TRACE_ON(tid))
+        DPRINTF("%08lx:",GetCurrentThreadId());
     if (ret64)
-        DPRINTF( "Ret  %s() retval=%08x%08x ret=%08x tid=%08lx\n",
-                 buffer, (UINT)(ret >> 32), (UINT)ret, ret_addr, GetCurrentThreadId() );
+        DPRINTF( "Ret  %s() retval=%08x%08x ret=%08x\n",
+                 buffer, (UINT)(ret >> 32), (UINT)ret, ret_addr );
     else
-        DPRINTF( "Ret  %s() retval=%08x ret=%08x tid=%08lx\n",
-                 buffer, (UINT)ret, ret_addr, GetCurrentThreadId() );
+        DPRINTF( "Ret  %s() retval=%08x ret=%08x\n",
+                 buffer, (UINT)ret, ret_addr );
 
     if (memcmp( buffer, "x11drv.", 7 ) && memcmp( buffer, "ttydrv.", 7 ))
       SYSLEVEL_CheckNotLevel( 2 );
@@ -328,6 +333,8 @@
 
     get_entry_point( buffer, relay );
 
+    if (TRACE_ON(tid))
+        DPRINTF("%08lx:",GetCurrentThreadId());
     DPRINTF( "Call %s(", buffer );
     RELAY_PrintArgs( args, nb_args, relay->argtypes );
     DPRINTF( ") ret=%08lx fs=%04lx\n", context->Eip, context->SegFs );
@@ -374,6 +381,8 @@
         assert(FALSE);
     }
 
+    if (TRACE_ON(tid))
+        DPRINTF("%08lx:",GetCurrentThreadId());
     DPRINTF( "Ret  %s() retval=%08lx ret=%08lx fs=%04lx\n",
              buffer, context->Eax, context->Eip, context->SegFs );
 
Index: relay32/snoop.c
===================================================================
RCS file: /home/cvs/wine/wine/relay32/snoop.c,v
retrieving revision 1.39
diff -u -r1.39 snoop.c
--- relay32/snoop.c	2001/02/12 01:19:04	1.39
+++ relay32/snoop.c	2001/04/10 05:49:33
@@ -18,6 +18,7 @@
 #include "wine/exception.h"
 
 DEFAULT_DEBUG_CHANNEL(snoop);
+DECLARE_DEBUG_CHANNEL(tid);
 
 static WINE_EXCEPTION_FILTER(page_fault)
 {
@@ -322,6 +323,8 @@
 
 	context->Eip = (DWORD)fun->origfun;
 
+        if (TRACE_ON(tid))
+            DPRINTF("%08lx:",GetCurrentThreadId());
 	DPRINTF("CALL %s.%ld: %s(",dll->name,ordinal,fun->name);
 	if (fun->nrofargs>0) {
 		max = fun->nrofargs; if (max>16) max=16;
@@ -334,7 +337,7 @@
 		ret->args = HeapAlloc(GetProcessHeap(),0,16*sizeof(DWORD));
 		memcpy(ret->args,(LPBYTE)(context->Esp + 4),sizeof(DWORD)*16);
 	}
-	DPRINTF(") ret=%08lx fs=%04lx\n",(DWORD)ret->origreturn,context->SegFs);
+	DPRINTF(") ret=%08lx\n",(DWORD)ret->origreturn);
 }
 
 
@@ -350,6 +353,8 @@
 	if (ret->dll->funs[ret->ordinal].nrofargs<0)
 		ret->dll->funs[ret->ordinal].nrofargs=(context->Esp - ret->origESP-4)/4;
 	context->Eip = (DWORD)ret->origreturn;
+        if (TRACE_ON(tid))
+            DPRINTF("%08lx:",GetCurrentThreadId());
 	if (ret->args) {
 		int	i,max;
 
@@ -359,8 +364,8 @@
 
 		for (i=0;i<max;i++)
 			DPRINTF("%s%s",SNOOP_PrintArg(ret->args[i]),(i<max-1)?",":"");
-		DPRINTF(") retval = %08lx ret=%08lx fs=%04lx\n",
-			context->Eax,(DWORD)ret->origreturn,context->SegFs );
+		DPRINTF(") retval = %08lx ret=%08lx\n",
+			context->Eax,(DWORD)ret->origreturn );
 		HeapFree(GetProcessHeap(),0,ret->args);
 		ret->args = NULL;
 	} else


More information about the wine-devel mailing list