mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-27 14:22:13 +00:00
- print VM stack trace on startup abort exception
https://forum.zdoom.org/viewtopic.php?t=62650
This commit is contained in:
parent
f6aa16947a
commit
8b46be7686
3 changed files with 43 additions and 8 deletions
|
@ -32,9 +32,11 @@
|
|||
*/
|
||||
// Workaround for GCC Objective-C++ with C++ exceptions bug.
|
||||
|
||||
#include "doomerrors.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "doomerrors.h"
|
||||
#include "vm.h"
|
||||
|
||||
// Import some functions from i_main.mm
|
||||
void call_terms();
|
||||
void Mac_I_FatalError(const char* const message);
|
||||
|
@ -50,11 +52,22 @@ void OriginalMainExcept(int argc, char** argv)
|
|||
{
|
||||
const char* const message = error.what();
|
||||
|
||||
if (NULL != message)
|
||||
if (strcmp(message, "NoRunExit"))
|
||||
{
|
||||
if (CVMAbortException::stacktrace.IsNotEmpty())
|
||||
{
|
||||
Printf("%s", CVMAbortException::stacktrace.GetChars());
|
||||
}
|
||||
|
||||
if (batchrun)
|
||||
{
|
||||
Printf("%s\n", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strcmp(message, "NoRunExit")) fprintf(stderr, "%s\n", message);
|
||||
Mac_I_FatalError(message);
|
||||
}
|
||||
}
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#include "cmdlib.h"
|
||||
#include "r_utility.h"
|
||||
#include "doomstat.h"
|
||||
#include "vm.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
@ -261,16 +262,31 @@ int main (int argc, char **argv)
|
|||
catch (std::exception &error)
|
||||
{
|
||||
I_ShutdownJoysticks();
|
||||
if (error.what () && strcmp(error.what(), "NoRunExit"))
|
||||
fprintf (stderr, "%s\n", error.what ());
|
||||
|
||||
const char *const message = error.what();
|
||||
|
||||
if (strcmp(message, "NoRunExit"))
|
||||
{
|
||||
if (CVMAbortException::stacktrace.IsNotEmpty())
|
||||
{
|
||||
Printf("%s", CVMAbortException::stacktrace.GetChars());
|
||||
}
|
||||
|
||||
if (batchrun)
|
||||
{
|
||||
Printf("%s\n", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
Mac_I_FatalError(error.what());
|
||||
Mac_I_FatalError(message);
|
||||
#endif // __APPLE__
|
||||
|
||||
#ifdef __linux__
|
||||
Linux_I_FatalError(error.what());
|
||||
Linux_I_FatalError(message);
|
||||
#endif // __linux__
|
||||
}
|
||||
}
|
||||
|
||||
exit (-1);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
#include "r_utility.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "s_sound.h"
|
||||
#include "vm.h"
|
||||
|
||||
#include "stats.h"
|
||||
#include "st_start.h"
|
||||
|
@ -1057,6 +1058,11 @@ void DoMain (HINSTANCE hInstance)
|
|||
auto msg = error.what();
|
||||
if (strcmp(msg, "NoRunExit"))
|
||||
{
|
||||
if (CVMAbortException::stacktrace.IsNotEmpty())
|
||||
{
|
||||
Printf("%s", CVMAbortException::stacktrace.GetChars());
|
||||
}
|
||||
|
||||
if (!batchrun)
|
||||
{
|
||||
ShowErrorPane(msg);
|
||||
|
|
Loading…
Reference in a new issue