From 0f8d5281a77cdac879592d3b65546d7fea20f802 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 25 Feb 2004 21:15:25 +0000 Subject: [PATCH] on mutex deadlock, get a backtrace of the thread that we're deadlocked with --- stepmania/src/RageThreads.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/stepmania/src/RageThreads.cpp b/stepmania/src/RageThreads.cpp index 1c0ca936af..7e344df7aa 100644 --- a/stepmania/src/RageThreads.cpp +++ b/stepmania/src/RageThreads.cpp @@ -28,6 +28,10 @@ #define PID_BASED_THREADS #endif +#if defined(WIN32) +#include "archutils/Win32/crash.h" +#endif + #define MAX_THREADS 128 static const unsigned int UnknownThreadID = 0xFFFFFFFF; @@ -480,9 +484,12 @@ RageMutexImpl::~RageMutexImpl() } -void CrashDeadlocked() +static ThreadSlot *FindThread( DWORD id ) { - sm_crash(); + for( int i = 0; i < MAX_THREADS; ++i ) + if( g_ThreadSlots[i].threadid == id ) + return &g_ThreadSlots[i]; + return NULL; } void RageMutexImpl::Lock() @@ -521,11 +528,8 @@ void RageMutexImpl::Lock() } } - /* XXX: We want a stack trace of *all* threads if this happened, so we can - * tell who we're deadlocked with. We can't use CHECKPOINT, since that uses - * locks. Crash in a function, so we can see it on the stack (so we know - * we didn't crash somewhere else above.) */ - CrashDeadlocked(); + ThreadSlot *slot = FindThread( LockedBy ); + Crash_BacktraceThread( slot? slot->ThreadHandle:NULL ); } void RageMutexImpl::Unlock()