Add A function to dump all locked handles and call it when an assertion about 0 locks fails.

svn path=/trunk/; revision=50969
This commit is contained in:
Timo Kreuzer 2011-03-05 10:21:07 +00:00
parent 85f0fb63f3
commit a528924f3b
2 changed files with 29 additions and 2 deletions

View file

@ -20,6 +20,7 @@ enum _DEBUGCHANNELS
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);
@ -96,17 +97,19 @@ DbgPostServiceHook(ULONG ulSyscallId, ULONG_PTR ulResult);
#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);
GdiDbgDumpLockedHandles();
ASSERT(FALSE);
}
}
#define ASSERT_NOGDILOCKS() DbgAssertNoGdiLocks(__FILE__,__LINE__)
#define ASSERT_NOGDILOCKS() GdiDbgAssertNoLocks(__FILE__,__LINE__)
#else
#define ASSERT_NOGDILOCKS()
#endif

View file

@ -292,6 +292,30 @@ GDIOBJ_IncrementShareCount(POBJ Object)
#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)