|
|
Nicolas Alvarez wrote:
> GNU libc (not libstdc++!) has C functions to get backtraces at any moment.
> It's a GNU extension. You may very well call it in an exception handler.
>
> http://www.gnu.org/software/libtool/manual/libc/Backtraces.html
It would seem that's rather not very useful in the exception handler? Or am
I misunderstanding? If I catch a division-by-zero in main() and I want to
log what function that happened in, how would I do that?
I guess what I'm asking is, isn't it the case that by the time you're in the
exception handler, the stack frames leading to the unexpected exception have
already been cleaned up, and all the stuff that's on the stack is working
correctly?
If I have a server, and I want to catch and log failures, in most languages
I do something along the lines of
main() {
try {
do_main_loop();
} except Exception e {
log("Uncaught exception", e);
} finally {
clean_up();
}
}
but by the time I get to the log() call, the stack is gone, yes? Where would
I put the call to "backtrace" such that I'd catch the actual function that
threw the exception?
--
Darren New, San Diego CA, USA (PST)
My fortune cookie said, "You will soon be
unable to read this, even at arm's length."
Post a reply to this message
|
|