diff options
author | Dave Beazley <dave-swig@dabeaz.com> | 2001-06-24 20:01:03 +0000 |
---|---|---|
committer | Dave Beazley <dave-swig@dabeaz.com> | 2001-06-24 20:01:03 +0000 |
commit | 0db13bddea79301f8d497ec5c976f3fb61c98a35 (patch) | |
tree | e9356ce111ec5b28f7e16615748f8e53dd97ed79 /Tools | |
parent | d194c494f36eeb842c26d70fb2ff62b4935385c7 (diff) | |
download | swig-0db13bddea79301f8d497ec5c976f3fb61c98a35.tar.gz |
*** empty log message ***
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@1218 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/WAD/CHANGES | 6 | ||||
-rw-r--r-- | Tools/WAD/Include/wad.h | 2 | ||||
-rw-r--r-- | Tools/WAD/README | 5 | ||||
-rw-r--r-- | Tools/WAD/Test/death.tcl | 65 | ||||
-rw-r--r-- | Tools/WAD/Wad/default.c | 37 | ||||
-rw-r--r-- | Tools/WAD/Wad/signal.c | 13 |
6 files changed, 111 insertions, 17 deletions
diff --git a/Tools/WAD/CHANGES b/Tools/WAD/CHANGES index e9acbc1a0..455c1ca6b 100644 --- a/Tools/WAD/CHANGES +++ b/Tools/WAD/CHANGES @@ -1,3 +1,9 @@ +WAD 0.2 - June 24, 2001 + + - Minor changes. Added the wadtrace file + + - Put everything under the LGPL. + WAD 0.1 - March 23, 2001 - Extensive changes to WAD core. WAD now builds an exception diff --git a/Tools/WAD/Include/wad.h b/Tools/WAD/Include/wad.h index c61eeb457..fc47237cc 100644 --- a/Tools/WAD/Include/wad.h +++ b/Tools/WAD/Include/wad.h @@ -202,6 +202,8 @@ extern void wad_stack_debug(WadFrame *f); extern char *wad_strip_dir(char *); extern void wad_default_callback(int signo, WadFrame *frame, char *ret); +extern void wad_dump_trace(int fd, int signo, WadFrame *frame, char *ret); + extern void wad_set_callback(void (*h)(int, WadFrame *, char *)); extern char *wad_load_source(char *, int line); extern void wad_release_source(); diff --git a/Tools/WAD/README b/Tools/WAD/README index 15fce76ef..282d0bcf5 100644 --- a/Tools/WAD/README +++ b/Tools/WAD/README @@ -329,7 +329,8 @@ The scripts debug.py, debug.tcl, debug.pl can be used to test these extensions. No official documentation exists at this time. However, the Papers directory contains two conference papers that describe WAD's design -and high-level operation. Slides from the Python9 talk are also included. +and high-level operation. Slides from the Python9 talk are also +included. 9. To-Do @@ -369,4 +370,4 @@ ways to contribute. Here is the short to-do list: Please contact me if you are interested in working on any of these projects. Dave Beazley (beazley@cs.uchicago.edu) -March 23, 2001 +June 24, 2001 diff --git a/Tools/WAD/Test/death.tcl b/Tools/WAD/Test/death.tcl new file mode 100644 index 000000000..e43feb2c6 --- /dev/null +++ b/Tools/WAD/Test/death.tcl @@ -0,0 +1,65 @@ +load ./debug.so + +proc death_by_segmentation { } { + seg_crash +} + +proc death_by_bus { } { + bus_crash +} + +proc death_by_abort { } { + abort_crash -1 +} + +proc death_by_math { } { + math_crash 37 0 +} + +proc death_by_buffer { } { + overflow_crash +} + +set method 1 +proc death {} { + global method + if { $method == 1 } { + death_by_segmentation + } + if { $method == 2 } { + death_by_abort + } + if { $method == 3 } { + death_by_math + } + if { $method == 4 } { + death_by_bus + } + if { $method == 5 } { + death_by_buffer + } +} + +label .l -text "How would you like to die today?" +pack .l + +radiobutton .r1 -text "Segmentation fault" -variable method -value 1 +pack .r1 -anchor w + +radiobutton .r2 -text "Failed assertion" -variable method -value 2 +pack .r2 -anchor w + +radiobutton .r3 -text "Math error" -variable method -value 3 +pack .r3 -anchor w + +radiobutton .r4 -text "Bus error" -variable method -value 4 +pack .r4 -anchor w + +radiobutton .r5 -text "Stack overflow" -variable method -value 5 +pack .r5 -anchor w + +button .b -text "Die" -command death +pack .b -fill both -expand 1 + +wm title . "Death Wizard" + diff --git a/Tools/WAD/Wad/default.c b/Tools/WAD/Wad/default.c index 114450595..538674f86 100644 --- a/Tools/WAD/Wad/default.c +++ b/Tools/WAD/Wad/default.c @@ -255,31 +255,30 @@ wad_debug_make_strings(WadFrame *f) { } } -/* ----------------------------------------------------------------------------- - * Default callback - * ----------------------------------------------------------------------------- */ - -void wad_default_callback(int signo, WadFrame *f, char *ret) { +/* Dump trace to a file */ +void wad_dump_trace(int fd, int signo, WadFrame *f, char *ret) { + static char buffer[128]; char *srcstr = 0; switch(signo) { case SIGSEGV: - fprintf(stderr,"WAD: Segmentation fault.\n"); + write(fd,"WAD: Segmentation fault.\n", 25); break; case SIGBUS: - fprintf(stderr,"WAD: Bus error.\n"); + write(fd,"WAD: Bus error.\n",17); break; case SIGABRT: - fprintf(stderr,"WAD: Abort.\n"); + write(fd,"WAD: Abort.\n",12); break; case SIGFPE: - fprintf(stderr,"WAD: Floating point exception.\n"); + write(fd,"WAD: Floating point exception.\n", 31); break; case SIGILL: - fprintf(stderr,"WAD: Illegal instruction.\n"); + write(fd,"WAD: Illegal instruction.\n", 26); break; default: - fprintf(stderr,"WAD: Signal %d\n", signo); + sprintf(buffer,"WAD: Signal %d\n", signo); + write(fd,buffer,strlen(buffer)); break; } /* Find the last exception frame */ @@ -289,16 +288,24 @@ void wad_default_callback(int signo, WadFrame *f, char *ret) { } while (f) { - fputs(f->debug_str, stderr); + write(fd,f->debug_str,strlen(f->debug_str)); if (f->debug_srcstr) { srcstr = f->debug_srcstr; } f = f->prev; } if (srcstr) { - fputs("\n", stderr); - fputs(srcstr,stderr); - fputs("\n", stderr); + write(fd,"\n",1); + write(fd,srcstr,strlen(srcstr)); + write(fd,"\n",1); } } +/* ----------------------------------------------------------------------------- + * Default callback + * ----------------------------------------------------------------------------- */ + +void wad_default_callback(int signo, WadFrame *f, char *ret) { + wad_dump_trace(2,signo,f,ret); +} + diff --git a/Tools/WAD/Wad/signal.c b/Tools/WAD/Wad/signal.c index b64aa1cb5..ea3f92518 100644 --- a/Tools/WAD/Wad/signal.c +++ b/Tools/WAD/Wad/signal.c @@ -401,6 +401,19 @@ void wad_signalhandler(int sig, siginfo_t *si, void *vcontext) { wad_string_debug(); wad_memory_debug(); + /* Before we do anything with callbacks, we are going + to attempt to dump a wad-core */ + + { + int fd; + static int already = 0; + fd = open("wadtrace",O_WRONLY | O_CREAT | (already*O_APPEND) | ((already==0)*O_TRUNC),0666); + if (fd > 0) { + wad_dump_trace(fd,sig,origframe,retname); + close(fd); + already=1; + } + } if (sig_callback) { (*sig_callback)(sig,origframe,retname); |