diff --git a/stepmania/src/RageThreads.cpp b/stepmania/src/RageThreads.cpp index 73f23a7b43..a225d847c5 100644 --- a/stepmania/src/RageThreads.cpp +++ b/stepmania/src/RageThreads.cpp @@ -593,7 +593,7 @@ void RageMutex::Lock() g_ThreadSlotsLock.Unlock(); /* Pass the crash handle of the other thread, so it can backtrace that thread. */ - ForceCrashHandlerDeadlock( sReason, CrashHandle ); + CrashHandler::ForceDeadlock( sReason, CrashHandle ); #else FAIL_M( sReason ); #endif @@ -747,7 +747,7 @@ retry: const CString sReason = ssprintf( "Semaphore timeout on mutex %s on thread %s", GetName().c_str(), ThisSlot? ThisSlot->GetThreadName(): "(???" ")" ); // stupid trigraph warnings #if defined(CRASH_HANDLER) - ForceCrashHandlerDeadlock( sReason, GetInvalidThreadId() ); + CrashHandler::ForceDeadlock( sReason, GetInvalidThreadId() ); #else RageException::Throw( "%s", sReason.c_str() ); #endif diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp index 47224a531f..13913a0e7d 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -14,7 +14,7 @@ static bool g_bIsMultipleInstance = false; ArchHooks_Win32::ArchHooks_Win32() { - SetUnhandledExceptionFilter(CrashHandler); + SetUnhandledExceptionFilter( CrashHandler::ExceptionHandler ); TimeCritMutex = new RageMutex("TimeCritMutex"); /* Disable critical errors, and handle them internally. We never want the diff --git a/stepmania/src/archutils/Win32/Crash.cpp b/stepmania/src/archutils/Win32/Crash.cpp index 057cb375fb..79be995ca9 100644 --- a/stepmania/src/archutils/Win32/Crash.cpp +++ b/stepmania/src/archutils/Win32/Crash.cpp @@ -164,7 +164,7 @@ bool VDDebugInfoInitFromFile( VDDebugInfoContext *pctx ); void VDDebugInfoDeinit( VDDebugInfoContext *pctx ); -long __stdcall CrashHandler( EXCEPTION_POINTERS *pExc ) +long __stdcall CrashHandler::ExceptionHandler( EXCEPTION_POINTERS *pExc ) { /* Flush the log it isn't cut off at the end. */ /* 1. We can't do regular file access in the crash handler. @@ -659,7 +659,7 @@ static bool PointsToValidCall( unsigned long ptr ) return IsValidCall(buf+7, len); } -void do_backtrace( const void **buf, size_t size, +void CrashHandler::do_backtrace( const void **buf, size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext ) { // Retrieve stack pointers. @@ -949,20 +949,20 @@ BOOL APIENTRY CrashDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) return FALSE; } -void NORETURN debug_crash() +void NORETURN CrashHandler::debug_crash() { __try { __asm xor ebx,ebx __asm mov eax,dword ptr [ebx] // __asm mov dword ptr [ebx],eax // __asm lock add dword ptr cs:[00000000h], 12345678h - } __except(CrashHandler((EXCEPTION_POINTERS*)_exception_info())) { + } __except(ExceptionHandler((EXCEPTION_POINTERS*)_exception_info())) { } } /* Get a stack trace of the current thread and the specified thread. If * iID == GetInvalidThreadId(), then output a stack trace for every thread. */ -void ForceCrashHandlerDeadlock( CString reason, uint64_t iID ) +void CrashHandler::ForceDeadlock( CString reason, uint64_t iID ) { strncpy( g_CrashInfo.m_CrashReason, reason, sizeof(g_CrashInfo.m_CrashReason) ); g_CrashInfo.m_CrashReason[ sizeof(g_CrashInfo.m_CrashReason)-1 ] = 0; @@ -1024,7 +1024,7 @@ void ForceCrashHandlerDeadlock( CString reason, uint64_t iID ) debug_crash(); } -void ForceCrashHandler( const char *reason ) +void CrashHandler::ForceCrash( const char *reason ) { strncpy( g_CrashInfo.m_CrashReason, reason, sizeof(g_CrashInfo.m_CrashReason) ); g_CrashInfo.m_CrashReason[ sizeof(g_CrashInfo.m_CrashReason)-1 ] = 0; diff --git a/stepmania/src/archutils/Win32/Crash.h b/stepmania/src/archutils/Win32/Crash.h index 2149b9f4e2..f3f271eb5a 100644 --- a/stepmania/src/archutils/Win32/Crash.h +++ b/stepmania/src/archutils/Win32/Crash.h @@ -3,16 +3,18 @@ #ifndef CRASH_H #define CRASH_H #include -extern long __stdcall CrashHandler(struct _EXCEPTION_POINTERS *ExceptionInfo); +namespace CrashHandler +{ + extern long __stdcall ExceptionHandler(struct _EXCEPTION_POINTERS *ExceptionInfo); -/* Exactly as advertised. (This will bring up the crash handler even - * in the debugger.) */ -void NORETURN debug_crash(); + /* Trigger the crash handler. This works even in the debugger. */ + void NORETURN debug_crash(); -void do_backtrace( const void **buf, size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext ); -void SymLookup( const void *ptr, char *buf ); -void ForceCrashHandler( const char *reason ); -void ForceCrashHandlerDeadlock( CString reason, uint64_t iID ); + void do_backtrace( const void **buf, size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext ); + void SymLookup( const void *ptr, char *buf ); + void ForceCrash( const char *reason ); + void ForceDeadlock( CString reason, uint64_t iID ); +}; #endif /*