POV-Ray : Newsgroups : povray.off-topic : Standard libraries : Re: Standard libraries Server Time
9 Oct 2024 14:33:54 EDT (-0400)
  Re: Standard libraries  
From: Darren New
Date: 8 Mar 2009 19:39:43
Message: <49b4573f@news.povray.org>
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

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.