www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Exception Handling

reply "sleek" <cslush gmail.com> writes:
Is there an easy way to get a stack trace when an exception is caught? 
Aug 27 2008
next sibling parent Jesse Phillips <jessekphillips gmail.com> writes:
On Wed, 27 Aug 2008 20:18:30 -0400, sleek wrote:

 Is there an easy way to get a stack trace when an exception is caught?
I believe that is currently a no.
Aug 27 2008
prev sibling next sibling parent Robert Fraser <fraserofthenight gmail.com> writes:
sleek wrote:
 Is there an easy way to get a stack trace when an exception is caught? 
The only way I know of currently is http://petermodzelewski.blogspot.com/2008/01/development-in-d-with-u e-of-backtrace.html . It's Windows-only. However, my most recent test of the binary tango libs ( http://petermodzelewski.blogspot.com/2008/08/tango-patched-libs-for-0997.html ) had some linking issue, and I was too lazy to follow up on it. There's a Phobos hack there as well as the Tango one, I haven't tried that. Flectioned ( flectioned.kuehne.cn ) used to be able to do it, but it hasn't been updated for over a year. I know the Tango one no longer compiles (though it shouldn't be _too_ much work to get it to do so). Phobos might still work. To trace non-user-defined exceptions with it you need to call TracedException.traceAllExceptions(true); Flectioned works better on Linux (on Windows, it won't trace segfaults/access violations).
Aug 27 2008
prev sibling next sibling parent reply Christopher Wright <dhasenan gmail.com> writes:
sleek wrote:
 Is there an easy way to get a stack trace when an exception is caught? 
On Linux, there's a library called jive floating around. It may be tango-only, and the official version is defunct, but you can find versions of it updated to more recent versions of D and tango. I know for a fact that it doesn't help when you segfault due to stack overflow (debugging a circular dependency verifier in dconstructor; it only takes a couple seconds to overflow your stack, but it takes ages if you're printing to stdout in the meantime). I don't know whether it catches other segmentation faults, though.
Aug 27 2008
parent Frank Benoit <keinfarbton googlemail.com> writes:
Christopher Wright schrieb:
 sleek wrote:
 Is there an easy way to get a stack trace when an exception is caught? 
On Linux, there's a library called jive floating around. It may be tango-only, and the official version is defunct, but you can find versions of it updated to more recent versions of D and tango. I know for a fact that it doesn't help when you segfault due to stack overflow (debugging a circular dependency verifier in dconstructor; it only takes a couple seconds to overflow your stack, but it takes ages if you're printing to stdout in the meantime). I don't know whether it catches other segmentation faults, though.
I use Jive a lot on linux. I put a copy on the DWT project page: http://downloads.dsource.org/projects/dwt/jive.zip
Aug 28 2008
prev sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"sleek" <cslush gmail.com> wrote in message 
news:g94qsm$t5$1 digitalmars.com...
 Is there an easy way to get a stack trace when an exception is caught?
On Windows, you can run your program in ddbg, and it will print out a stack trace when you get an exception (segfaults/stack overflows included) as long as you compiled your program with debug symbols (-g). You can get it here: http://ddbg.mainia.de/releases.html You just use ddbg -cmd="r" myprog.exe on the commandline to load your program and immediately start running it. On linux... yeah I don't know.
Aug 27 2008
next sibling parent reply "Jarrett Billingsley" <kb3ctd2 yahoo.com> writes:
"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:g95d2h$1ojq$1 digitalmars.com...
 "sleek" <cslush gmail.com> wrote in message 
 news:g94qsm$t5$1 digitalmars.com...
 Is there an easy way to get a stack trace when an exception is caught?
On Windows, you can run your program in ddbg, and it will print out a stack trace when you get an exception (segfaults/stack overflows included) as long as you compiled your program with debug symbols (-g). You can get it here: http://ddbg.mainia.de/releases.html You just use ddbg -cmd="r" myprog.exe on the commandline to load your program and immediately start running it. On linux... yeah I don't know.
The downside here of course being that it's an external program and not a library/part of the language, but hey, how often do you need a stack trace unless you're debugging?
Aug 27 2008
parent Christopher Wright <dhasenan gmail.com> writes:
Jarrett Billingsley wrote:
 "Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
 news:g95d2h$1ojq$1 digitalmars.com...
 "sleek" <cslush gmail.com> wrote in message 
 news:g94qsm$t5$1 digitalmars.com...
 Is there an easy way to get a stack trace when an exception is caught?
On Windows, you can run your program in ddbg, and it will print out a stack trace when you get an exception (segfaults/stack overflows included) as long as you compiled your program with debug symbols (-g). You can get it here: http://ddbg.mainia.de/releases.html You just use ddbg -cmd="r" myprog.exe on the commandline to load your program and immediately start running it. On linux... yeah I don't know.
The downside here of course being that it's an external program and not a library/part of the language, but hey, how often do you need a stack trace unless you're debugging?
Conversely, when do you explicitly want a lacok of debug information on a crash? Maybe if you're distributing a super-secret closed source application, but that's the only situation I can think of.
Aug 28 2008
prev sibling parent "sleek" <cslush gmail.com> writes:
After considering this for a few hours, I think ddbg is my best bet here. 
Quite honestly, I should only be catching known exceptions. Anything else 
that occurs that is unexpected should absolutely bubble up and out.


"Jarrett Billingsley" <kb3ctd2 yahoo.com> wrote in message 
news:g95d2h$1ojq$1 digitalmars.com...
 "sleek" <cslush gmail.com> wrote in message 
 news:g94qsm$t5$1 digitalmars.com...
 Is there an easy way to get a stack trace when an exception is caught?
On Windows, you can run your program in ddbg, and it will print out a stack trace when you get an exception (segfaults/stack overflows included) as long as you compiled your program with debug symbols (-g). You can get it here: http://ddbg.mainia.de/releases.html You just use ddbg -cmd="r" myprog.exe on the commandline to load your program and immediately start running it. On linux... yeah I don't know.
Aug 28 2008