From 53418727e9ce2aae5b87503f5f8b0d0d15eab267 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 3 Aug 2009 22:15:53 +0000 Subject: [PATCH] little debugging helper for linux git-svn-id: https://svn.eduke32.com/eduke32@1485 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/sdlayer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/polymer/eduke32/build/src/sdlayer.c b/polymer/eduke32/build/src/sdlayer.c index 55d320695..d8d1a4d77 100644 --- a/polymer/eduke32/build/src/sdlayer.c +++ b/polymer/eduke32/build/src/sdlayer.c @@ -6,6 +6,7 @@ #include #include +#include #include "sdl_inc.h" #include "compat.h" #include "sdlayer.h" @@ -224,6 +225,20 @@ void setvsync(int32_t sync) } #endif +static void attach_debugger_here(void){} + +static void sighandler(int signum) +{ + if (signum==SIGSEGV) + { + SDL_WM_GrabInput(SDL_GRAB_OFF); + SDL_ShowCursor(SDL_ENABLE); + attach_debugger_here(); + uninitsystem(); + exit(1); + } +} + // // initsystem() -- init SDL systems // @@ -262,6 +277,8 @@ int32_t initsystem(void) return -1; } + signal(SIGSEGV, sighandler); + atexit(uninitsystem); frameplace = 0;