From 32b37f6613b41147812db3d16a3e09e73e6d40ba Mon Sep 17 00:00:00 2001 From: Maarten Lankhorst Date: Fri, 18 Apr 2008 14:30:27 -0700 Subject: [PATCH] ntdll: Add reading WINE_DEBUG_SPINLOCK variable --- dlls/ntdll/critsection.c | 19 ++++++++++++++++++- dlls/ntdll/loader.c | 7 ++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c index 0fa47c4..e303f20 100644 --- a/dlls/ntdll/critsection.c +++ b/dlls/ntdll/critsection.c @@ -37,6 +37,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(ntdll); WINE_DECLARE_DEBUG_CHANNEL(relay); +char *critsect_debug_name = NULL; + static inline LONG interlocked_inc( PLONG dest ) { return interlocked_xchg_add( dest, 1 ) + 1; @@ -389,7 +391,12 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit ) for (;;) { EXCEPTION_RECORD rec; - NTSTATUS status = wait_semaphore( crit, 5 ); + NTSTATUS status; + + if (crit->DebugInfo && crit->DebugInfo->Spare[0] && critsect_debug_name && !strcmp(critsect_debug_name, (char *)crit->DebugInfo->Spare[0])) + status = wait_semaphore( crit, 1 ); + else + status = wait_semaphore( crit, 5 ); if ( status == STATUS_TIMEOUT ) { @@ -499,6 +506,8 @@ NTSTATUS WINAPI RtlEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) { if (crit->OwningThread == ULongToHandle(GetCurrentThreadId())) { + if (crit->DebugInfo && crit->DebugInfo->Spare[0] && critsect_debug_name && !strcmp(critsect_debug_name, (char *)crit->DebugInfo->Spare[0])) + FIXME("++\n"); crit->RecursionCount++; return STATUS_SUCCESS; } @@ -509,6 +518,8 @@ NTSTATUS WINAPI RtlEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) done: crit->OwningThread = ULongToHandle(GetCurrentThreadId()); crit->RecursionCount = 1; + if (crit->DebugInfo && crit->DebugInfo->Spare[0] && critsect_debug_name && !strcmp(critsect_debug_name, (char *)crit->DebugInfo->Spare[0])) + FIXME("++\n"); return STATUS_SUCCESS; } @@ -545,6 +556,9 @@ BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) crit->RecursionCount++; ret = TRUE; } + if (ret && crit->DebugInfo && crit->DebugInfo->Spare[0] && critsect_debug_name && !strcmp(critsect_debug_name, (char *)crit->DebugInfo->Spare[0])) + FIXME("++\n"); + return ret; } @@ -567,6 +581,9 @@ BOOL WINAPI RtlTryEnterCriticalSection( RTL_CRITICAL_SECTION *crit ) */ NTSTATUS WINAPI RtlLeaveCriticalSection( RTL_CRITICAL_SECTION *crit ) { + if (crit->DebugInfo && crit->DebugInfo->Spare[0] && critsect_debug_name && !strcmp(critsect_debug_name, (char *)crit->DebugInfo->Spare[0])) + FIXME("--\n"); + if (--crit->RecursionCount) interlocked_dec( &crit->LockCount ); else { diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index b0000b8..b56c705 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -57,6 +57,7 @@ WINE_DECLARE_DEBUG_CHANNEL(imports); #define ISOLATIONAWARE_MANIFEST_RESOURCE_ID ((ULONG_PTR)2) extern struct wine_pthread_functions pthread_functions; +extern char *critsect_debug_name; typedef DWORD (CALLBACK *DLLENTRYPROC)(HMODULE,DWORD,LPVOID); @@ -2546,7 +2547,11 @@ NTSTATUS WINAPI NtUnloadDriver( const UNICODE_STRING *DriverServiceName ) */ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved ) { - if (reason == DLL_PROCESS_ATTACH) LdrDisableThreadCalloutsForDll( inst ); + if (reason == DLL_PROCESS_ATTACH) + { + LdrDisableThreadCalloutsForDll( inst ); + critsect_debug_name = getenv("WINE_DEBUG_SPINLOCK"); + } return TRUE; } -- 1.5.4.1