Merge branch 'better-crashes' into 'next'

Better signal handler messages

See merge request STJr/SRB2!2042
This commit is contained in:
sphere 2023-07-14 22:48:26 +00:00
commit 7aac6a01e4

View file

@ -325,56 +325,90 @@ static void write_backtrace(INT32 signal)
static void I_ReportSignal(int num, int coredumped)
{
//static char msg[] = "oh no! back to reality!\r\n";
const char * sigmsg;
char msg[128];
const char *sigmsg, *sigttl;
char ttl[128];
switch (num)
{
// case SIGINT:
// sigmsg = "SIGINT - interrupted";
// sigttl = "SIGINT"
// sigmsg = "SRB2 was interrupted prematurely by the user.";
// break;
case SIGILL:
sigmsg = "SIGILL - illegal instruction - invalid function image";
sigmsg = "SRB2 has attempted to execute an illegal instruction and needs to close. %s";
sigttl = "SIGILL"; // illegal instruction - invalid function image
break;
case SIGFPE:
sigmsg = "SIGFPE - mathematical exception";
sigmsg = "SRB2 has encountered a mathematical exception and needs to close. %s";
sigttl = "SIGFPE"; // mathematical exception
break;
case SIGSEGV:
sigmsg = "SIGSEGV - segment violation";
sigmsg = "SRB2 has attempted to access a memory location that it shouldn't and needs to close. %s";
sigttl = "SIGSEGV"; // segment violation
break;
// case SIGTERM:
// sigmsg = "SIGTERM - Software termination signal from kill";
// sigmsg = "SRB2 was terminated by a kill signal.";
// sigttl = "SIGTERM"; // Software termination signal from kill
// break;
// case SIGBREAK:
// sigmsg = "SIGBREAK - Ctrl-Break sequence";
// sigmsg = "SRB2 was terminated by a Ctrl-Break sequence.";
// sigttl = "SIGBREAK" // Ctrl-Break sequence
// break;
case SIGABRT:
sigmsg = "SIGABRT - abnormal termination triggered by abort call";
sigmsg = "SRB2 was terminated by an abort signal. %s";
sigttl = "SIGABRT"; // abnormal termination triggered by abort call
break;
default:
sprintf(msg,"signal number %d", num);
sigmsg = "SRB2 was terminated by an unknown signal. %s";
sprintf(ttl, "number %d", num);
if (coredumped)
sigmsg = 0;
sigttl = 0;
else
sigmsg = msg;
sigttl = ttl;
}
if (coredumped)
{
if (sigmsg)
sprintf(msg, "%s (core dumped)", sigmsg);
if (sigttl)
sprintf(ttl, "%s (core dumped)", sigttl);
else
strcat(msg, " (core dumped)");
strcat(ttl, " (core dumped)");
sigmsg = msg;
sigttl = ttl;
}
I_OutputMsg("\nProcess killed by signal: %s\n\n", sigmsg);
sprintf(ttl, "Process killed by signal: %s", sigttl);
if (!M_CheckParm("-dedicated"))
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR,
"Process killed by signal",
sigmsg, NULL);
sigttl = ttl;
I_OutputMsg("\n%s\n\n", sigttl);
if (M_CheckParm("-dedicated"))
return;
const SDL_MessageBoxButtonData buttons[] = {
{ SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, 0, "OK" },
{ 0, 1, "Discord" },
};
const SDL_MessageBoxData messageboxdata = {
SDL_MESSAGEBOX_ERROR, /* .flags */
NULL, /* .window */
sigttl, /* .title */
va(sigmsg,
"\n\nTo help us figure out the cause, you can visit our official Discord server\nwhere you will find more instructions on how to submit a crash report.\n\nSorry for the inconvenience!"), /* .message */
SDL_arraysize(buttons), /* .numbuttons */
buttons, /* .buttons */
NULL /* .colorScheme */
};
int buttonid;
SDL_ShowMessageBox(&messageboxdata, &buttonid);
if (buttonid == 1)
SDL_OpenURL("https://www.srb2.org/discord");
}
#ifndef NEWSIGNALHANDLER