Split out BacktraceAllThreads() and do so when signaled with SIGUSR1.
This commit is contained in:
@@ -238,8 +238,11 @@ const char *SignalName( int signo )
|
|||||||
X(SIGQUIT)
|
X(SIGQUIT)
|
||||||
case SIGSEGV: return "Segmentation fault";
|
case SIGSEGV: return "Segmentation fault";
|
||||||
X(SIGTRAP) X(SIGTERM) X(SIGVTALRM) X(SIGXCPU) X(SIGXFSZ)
|
X(SIGTRAP) X(SIGTERM) X(SIGVTALRM) X(SIGXCPU) X(SIGXFSZ)
|
||||||
#if defined(HAVE_DECL_SIGPWR) && HAVE_DECL_SIGPWR
|
#if defined(HAVE_DECL_SIGPWR)
|
||||||
X(SIGPWR)
|
X(SIGPWR)
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_DECL_SIGUSR1)
|
||||||
|
case SIGUSR1: return "Forced crash";
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
@@ -352,6 +355,28 @@ static void RunCrashHandler( const CrashData *crash )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void BacktraceAllThreads( CrashData& crash )
|
||||||
|
{
|
||||||
|
int iCnt = 1;
|
||||||
|
uint64_t iID;
|
||||||
|
|
||||||
|
for( int i = 0; RageThread::EnumThreadIDs(i, iID); ++i )
|
||||||
|
{
|
||||||
|
if( iID == GetInvalidThreadId() || iID == RageThread::GetCurrentThreadID() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
BacktraceContext ctx;
|
||||||
|
if( GetThreadBacktraceContext( iID, &ctx ) )
|
||||||
|
GetBacktrace( crash.BacktracePointers[iCnt], BACKTRACE_MAX_SIZE, &ctx );
|
||||||
|
strncpy( crash.m_ThreadName[iCnt], RageThread::GetThreadNameByID(iID), sizeof(crash.m_ThreadName[0])-1 );
|
||||||
|
|
||||||
|
++iCnt;
|
||||||
|
|
||||||
|
if( iCnt == CrashData::MAX_BACKTRACE_THREADS )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CrashHandler::ForceCrash( const char *reason )
|
void CrashHandler::ForceCrash( const char *reason )
|
||||||
{
|
{
|
||||||
CrashData crash;
|
CrashData crash;
|
||||||
@@ -378,22 +403,7 @@ void CrashHandler::ForceDeadlock( CString reason, uint64_t iID )
|
|||||||
if( iID == GetInvalidThreadId() )
|
if( iID == GetInvalidThreadId() )
|
||||||
{
|
{
|
||||||
/* Backtrace all threads. */
|
/* Backtrace all threads. */
|
||||||
int iCnt = 1;
|
BacktraceAllThreads( crash );
|
||||||
for( int i = 0; RageThread::EnumThreadIDs(i, iID); ++i )
|
|
||||||
{
|
|
||||||
if( iID == GetInvalidThreadId() || iID == RageThread::GetCurrentThreadID() )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
BacktraceContext ctx;
|
|
||||||
if( GetThreadBacktraceContext( iID, &ctx ) )
|
|
||||||
GetBacktrace( crash.BacktracePointers[iCnt], BACKTRACE_MAX_SIZE, &ctx );
|
|
||||||
strncpy( crash.m_ThreadName[iCnt], RageThread::GetThreadNameByID(iID), sizeof(crash.m_ThreadName[0])-1 );
|
|
||||||
|
|
||||||
++iCnt;
|
|
||||||
|
|
||||||
if( iCnt == CrashData::MAX_BACKTRACE_THREADS )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -429,6 +439,10 @@ void CrashHandler::CrashSignalHandler( int signal, siginfo_t *si, const ucontext
|
|||||||
BacktraceContext ctx;
|
BacktraceContext ctx;
|
||||||
GetSignalBacktraceContext( &ctx, uc );
|
GetSignalBacktraceContext( &ctx, uc );
|
||||||
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, &ctx );
|
GetBacktrace( crash.BacktracePointers[0], BACKTRACE_MAX_SIZE, &ctx );
|
||||||
|
#if defined(HAVE_DECL_SIGUSR1)
|
||||||
|
if( signal == SIGUSR1 )
|
||||||
|
BacktraceAllThreads( crash );
|
||||||
|
#endif
|
||||||
|
|
||||||
strncpy( crash.m_ThreadName[0], RageThread::GetCurThreadName(), sizeof(crash.m_ThreadName[0])-1 );
|
strncpy( crash.m_ThreadName[0], RageThread::GetCurThreadName(), sizeof(crash.m_ThreadName[0])-1 );
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,11 @@ static int signals[] =
|
|||||||
{
|
{
|
||||||
SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGABRT,
|
SIGALRM, SIGBUS, SIGFPE, SIGHUP, SIGILL, SIGINT, SIGABRT,
|
||||||
SIGQUIT, SIGSEGV, SIGTRAP, SIGTERM, SIGVTALRM, SIGXCPU, SIGXFSZ,
|
SIGQUIT, SIGSEGV, SIGTRAP, SIGTERM, SIGVTALRM, SIGXCPU, SIGXFSZ,
|
||||||
#if defined(HAVE_DECL_SIGPWR) && HAVE_DECL_SIGPWR
|
#if defined(HAVE_DECL_SIGPWR)
|
||||||
SIGPWR,
|
SIGPWR,
|
||||||
|
#endif
|
||||||
|
#if defined(HAVE_DECL_SIGUSR1)
|
||||||
|
SIGUSR1,
|
||||||
#endif
|
#endif
|
||||||
-1
|
-1
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user