In response to TT #1283 and a few requests on IRC yesterday, I started
a new exception_backtraces branch. This branch implements "multi-hop"
backtraces, keeping track of the history of an exception prior to a
rethrow.

Attached is a short test program (which has turned into a test in
t/compilers/imcc/syn/errors.t). When run from the commandline this
test program produces the following output:

caught in bar
caught in foo
caught in main
This is an exception
current instr.: 'main' pc 22 (test.pir:10)

thrown from:
called from Sub 'foo' pc 47 (test.pir:22)
current instr.: 'main' pc 22 (test.pir:10)

thrown from:
called from Sub 'bar' pc 74 (test.pir:34)
current instr.: 'foo' pc 47 (test.pir:22)
called from Sub 'main' pc 9 (test.pir:3)

thrown from:
called from Sub 'baz' pc 86 (test.pir:40)
current instr.: 'bar' pc 74 (test.pir:34)
called from Sub 'foo' pc 34 (test.pir:15)
called from Sub 'main' pc 9 (test.pir:3)

This is much more informative than the old backtrace would have been.

This branchwork only performs some basic refactors and feature
additions to the string-based backtrace facilities. It does NOT add
anything to the object-based backtraces provided through the
Exception.backtrace method (which is an array of hashes of stuff). To
get the new informative backtrace strings, call the
src/exceptions.c:Parrot_ex_build_complete_backtrace_string(interp, ex)
function.

This backtrace string is not available [yet] directly from PIR. I
could add a new backtrace_string method to Exception PMC, or something
similar. Feedback appreciated.

I have a few codestd fixes to make, and much more testing. If other
people can run a few tests and give some feedback we might be able to
get this merged before 3.0.

Thanks,

--Andrew Whitworth

Attachment: exception_test.pir
Description: Binary data

_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to