[PATCH] deferred trace

gerard patel gerard.patel at asi.fr
Sat Mar 10 10:46:20 CST 2001


This implements a way to not output the debug trace to disk until the
user hits Alf + F12. The goal is to avoid too big trace files.

Also fixes an unrelated problem in WIN_WalkWindows.

ChangeLog:

    * dlls/ntdll/debugtools.c, include/debugtools.h, include/server.h,loader/main.c,misc/options.c,
       scheduler/client.c, server/request.h,server/thread.c,server/trace.c,windows/defwnd.c,windows/win.c
    Implements deferred trace until Alt + F12

-------------- next part --------------
Index: dlls/ntdll/debugtools.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/debugtools.c,v
retrieving revision 1.5
diff -u -r1.5 debugtools.c
--- dlls/ntdll/debugtools.c	2001/02/16 19:52:50	1.5
+++ dlls/ntdll/debugtools.c	2001/03/10 16:31:38
@@ -12,9 +12,10 @@
 #include "debugtools.h"
 #include "thread.h"
 #include "winbase.h"
-#include "winnt.h"
-#include "wtypes.h"
+#include "server.h"
 
+DECLARE_DEBUG_CHANNEL(server);
+
 /* ---------------------------------------------------------------------- */
 
 struct debug_info
@@ -27,6 +28,8 @@
 
 static struct debug_info tmp;
 
+static BOOL deferredTrace = FALSE, traceEnabled = TRUE;
+
 /* get the debug info pointer for the current thread */
 static inline struct debug_info *get_info(void)
 {
@@ -200,8 +203,12 @@
 {
     struct debug_info *info = get_info();
     char *p;
+    int ret;
+
+    if (!traceEnabled)
+        return 0;
 
-    int ret = vsnprintf( info->out_pos, sizeof(info->output) - (info->out_pos - info->output),
+    ret = vsnprintf( info->out_pos, sizeof(info->output) - (info->out_pos - info->output),
                          format, args );
 
     /* make sure we didn't exceed the buffer length
@@ -231,6 +238,8 @@
     int ret;
     va_list valist;
 
+    if (!traceEnabled)
+        return 0;
     va_start(valist, format);
     ret = wine_dbg_vprintf( format, valist );
     va_end(valist);
@@ -238,6 +247,38 @@
 }
 
 /***********************************************************************
+ *		wine_dbg_switch_trace : get/set debug trace state
+ *  init = TRUE: init feature
+ *  switchIt : TRUE to switch trace state
+ *  returns -1 if feature not used, 0 if trace disabled, 1 if enabled
+ */
+int wine_dbg_switch_trace(BOOL init, BOOL switchIt)
+{
+    if (init)
+    {
+         deferredTrace = TRUE;
+         traceEnabled = FALSE;
+         return 0;
+    }
+    if (!deferredTrace)
+        return -1;
+    if (switchIt)
+    {
+        traceEnabled = !traceEnabled;
+        if (TRACE_ON(server))
+        {
+           SERVER_START_REQ( enable_trace )
+           {
+               req->debug_level = (traceEnabled == 1) ? TRACE_ON(server) : 0;
+               SERVER_CALL();
+           }
+           SERVER_END_REQ;   
+        }
+    }
+    return traceEnabled ? 1 : 0;
+}
+
+/***********************************************************************
  *		wine_dbg_log
  */
 int wine_dbg_log(enum __DEBUG_CLASS cls, const char *channel,
@@ -246,6 +287,9 @@
     static const char *classes[__DBCL_COUNT] = { "fixme", "err", "warn", "trace" };
     va_list valist;
     int ret = 0;
+
+    if (!traceEnabled)
+        return 0;
 
     va_start(valist, format);
     if (cls < __DBCL_COUNT)
Index: include/debugtools.h
===================================================================
RCS file: /home/wine/wine/include/debugtools.h,v
retrieving revision 1.13
diff -u -r1.13 debugtools.h
--- include/debugtools.h	2000/12/22 20:28:19	1.13
+++ include/debugtools.h	2001/03/10 16:31:48
@@ -70,6 +70,7 @@
 
 extern int wine_dbg_vprintf( const char *format, va_list args ) __PRINTF_ATTR(1,0);
 extern int wine_dbg_printf( const char *format, ... ) __PRINTF_ATTR(1,2);
+extern int wine_dbg_switch_trace( BOOL init, BOOL switchIt );
 extern int wine_dbg_log( enum __DEBUG_CLASS cls, const char *ch,
                          const char *func, const char *format, ... ) __PRINTF_ATTR(4,5);
 
Index: include/server.h
===================================================================
RCS file: /home/wine/wine/include/server.h,v
retrieving revision 1.92
diff -u -r1.92 server.h
--- include/server.h	2001/03/08 01:16:41	1.92
+++ include/server.h	2001/03/10 16:31:58
@@ -1379,6 +1379,13 @@
     IN  int          result;       /* NT status code */
 };
 
+/* enable server trace */
+struct enable_trace_request
+{
+    REQUEST_HEADER;                /* request header */
+    IN  int          debug_level;  /* new debug level */
+};
+
 /* Everything below this line is generated automatically by tools/make_requests */
 /* ### make_requests begin ### */
 
@@ -1493,6 +1500,7 @@
     REQ_set_serial_info,
     REQ_create_async,
     REQ_async_result,
+    REQ_enable_trace,
     REQ_NB_REQUESTS
 };
 
@@ -1609,9 +1617,10 @@
     struct set_serial_info_request set_serial_info;
     struct create_async_request create_async;
     struct async_result_request async_result;
+    struct enable_trace_request enable_trace;
 };
 
-#define SERVER_PROTOCOL_VERSION 42
+#define SERVER_PROTOCOL_VERSION 43
 
 /* ### make_requests end ### */
 /* Everything above this line is generated automatically by tools/make_requests */
Index: loader/main.c
===================================================================
RCS file: /home/wine/wine/loader/main.c,v
retrieving revision 1.77
diff -u -r1.77 main.c
--- loader/main.c	2000/12/12 00:50:20	1.77
+++ loader/main.c	2001/03/10 16:32:02
@@ -60,7 +60,7 @@
     SHELL_LoadRegistry();
     
     /* Global boot finished, the rest is process-local */
-    CLIENT_BootDone( TRACE_ON(server) );
+    CLIENT_BootDone( (wine_dbg_switch_trace(FALSE,FALSE) != 0) ? TRACE_ON(server) : 0 );
 
     /* Initialize module loadorder */
     if (!MODULE_InitLoadOrder()) return FALSE;
Index: misc/options.c
===================================================================
RCS file: /home/wine/wine/misc/options.c,v
retrieving revision 1.24
diff -u -r1.24 options.c
--- misc/options.c	2001/02/12 03:47:11	1.24
+++ misc/options.c	2001/03/10 16:32:05
@@ -62,6 +62,7 @@
 static void do_debugmsg( const char *arg );
 static void do_desktop( const char *arg );
 static void do_display( const char *arg );
+static void do_deferred( const char *arg );
 static void do_dll( const char *arg );
 static void do_help( const char *arg );
 static void do_language( const char *arg );
@@ -95,6 +96,8 @@
       "--version,-v     Display the Wine version" },
     { "winver",       0, 1, 1, VERSION_ParseWinVersion,
       "--winver         Version to imitate (win95,nt40,win31,nt2k,win98,nt351,win30,win20)" },
+    { "dt",           0, 0, 1, do_deferred,
+      "--dt             Defer trace until Alt+F12" }, 
     { NULL,           0, 0, 0, NULL, NULL }  /* terminator */
 };
 
@@ -125,6 +128,11 @@
     Options.display = xstrdup( arg );
 }
 
+static void do_deferred( const char *arg )
+{
+    wine_dbg_switch_trace(TRUE, FALSE);
+}
+    
 static void do_dll( const char *arg )
 {
     if (Options.dllFlags)
Index: scheduler/client.c
===================================================================
RCS file: /home/wine/wine/scheduler/client.c,v
retrieving revision 1.71
diff -u -r1.71 client.c
--- scheduler/client.c	2001/03/08 01:16:42	1.71
+++ scheduler/client.c	2001/03/10 16:32:21
@@ -35,6 +35,9 @@
 #include "server.h"
 #include "winerror.h"
 #include "options.h"
+#include "debugtools.h"
+
+DEFAULT_DEBUG_CHANNEL(ntdll);
 
 /* Some versions of glibc don't define this */
 #ifndef SCM_RIGHTS
Index: server/request.h
===================================================================
RCS file: /home/wine/wine/server/request.h,v
retrieving revision 1.43
diff -u -r1.43 request.h
--- server/request.h	2001/03/08 01:16:42	1.43
+++ server/request.h	2001/03/10 16:32:22
@@ -177,6 +177,7 @@
 DECL_HANDLER(set_serial_info);
 DECL_HANDLER(create_async);
 DECL_HANDLER(async_result);
+DECL_HANDLER(enable_trace);
 
 #ifdef WANT_REQUEST_HANDLERS
 
@@ -292,6 +293,7 @@
     (req_handler)req_set_serial_info,
     (req_handler)req_create_async,
     (req_handler)req_async_result,
+    (req_handler)req_enable_trace,
 };
 #endif  /* WANT_REQUEST_HANDLERS */
 
Index: server/thread.c
===================================================================
RCS file: /home/wine/wine/server/thread.c,v
retrieving revision 1.64
diff -u -r1.64 thread.c
--- server/thread.c	2001/03/08 01:16:42	1.64
+++ server/thread.c	2001/03/10 16:32:25
@@ -745,6 +745,12 @@
     }
 }
 
+/* enable trace */
+DECL_HANDLER(enable_trace)
+{
+    debug_level = req->debug_level;
+}
+
 /* create a new thread */
 DECL_HANDLER(new_thread)
 {
Index: server/trace.c
===================================================================
RCS file: /home/wine/wine/server/trace.c,v
retrieving revision 1.89
diff -u -r1.89 trace.c
--- server/trace.c	2001/03/08 01:16:42	1.89
+++ server/trace.c	2001/03/10 16:32:34
@@ -1495,6 +1495,11 @@
     fprintf( stderr, " result=%d", req->result );
 }
 
+static void dump_enable_trace_request( const struct enable_trace_request *req )
+{
+    fprintf( stderr, " debug_level=%d", req->debug_level );
+}
+
 static const dump_func req_dumpers[REQ_NB_REQUESTS] = {
     (dump_func)dump_new_process_request,
     (dump_func)dump_get_new_process_info_request,
@@ -1605,6 +1610,7 @@
     (dump_func)dump_set_serial_info_request,
     (dump_func)dump_create_async_request,
     (dump_func)dump_async_result_request,
+    (dump_func)dump_enable_trace_request,
 };
 
 static const dump_func reply_dumpers[REQ_NB_REQUESTS] = {
@@ -1717,6 +1723,7 @@
     (dump_func)0,
     (dump_func)dump_create_async_reply,
     (dump_func)0,
+    (dump_func)0,
 };
 
 static const char * const req_names[REQ_NB_REQUESTS] = {
@@ -1829,6 +1836,7 @@
     "set_serial_info",
     "create_async",
     "async_result",
+    "enable_trace",
 };
 
 /* ### make_requests end ### */
Index: windows/defwnd.c
===================================================================
RCS file: /home/wine/wine/windows/defwnd.c,v
retrieving revision 1.52
diff -u -r1.52 defwnd.c
--- windows/defwnd.c	2001/02/23 01:13:42	1.52
+++ windows/defwnd.c	2001/03/10 16:33:06
@@ -552,6 +552,11 @@
 	      pSendMessage( WIN_GetTopParent(wndPtr->hwndSelf),
                              WM_SYSCOMMAND, SC_KEYMENU, 0L );
 	iMenuSysKey = iF10Key = 0;
+        if ((wParam == VK_F12) && (GetKeyState(VK_MENU) & 0x8000))
+        { /* switch trace on and off on Alt F12 */
+              if (wine_dbg_switch_trace(FALSE,TRUE) > 0)
+                   WIN_WalkWindows((HWND)NULL, 0);
+        }         
         break;
 
     case WM_SYSCHAR:
Index: windows/win.c
===================================================================
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.119
diff -u -r1.119 win.c
--- windows/win.c	2001/02/12 03:40:42	1.119
+++ windows/win.c	2001/03/10 16:33:39
@@ -265,7 +265,7 @@
     {
         DPRINTF( "%*s%04x%*s", indent, "", ptr->hwndSelf, 13-indent,"");
 
-        GetClassNameA( hwnd, className, sizeof(className) );
+        GetClassNameA( ptr->hwndSelf, className, sizeof(className) );
         DPRINTF( "%08lx %-6.4x %-17.17s %08x %08x %.14s\n",
                  (DWORD)ptr, ptr->hmemTaskQ, className,
                  (UINT)ptr->dwStyle, (UINT)ptr->winproc,
-------------- next part --------------



More information about the wine-patches mailing list