2003-02-16 03:56:52 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
|
2004-03-19 07:32:06 +00:00
|
|
|
#if defined(_WINDOWS)
|
2004-06-20 01:35:25 +00:00
|
|
|
# define _WIN32_WINDOWS 0x0410 // include Win98 stuff
|
|
|
|
|
# include "windows.h"
|
|
|
|
|
# include "archutils/Win32/Crash.h"
|
|
|
|
|
#elif defined(_XBOX)
|
2004-06-16 07:10:09 +00:00
|
|
|
#else
|
2004-06-20 01:35:25 +00:00
|
|
|
# include <unistd.h>
|
2004-05-06 09:13:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
2005-10-24 10:37:56 +00:00
|
|
|
#if defined(CRASH_HANDLER) && (defined(LINUX) || defined(MACOSX))
|
2004-05-06 09:13:37 +00:00
|
|
|
#include "archutils/Unix/CrashHandler.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-03-26 02:55:13 +00:00
|
|
|
void NORETURN sm_crash( const char *reason )
|
2004-02-25 01:35:19 +00:00
|
|
|
{
|
2004-05-06 09:13:37 +00:00
|
|
|
#if defined(_WINDOWS)
|
2004-04-12 01:47:17 +00:00
|
|
|
/* If we're being debugged, throw a debug break so it'll suspend the process. */
|
|
|
|
|
if( IsDebuggerPresent() )
|
2004-05-06 09:13:37 +00:00
|
|
|
{
|
2004-04-12 01:47:17 +00:00
|
|
|
DebugBreak();
|
2004-05-06 09:18:15 +00:00
|
|
|
while(1); /* don't return */
|
2004-05-06 09:13:37 +00:00
|
|
|
}
|
|
|
|
|
#endif
|
2004-02-25 01:35:19 +00:00
|
|
|
|
2004-05-06 09:13:37 +00:00
|
|
|
#if defined(CRASH_HANDLER)
|
2004-03-26 02:55:13 +00:00
|
|
|
ForceCrashHandler( reason );
|
2004-02-25 01:35:19 +00:00
|
|
|
#else
|
|
|
|
|
*(char*)0=0;
|
|
|
|
|
|
|
|
|
|
/* This isn't actually reached. We just do this to convince the compiler that the
|
|
|
|
|
* function really doesn't return. */
|
|
|
|
|
while(1);
|
2004-05-06 09:13:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(_WINDOWS)
|
|
|
|
|
/* Do something after the above, so the call/return isn't optimized to a jmp; that
|
|
|
|
|
* way, this function will appear in backtrace stack traces. */
|
2005-06-26 01:33:33 +00:00
|
|
|
#if defined(_MSC_VER)
|
2004-05-06 09:13:37 +00:00
|
|
|
_asm nop;
|
2005-06-26 01:33:33 +00:00
|
|
|
#elif defined(__GNUC__) // MinGW or similar
|
|
|
|
|
asm("nop");
|
|
|
|
|
#endif
|
2004-05-07 00:40:02 +00:00
|
|
|
#else
|
|
|
|
|
_exit( 1 );
|
2004-05-06 09:13:37 +00:00
|
|
|
#endif
|
2004-02-25 01:35:19 +00:00
|
|
|
}
|
2004-05-06 09:13:37 +00:00
|
|
|
|
2004-06-08 05:35:39 +00:00
|
|
|
/*
|
|
|
|
|
* (c) 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
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
|
|
|
|
* whom the Software is furnished to do so, provided that the above
|
|
|
|
|
* 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
|
|
|
|
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
|
|
|
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
|
|
|
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
|
|
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
|
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
|
|
|
* PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
|
*/
|