[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 5 Mar 2011 10:21:07 +0000 (10:21 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sat, 5 Mar 2011 10:21:07 +0000 (10:21 +0000)
Add A function to dump all locked handles and call it when an assertion about 0 locks fails.

svn path=/trunk/; revision=50969

reactos/subsystems/win32/win32k/include/gdidebug.h
reactos/subsystems/win32/win32k/objects/gdidbg.c

index dc7179a..944e546 100644 (file)
@@ -20,6 +20,7 @@ enum _DEBUGCHANNELS
 void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable);
 ULONG CaptureStackBackTace(PVOID* pFrames, ULONG nFramesToCapture);
 BOOL GdiDbgHTIntegrityCheck();
 void IntDumpHandleTable(PGDI_HANDLE_TABLE HandleTable);
 ULONG CaptureStackBackTace(PVOID* pFrames, ULONG nFramesToCapture);
 BOOL GdiDbgHTIntegrityCheck();
+void GdiDbgDumpLockedHandles();
 
 #define DBGENABLE(ch) gulDebugChannels |= (ch);
 #define DBGDISABLE(ch) gulDebugChannels &= ~(ch);
 
 #define DBGENABLE(ch) gulDebugChannels |= (ch);
 #define DBGDISABLE(ch) gulDebugChannels &= ~(ch);
@@ -96,17 +97,19 @@ DbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
 #define ID_Win32PostServiceHook 'WSH1'
 
 FORCEINLINE void
 #define ID_Win32PostServiceHook 'WSH1'
 
 FORCEINLINE void
-DbgAssertNoGdiLocks(char * pszFile, ULONG nLine)
+GdiDbgAssertNoLocks(char * pszFile, ULONG nLine)
 {
     PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
     if (pti && pti->cExclusiveLocks != 0)
     {
         DbgPrint("(%s:%ld) There are %ld exclusive locks!\n",
                  pszFile, nLine, pti->cExclusiveLocks);
 {
     PTHREADINFO pti = (PTHREADINFO)PsGetCurrentThreadWin32Thread();
     if (pti && pti->cExclusiveLocks != 0)
     {
         DbgPrint("(%s:%ld) There are %ld exclusive locks!\n",
                  pszFile, nLine, pti->cExclusiveLocks);
+        GdiDbgDumpLockedHandles();
         ASSERT(FALSE);
     }
 }
         ASSERT(FALSE);
     }
 }
-#define ASSERT_NOGDILOCKS() DbgAssertNoGdiLocks(__FILE__,__LINE__)
+
+#define ASSERT_NOGDILOCKS() GdiDbgAssertNoLocks(__FILE__,__LINE__)
 #else
 #define ASSERT_NOGDILOCKS()
 #endif
 #else
 #define ASSERT_NOGDILOCKS()
 #endif
index ab1a8d9..4be2d4d 100644 (file)
@@ -292,6 +292,30 @@ GDIOBJ_IncrementShareCount(POBJ Object)
 
 #endif /* GDI_DEBUG */
 
 
 #endif /* GDI_DEBUG */
 
+void
+GdiDbgDumpLockedHandles()
+{
+    ULONG i;
+
+    for (i = RESERVE_ENTRIES_COUNT; i < GDI_HANDLE_COUNT; i++)
+    {
+        PGDI_TABLE_ENTRY pEntry = &GdiHandleTable->Entries[i];
+
+        if (pEntry->Type & GDI_ENTRY_BASETYPE_MASK)
+        {
+            BASEOBJECT *pObject = pEntry->KernelData;
+            if (pObject->cExclusiveLock > 0)
+            {
+                DPRINT1("Locked object: %lx, type = %lx. allocated from:\n",
+                        i, pEntry->Type);
+                GDIDBG_TRACEALLOCATOR(i);
+                DPRINT1("Locked from:\n");
+                GDIDBG_TRACELOCKER(i);
+            }
+        }
+    }
+}
+
 void
 NTAPI
 DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)
 void
 NTAPI
 DbgPreServiceHook(ULONG ulSyscallId, PULONG_PTR pulArguments)