Added -dumpstack option to catch fatal signals for stacktrace dumping. Writes to both stderr and a crash.log in the WORKING directory. Admins are expected to email a copy or something to an FTE dev, then delete it. Clients connecting will be notified, but unable to obtain actual details via quake.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3813 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2011-06-06 01:41:33 +00:00
parent d039841d21
commit 78d4632097
5 changed files with 53 additions and 4 deletions

View File

@ -270,6 +270,7 @@ CLIENT_ONLY_CFLAGS=-DCLIENTONLY
SERVER_ONLY_CFLAGS=-DSERVERONLY
JOINT_CFLAGS=
DEBUG_CFLAGS=-ggdb -g
DEBUG_CFLAGS=-rdynamic
PROFILE_CFLAGS=-pg
ifeq ($(FTE_TARGET),win32)

View File

@ -3117,10 +3117,6 @@ void CL_Init (void)
Cmd_AddCommand ("demo_jump", CL_DemoJump_f);
Cmd_AddCommand ("timedemo", CL_TimeDemo_f);
#ifdef _DEBUG
Cmd_AddCommand ("crashme", (void*)~0);
#endif
Cmd_AddCommand ("showpic", SCR_ShowPic_Script_f);
Cmd_AddCommand ("startdemos", CL_Startdemos_f);

View File

@ -3309,6 +3309,8 @@ void COM_Init (void)
Cmd_AddCommand ("dir", COM_Dir_f); //q3 like
Cmd_AddCommand ("flocate", COM_Locate_f); //prints the pak or whatever where this file can be found.
Cmd_AddCommand ("version", COM_Version_f); //prints the pak or whatever where this file can be found.
Cmd_AddCommand ("crashme", (void*)0); //debugging feature, makes it jump to an invalid address
COM_InitFilesystem ();

View File

@ -1630,6 +1630,22 @@ void SV_AcceptMessage(int protocol)
Netchan_OutOfBand (NS_SERVER, net_from, len, (qbyte *)string);
}
#ifndef _WIN32
#include <sys/stat.h>
static void SV_CheckRecentCrashes(client_t *tellclient)
{
struct stat sb;
if (-1 != stat("crash.log", &sb))
{
SV_ClientPrintf(tellclient, PRINT_HIGH, "\1WARNING: crash.log exists, dated %s\n", ctime(&sb.st_mtime));
}
}
#else
static void SV_CheckRecentCrashes(client_t *tellclient)
{
}
#endif
/*
==================
SVC_DirectConnect
@ -2389,6 +2405,8 @@ client_t *SVC_DirectConnect(void)
SV_ClientPrintf(newcl, PRINT_CHAT, "%s\n", sv_motd[i].string);
}
SV_CheckRecentCrashes(newcl);
#ifdef PEXT2_VOICECHAT
SV_VoiceInitClient(newcl);
#endif

View File

@ -637,6 +637,32 @@ void Sys_Shutdown (void)
{
}
#include <execinfo.h>
static void Friendly_Crash_Handler(int sig)
{
int fd;
void *array[10];
size_t size;
// get void*'s for all entries on the stack
size = backtrace(array, 10);
// print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, 2);
fd = open("crash.log", O_WRONLY|O_CREAT|O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP);
if (fd != -1)
{
write(fd, "Crash Log:\n", 11);
size = backtrace(array, 10);
backtrace_symbols_fd(array, size, fd);
write(fd, "\n", 1);
close(fd);
}
exit(1);
}
/*
=============
main
@ -661,6 +687,12 @@ int main(int argc, char *argv[])
parms.argc = com_argc;
parms.argv = com_argv;
if (COM_CheckParm("-dumpstack"))
{
signal(SIGILL, Friendly_Crash_Handler);
signal(SIGSEGV, Friendly_Crash_Handler);
signal(SIGBUS, Friendly_Crash_Handler);
}
parms.memsize = 16*1024*1024;