Search
lxdream.org :: lxdream :: r495:4db4702b0778
lxdream 0.9.1
released Jun 29
Download Now
changeset495:4db4702b0778
parent494:67c133a17400
child496:5c5c98f3bdd5
authornkeynes
dateWed Nov 07 11:45:53 2007 +0000 (16 years ago)
Add crash handler to get a backtrace via gdb
src/dream.h
src/main.c
src/util.c
1.1 --- a/src/dream.h Tue Nov 06 12:23:25 2007 +0000
1.2 +++ b/src/dream.h Wed Nov 07 11:45:53 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: dream.h,v 1.16 2007-10-31 09:10:23 nkeynes Exp $
1.6 + * $Id: dream.h,v 1.17 2007-11-07 11:45:53 nkeynes Exp $
1.7 *
1.8 * Miscellaneous application-wide declarations (mainly logging atm)
1.9 *
1.10 @@ -95,6 +95,8 @@
1.11 void fwrite_dump32( unsigned int *buf, unsigned int length, FILE *f );
1.12 void fwrite_dump32v( unsigned int *buf, unsigned int length, int wordsPerLine, FILE *f );
1.13
1.14 +void install_crash_handler(void);
1.15 +
1.16 gboolean write_png_to_stream( FILE *f, frame_buffer_t );
1.17 frame_buffer_t read_png_from_stream( FILE *f );
1.18
2.1 --- a/src/main.c Tue Nov 06 12:23:25 2007 +0000
2.2 +++ b/src/main.c Wed Nov 07 11:45:53 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: main.c,v 1.34 2007-10-31 11:53:35 nkeynes Exp $
2.6 + * $Id: main.c,v 1.35 2007-11-07 11:45:53 nkeynes Exp $
2.7 *
2.8 * Main program, initializes dreamcast and gui, then passes control off to
2.9 * the gtk main loop (currently).
2.10 @@ -64,6 +64,8 @@
2.11 {
2.12 int opt, i;
2.13 double t;
2.14 +
2.15 + install_crash_handler();
2.16 #ifdef ENABLE_NLS
2.17 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
2.18 textdomain (PACKAGE);
3.1 --- a/src/util.c Tue Nov 06 12:23:25 2007 +0000
3.2 +++ b/src/util.c Wed Nov 07 11:45:53 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: util.c,v 1.12 2007-10-31 12:05:23 nkeynes Exp $
3.6 + * $Id: util.c,v 1.13 2007-11-07 11:45:53 nkeynes Exp $
3.7 *
3.8 * Miscellaneous utility functions.
3.9 *
3.10 @@ -16,11 +16,14 @@
3.11 * GNU General Public License for more details.
3.12 */
3.13
3.14 +#define HAVE_EXECINFO_H 1
3.15 +
3.16 #include <assert.h>
3.17 #include <ctype.h>
3.18 #include <stdarg.h>
3.19 #include <stdio.h>
3.20 #include <stdlib.h>
3.21 +#include <signal.h>
3.22 #include <time.h>
3.23 #include <zlib.h>
3.24 #include <glib.h>
3.25 @@ -31,7 +34,30 @@
3.26 #include "sh4/sh4core.h"
3.27
3.28 char *msg_levels[] = { "FATAL", "ERROR", "WARN", "INFO", "DEBUG", "TRACE" };
3.29 -int global_msg_level = EMIT_WARN;
3.30 +int global_msg_level = EMIT_INFO;
3.31 +
3.32 +static void report_crash( int signo, siginfo_t *info, void *ptr )
3.33 +{
3.34 + char buf[128];
3.35 +
3.36 + fprintf( stderr, "--- Aborting with signal %d ---\n", signo );
3.37 + // Get gdb to print a nice backtrace for us
3.38 + snprintf( buf, 128, "gdb -batch -f --quiet --pid=%d -ex bt", getpid() );
3.39 + system(buf);
3.40 +
3.41 + abort();
3.42 +}
3.43 +
3.44 +void install_crash_handler(void)
3.45 +{
3.46 + struct sigaction sa;
3.47 +
3.48 + sa.sa_sigaction = report_crash;
3.49 + sigemptyset(&sa.sa_mask);
3.50 + sa.sa_flags = SA_RESETHAND|SA_SIGINFO;
3.51 + sigaction( SIGSEGV, &sa, NULL );
3.52 +}
3.53 +
3.54
3.55 void fwrite_string( const char *s, FILE *f )
3.56 {
.