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

This commit is contained in:
Timo Kreuzer
2024-05-23 21:21:35 +02:00
parent 53518bbab3
commit da64119fe6
2 changed files with 20 additions and 0 deletions
+3
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;
//
+17
View File
@@ -6,6 +6,19 @@
* PROGRAMMERS: Alex Ionescu ([email protected])
*/
#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
}
//