[Toxine-cvs] CVS: toxine/src common.h,1.33,1.34 main.c,1.38,1.39
Brought to you by:
f1rmb
From: Daniel Caujolle-B. <f1...@us...> - 2004-06-01 22:15:55
|
Update of /cvsroot/toxine/toxine/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5343/src Modified Files: common.h main.c Log Message: add backtrace printing (linux only) Index: common.h =================================================================== RCS file: /cvsroot/toxine/toxine/src/common.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- common.h 30 May 2004 23:22:39 -0000 1.33 +++ common.h 1 Jun 2004 22:15:46 -0000 1.34 @@ -101,6 +101,7 @@ fflush(stdout); \ } \ } while(0) + #define pout(FMT,ARGS...) do { \ if(!tox->stdin) { \ fprintf(stdout, FMT, ##ARGS); \ @@ -115,6 +116,7 @@ fflush(stdout); \ } \ } while(0) + #define pinfo(FMT,ARGS...) do { \ if(!tox->stdin) { \ fprintf(stdout, "%s", INFO_PREFIX); \ Index: main.c =================================================================== RCS file: /cvsroot/toxine/toxine/src/main.c,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- main.c 31 May 2004 20:37:05 -0000 1.38 +++ main.c 1 Jun 2004 22:15:46 -0000 1.39 @@ -36,6 +36,10 @@ #include <string.h> #include <fcntl.h> +#ifdef __linux__ +#include <execinfo.h> +#endif + #ifdef HAVE_GETOPT_LONG # include <getopt.h> #else @@ -83,6 +87,28 @@ switch(sig) { /* Segfault */ case SIGSEGV: + perr("SIGSEGV received.\n"); +#ifdef __linux__ + { + void *backtrace_array[255]; + char **backtrace_strings; + int entries, i; + + if((entries = backtrace(backtrace_array, 255))) { + if((backtrace_strings = backtrace_symbols(backtrace_array, entries))) { + perr("Backtrace:\n"); + + for(i = 0; i < entries; i++) { + poutalign(); + pout("[%d] %s\n", i, backtrace_strings[i]); + } + + free(backtrace_strings); + perr("--\n"); + } + } + } +#endif exit(TOX_ERR_SIGSEGV); break; |