Use attributes where possible
This commit is contained in:
@@ -69,7 +69,8 @@ static void GetExecutableName( char *buf, int bufsize )
|
||||
}
|
||||
#endif
|
||||
|
||||
static void SM_NORETURN spawn_child_process( int from_parent )
|
||||
[[noreturn]]
|
||||
static void spawn_child_process( int from_parent )
|
||||
{
|
||||
/* We need to re-exec ourself, to get a clean process. Close all
|
||||
* FDs except for 0-2 and to_child, and then assign to_child to 3. */
|
||||
@@ -107,7 +108,7 @@ static int retried_write( int fd, const void *buf, size_t count )
|
||||
ret = write( fd, buf, count );
|
||||
}
|
||||
while( ret == -1 && errno == EINTR && tries-- );
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -134,7 +135,7 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
/* 1. Write the CrashData. */
|
||||
if( !parent_write(to_child, crash, sizeof(CrashData)) )
|
||||
return;
|
||||
|
||||
|
||||
/* 2. Write info. */
|
||||
const char *p = RageLog::GetInfo();
|
||||
int size = strlen( p )+1;
|
||||
@@ -150,7 +151,7 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
return;
|
||||
if( !parent_write(to_child, p, size) )
|
||||
return;
|
||||
|
||||
|
||||
/* 4. Write RecentLogs. */
|
||||
int cnt = 0;
|
||||
const char *ps[1024];
|
||||
@@ -175,7 +176,7 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
return;
|
||||
if( !parent_write(to_child, buf, size) )
|
||||
return;
|
||||
|
||||
|
||||
/* 6. Write the crashed thread's name. */
|
||||
p = RageThread::GetCurrentThreadName();
|
||||
size = strlen( p )+1;
|
||||
@@ -188,7 +189,7 @@ static void parent_process( int to_child, const CrashData *crash )
|
||||
|
||||
/* The parent process is the crashed process. It'll send data to the
|
||||
* child, who will do stuff with it. The parent then waits for the
|
||||
* child to quit, and exits.
|
||||
* child to quit, and exits.
|
||||
*
|
||||
* We can do whatever fancy things we want in the child process. However,
|
||||
* let's not open any windows until we at least try to shut down OpenGL,
|
||||
@@ -216,7 +217,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", nullptr );
|
||||
_exit( 1 );
|
||||
}
|
||||
|
||||
|
||||
/* Block SIGPIPE, so we get EPIPE. */
|
||||
struct sigaction sa;
|
||||
memset( &sa, 0, sizeof(sa) );
|
||||
@@ -261,7 +262,7 @@ static void RunCrashHandler( const CrashData *crash )
|
||||
/* Stop other threads. XXX: This prints a spurious ptrace error if any threads
|
||||
* are already suspended, which happens in ForceCrashHandlerDeadlock(). */
|
||||
RageThread::HaltAllThreads();
|
||||
|
||||
|
||||
/* We need to be very careful, since we're under crash conditions. Let's fork
|
||||
* a process and exec ourself to get a clean environment to work in. */
|
||||
int fds[2];
|
||||
@@ -313,19 +314,19 @@ 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;
|
||||
}
|
||||
@@ -426,7 +427,7 @@ void CrashHandler::InitializeCrashHandler()
|
||||
/*
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -436,7 +437,7 @@ void CrashHandler::InitializeCrashHandler()
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -467,7 +467,7 @@ static bool PointsToValidCall( ULONG_PTR ptr )
|
||||
return IsValidCall(buf+7, len);
|
||||
}
|
||||
|
||||
void CrashHandler::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 )
|
||||
{
|
||||
const void **pLast = buf + size - 1;
|
||||
@@ -535,7 +535,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
MEMORY_BASIC_INFORMATION meminfo;
|
||||
|
||||
VirtualQuery((void *)data, &meminfo, sizeof meminfo);
|
||||
|
||||
|
||||
if (!IsExecutableProtection(meminfo.Protect) || meminfo.State!=MEM_COMMIT)
|
||||
fValid = false;
|
||||
|
||||
@@ -563,7 +563,8 @@ void CrashHandler::do_backtrace( const void **buf, size_t size,
|
||||
}
|
||||
|
||||
// Trigger the crash handler. This works even in the debugger.
|
||||
static void SM_NORETURN debug_crash()
|
||||
[[noreturn]]
|
||||
static void debug_crash()
|
||||
{
|
||||
// __try {
|
||||
#if defined(__MSC_VER)
|
||||
@@ -652,7 +653,7 @@ void CrashHandler::ForceCrash( const char *reason )
|
||||
* (c) 1998-2001 Avery Lee
|
||||
* (c) 2003-2004 Glenn Maynard
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -662,7 +663,7 @@ void CrashHandler::ForceCrash( const char *reason )
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef RESTART_PROGRAM_H
|
||||
#define RESTART_PROGRAM_H
|
||||
|
||||
[[noreturn]]
|
||||
void Win32RestartProgram();
|
||||
|
||||
#endif
|
||||
@@ -8,7 +9,7 @@ void Win32RestartProgram();
|
||||
/*
|
||||
* (c) 2002-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -18,7 +19,7 @@ void Win32RestartProgram();
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
Reference in New Issue
Block a user