Darren New wrote:
> 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?
Uh... Actually you're right :)
I dunno... I think you might be able to do something like this:
template<typename E>
void my_throw_exception(E& exc) {
//do the backtrace() dance and store the results somewhere in exc
throw exc;
}
But that's a bit cumbersome.
(PS: Division by zero doesn't throw a C++ exception)
Post a reply to this message
|