wnd lock tracing

Andreas Mohr a.mohr at mailto.de
Sun Jul 29 15:56:26 CDT 2001


Hi all,

I finally submit this patch now.
I used to recreate the same debug statements over and over again,
but I'm tired of doing so ;-)

Add a #define DBG_WNDLOCK in order to have reasonable wndlock debugging

Oh yeah, and it's really needed, since e.g. a forgotten WIN_ReleaseWndPtr
is an ongoing phenomenon...

-- 
Andreas Mohr                        Stauferstr. 6, D-71272 Renningen, Germany
-------------- next part --------------
Determining best CVS host...
Using CVSROOT :pserver:cvs at rhlx01.fht-esslingen.de:/home/wine
Index: windows/win.c
===================================================================
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.138
diff -u -r1.138 win.c
--- windows/win.c	26 Jul 2001 20:12:23 -0000	1.138
+++ windows/win.c	29 Jul 2001 18:51:58 -0000
@@ -27,6 +27,9 @@
 DEFAULT_DEBUG_CHANNEL(win);
 DECLARE_DEBUG_CHANNEL(msg);
 
+/* define in order to debug some wnd lock weirdness */
+#undef DBG_WNDLOCK
+
 /**********************************************************************/
 
 /* Desktop window */
@@ -47,6 +50,9 @@
  */
 void WIN_LockWnds( void )
 {
+#ifdef DBG_WNDLOCK
+    TRACE("entering lock\n");
+#endif
     _EnterSysLevel( &WIN_SysLevel );
 }
 
@@ -57,6 +63,9 @@
  */
 void WIN_UnlockWnds( void )
 {
+#ifdef DBG_WNDLOCK
+    TRACE("leaving lock\n");
+#endif
     _LeaveSysLevel( &WIN_SysLevel );
 }
 
@@ -73,6 +82,9 @@
 
     while ( count-- > 0 )
         _LeaveSysLevel( &WIN_SysLevel );
+#ifdef DBG_WNDLOCK
+    TRACE("(%d locks)\n", isuspendedLocks);
+#endif
 
     return isuspendedLocks;
 }
@@ -84,6 +96,9 @@
  */
 void WIN_RestoreWndsLock( int ipreviousLocks )
 {
+#ifdef DBG_WNDLOCK
+    TRACE("(%d locks)\n", ipreviousLocks);
+#endif
     while ( ipreviousLocks-- > 0 )
         _EnterSysLevel( &WIN_SysLevel );
 }
@@ -99,10 +114,13 @@
     
     if (!hwnd || HIWORD(hwnd)) goto error2;
     ptr = (WND *) USER_HEAP_LIN_ADDR( hwnd );
-    /* Lock all WND structures for thread safeness*/
+    /* Lock all WND structures for thread safeness */
     WIN_LockWnds();
-    /*and increment destruction monitoring*/
+    /* and increment destruction monitoring */
      ptr->irefCount++;
+#ifdef DBG_WNDLOCK
+    TRACE("%04x -> %p, cnt now %d\n", hwnd, ptr, ptr->irefCount);
+#endif
 
     if (ptr->dwMagic != WND_MAGIC) goto error;
     if (ptr->hwndSelf != hwnd)
@@ -113,7 +131,7 @@
     /* returns a locked pointer */
     return ptr;
  error:
-    /* Unlock all WND structures for thread safeness*/
+    /* Unlock all WND structures for thread safeness */
     WIN_UnlockWnds();
     /* and decrement destruction monitoring value */
      ptr->irefCount--;
@@ -135,10 +153,13 @@
 {
     if(!initWndPtr) return 0;
 
-    /* Lock all WND structures for thread safeness*/
+    /* Lock all WND structures for thread safeness */
     WIN_LockWnds();
-    /*and increment destruction monitoring*/
+    /* and increment destruction monitoring */
     initWndPtr->irefCount++;
+#ifdef DBG_WNDLOCK
+    TRACE("%p, cnt now %d\n", initWndPtr, initWndPtr->irefCount);
+#endif
     
     return initWndPtr;
 
@@ -152,10 +173,13 @@
 void WIN_ReleaseWndPtr(WND *wndPtr)
 {
     if(!wndPtr) return;
+#ifdef DBG_WNDLOCK
+    TRACE("%p, cnt was %d\n", wndPtr, wndPtr->irefCount);
+#endif
 
-    /*Decrement destruction monitoring value*/
+    /* Decrement destruction monitoring value */
      wndPtr->irefCount--;
-     /* Check if it's time to release the memory*/
+     /* Check if it's time to release the memory */
      if(wndPtr->irefCount == 0 && !wndPtr->dwMagic)
      {
          /* Release memory */
@@ -165,9 +189,10 @@
      else if(wndPtr->irefCount < 0)
      {
          /* This else if is useful to monitor the WIN_ReleaseWndPtr function */
-         ERR("forgot a Lock on %p somewhere\n",wndPtr);
+         ERR("forgot a Lock on %p somewhere (irefCount %d)\n",wndPtr,wndPtr->irefCount);
+	 DebugBreak();
      }
-     /*unlock all WND structures for thread safeness*/
+     /* unlock all WND structures for thread safeness */
      WIN_UnlockWnds();
 }
 
@@ -180,6 +205,9 @@
 {
     WND *tmpWnd = NULL;
     
+#ifdef DBG_WNDLOCK
+    TRACE("from %p to %p\n", *oldPtr, newPtr);
+#endif
     tmpWnd = WIN_LockWndPtr(newPtr);
     WIN_ReleaseWndPtr(*oldPtr);
     *oldPtr = tmpWnd;
@@ -2405,7 +2433,7 @@
     while (wndPtr && wndPtr->parent)
     {
         if (!(wndPtr->dwStyle & WS_VISIBLE))
-    {
+        {
             WIN_ReleaseWndPtr(wndPtr);
             return FALSE;
         }


More information about the wine-patches mailing list