[NTOS:CM] Add debug code for analyzing lock issues

This commit is contained in:
Timo Kreuzer 2024-04-30 13:40:47 +03:00
parent 53518bbab3
commit da64119fe6
2 changed files with 20 additions and 0 deletions

View file

@ -160,6 +160,9 @@ typedef struct _CM_KEY_HASH_TABLE_ENTRY
EX_PUSH_LOCK Lock;
PKTHREAD Owner;
PCM_KEY_HASH Entry;
#if DBG
PVOID LockBackTrace[5];
#endif
} CM_KEY_HASH_TABLE_ENTRY, *PCM_KEY_HASH_TABLE_ENTRY;
//

View file

@ -6,6 +6,19 @@
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
*/
#if DBG
FORCEINLINE
VOID
CmpCaptureLockBackTraceByIndex(_In_ ULONG Index)
{
/* Capture the backtrace */
RtlCaptureStackBackTrace(1,
_countof(CmpCacheTable[Index].LockBackTrace),
CmpCacheTable[Index].LockBackTrace,
NULL);
}
#endif
//
// Returns the hashkey corresponding to a convkey
//
@ -104,8 +117,12 @@ FORCEINLINE
VOID
CmpAcquireKcbLockExclusiveByIndex(ULONG Index)
{
ASSERT(CmpCacheTable[Index].Owner != KeGetCurrentThread());
ExAcquirePushLockExclusive(&CmpCacheTable[Index].Lock);
CmpCacheTable[Index].Owner = KeGetCurrentThread();
#if DBG
CmpCaptureLockBackTraceByIndex(Index);
#endif
}
//