Rearrange WINPROC_CallWndProc to give clearer tracing

Mike Hearn mh at codeweavers.com
Wed Feb 9 14:18:46 CST 2005


On Wed, 2005-02-09 at 20:44 +0100, Alexandre Julliard wrote:
> You don't want to do that, window procs can be nested quite deeply.

Yes, I realised the stack allocation might be a problem but only a while
after I sent the patch. Here's another that uses the heap.

ChangeLog:
Rearrange WINPROC_CallWndProc to give clearer tracing
-------------- next part --------------
--- windows/winproc.c  (revision 132)
+++ windows/winproc.c  (local)
@@ -408,20 +408,38 @@ static LRESULT WINPROC_CallWndProc( WNDP
 {
     LRESULT retvalue;
     int iWndsLocks;
+    char *msgname;
 
+    /* To avoid any deadlocks, all the locks on the windows structures
+       must be suspended before the control is passed to the application */
+    iWndsLocks = WIN_SuspendWndsLock();    
+    
     hwnd = WIN_GetFullHandle( hwnd );
+
     if (TRACE_ON(relay))
+    {
+        char *m = SPY_GetMsgName(msg, hwnd);
+        int len = strlen(m);
+
+        /* copy here as debug buffer may be overwritten */
+        msgname = HeapAlloc(GetProcessHeap(), 0, len);
+        memcpy(msgname, m, len + 1);
+        
         DPRINTF( "%04lx:Call window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx)\n",
-                 GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam );
-    /* To avoid any deadlocks, all the locks on the windows structures
-       must be suspended before the control is passed to the application */
-    iWndsLocks = WIN_SuspendWndsLock();
+                 GetCurrentThreadId(), proc, hwnd, msgname, wParam, lParam );
+    }
+    
     retvalue = WINPROC_wrapper( proc, hwnd, msg, wParam, lParam );
-    WIN_RestoreWndsLock(iWndsLocks);
-
+    
     if (TRACE_ON(relay))
+    {
         DPRINTF( "%04lx:Ret  window proc %p (hwnd=%p,msg=%s,wp=%08x,lp=%08lx) retval=%08lx\n",
-                 GetCurrentThreadId(), proc, hwnd, SPY_GetMsgName(msg, hwnd), wParam, lParam, retvalue );
+                 GetCurrentThreadId(), proc, hwnd, msgname, wParam, lParam, retvalue );
+        HeapFree(GetProcessHeap(), 0, msgname);
+    }
+
+    WIN_RestoreWndsLock(iWndsLocks);
+    
     return retvalue;
 }
 


More information about the wine-patches mailing list