diff --git a/SWIG/Tools/WAD/Test/death.py b/SWIG/Tools/WAD/Test/death.py new file mode 100644 index 000000000..ba1de20a3 --- /dev/null +++ b/SWIG/Tools/WAD/Test/death.py @@ -0,0 +1,65 @@ +import debug +from Tkinter import * + +def death_by_segmentation(): + debug.seg_crash() + +def death_by_bus(): + debug.bus_crash() + +def death_by_abort(): + debug.abort_crash(-1) + +def death_by_math(): + debug.math_crash(37,0) + +def death_by_buffer(): + debug.overflow_crash() + +def death(f): + ty = f.tvar.get() + if ty == 1: + death_by_segmentation() + elif ty == 2: + death_by_abort() + elif ty == 3: + death_by_math() + elif ty == 4: + death_by_bus() + elif ty == 5: + death_by_buffer() + +class death_options(Frame): + def __init__(self): + Frame.__init__(self) + tvar = IntVar() + Radiobutton(self,text="Segmentation fault", variable=tvar, value=1).pack(anchor=W) + Radiobutton(self,text="Failed assertion", variable=tvar, value=2).pack(anchor=W) + Radiobutton(self,text="Math error", variable=tvar, value=3).pack(anchor=W) + Radiobutton(self,text="Bus error", variable=tvar, value=4).pack(anchor=W) + Radiobutton(self,text="Stack overflow", variable=tvar, value=5).pack(anchor=W) + Button(self,text="Die", command=lambda x=self: death(x)).pack(expand=1, fill=BOTH) + self.tvar = tvar + tvar.set(1) + +def death_wizard(): + root = Tk() + l = Label(text="How would you like to die today?") + l.pack() + death_options().pack() + root.title("Death Wizard") +death_wizard() + +#root.mainloop() + + + + + + + + + + + + diff --git a/SWIG/Tools/WAD/Test/debug.c b/SWIG/Tools/WAD/Test/debug.c index 24dc65c90..b95b539f0 100644 --- a/SWIG/Tools/WAD/Test/debug.c +++ b/SWIG/Tools/WAD/Test/debug.c @@ -12,6 +12,8 @@ typedef double Real; typedef Real Float; +char buffer[256]; + /* A simple segmentation fault on an uninitialized pointer */ int seg_crash() { int *a = 0; @@ -40,12 +42,10 @@ int overflow_crash() { } } -/* A simple bus error. This might fail silently on certain platforms */ +/* A simple bus error. */ int bus_crash() { - int b; - int *a = &b; - a = (int *) ((int) a | 0x1); - *a = 3; + double *a = (double *) (buffer+1); + *a = 3.4; return 1; }