[Haskell-cafe] Exceptions

Keith Wansbrough Keith.Wansbrough at cl.cam.ac.uk
Tue Oct 5 05:01:40 EDT 2004


[+RTS -xc]
> A major problem with this that I notice is that it dumps the stack
> whenever any exception is raised, which is a big pain if your program
> does IO and regularly raises and catches exceptions as part of normal
> operation. A big improvement would be to only dump the backtrace if the
> exception was uncaught and caused the program to abort.

Agreed.  I wrote the -RTS +xc code several years ago, and thought that
what you describe would be much nicer.  But this would have involved
quite a bit more hacking of the RTS.  At the point the exception is
thrown, the backtrace is just sitting there waiting to be dumped.  But
once it's thrown this information is lost.

I imagined wrapping up the backtrace information into a data structure
and including that as an argument to the exception, so that the
primitive catch operation would receive a backtrace in addition to the
exception itself; then the backtrace could be dumped to stderr or
whatever by the default toplevel handler.

In the end I didn't have the motivation to implement this, and I don't
have the same contact with the GHC codebase any more.  I'd be happy to
help anyone who wanted to add this, though, or for someone just to go
ahead and do it...

--KW 8-)



More information about the Haskell-Cafe mailing list