sm_crash: take a reason

when failing an assertion, pass the reason to sm_crash, in case we don't make it to logging checkpoints
This commit is contained in:
Glenn Maynard
2004-03-26 02:55:13 +00:00
parent 2404a98c44
commit 5fc16eebea
2 changed files with 6 additions and 6 deletions
+4 -4
View File
@@ -2,7 +2,7 @@
#if defined(_WINDOWS) #if defined(_WINDOWS)
#include "windows.h" #include "windows.h"
void NORETURN sm_crash() void NORETURN sm_crash( const char *reason )
{ {
// throws an exception that gets caught by the exception handler // throws an exception that gets caught by the exception handler
DebugBreak(); DebugBreak();
@@ -14,13 +14,13 @@ void NORETURN sm_crash()
#elif defined(LINUX) || defined(DARWIN) #elif defined(LINUX) || defined(DARWIN)
#include "archutils/Unix/CrashHandler.h" #include "archutils/Unix/CrashHandler.h"
#include <unistd.h> #include <unistd.h>
void NORETURN sm_crash() void NORETURN sm_crash( const char *reason )
{ {
ForceCrashHandler( "Internal error" ); ForceCrashHandler( reason );
_exit( 1 ); _exit( 1 );
} }
#else #else
void NORETURN sm_crash() void NORETURN sm_crash( const char *reason )
{ {
*(char*)0=0; *(char*)0=0;
+2 -2
View File
@@ -88,13 +88,13 @@ namespace Checkpoints
#define NORETURN #define NORETURN
#endif #endif
void NORETURN sm_crash(); void NORETURN sm_crash( const char *reason = "Internal error" );
/* Assertion that sets an optional message and brings up the crash handler, so /* Assertion that sets an optional message and brings up the crash handler, so
* we get a backtrace. This should probably be used instead of throwing an * we get a backtrace. This should probably be used instead of throwing an
* exception in most cases we expect never to happen (but not in cases that * exception in most cases we expect never to happen (but not in cases that
* we do expect, such as DSound init failure.) */ * we do expect, such as DSound init failure.) */
#define FAIL_M(MESSAGE) { CHECKPOINT_M(MESSAGE); sm_crash(); } #define FAIL_M(MESSAGE) { CHECKPOINT_M(MESSAGE); sm_crash(MESSAGE); }
#define ASSERT_M(COND, MESSAGE) { if(!(COND)) { FAIL_M(MESSAGE); } } #define ASSERT_M(COND, MESSAGE) { if(!(COND)) { FAIL_M(MESSAGE); } }
#define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed") #define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed")