Is there any way to know from where the C++ exception originates ?
bvacaliuc at ngit.com
Tue Sep 21 23:30:08 UTC 2004
On Tuesday, September 21, 2004 6:32 PM, Angelo Fraietta wrote:
> I suspect that this would be a GCC question.
Yes, and its been discussed there off and on. It seems that in most cases the different execution environments provide some
function which may be called in the exception handler itself to dump the stack.
Its not that important in *nix, as you get a .core and then you can use a debugger to analyze it. For an embedded system, when the
problem is intermittent, it would be nice to capture as much information as possible, log it and recover the system.
I also wanted to mention one point:
The std::exception class only provides an interface to get the exception interpreted as a text string via the what() member
function. Some developers are of the opinion that this engenders "useless" exception handling systems since the handlers have to
parse their way through at every level.
Certainly, one can use derived classes to provide additional info (such as file/line info) statically rather than dynamically; or
simply the PC that the throw() occurred in. This would cover the exceptions thrown from within the application code, but wouldn't
provide the functionality in external libraries.
For this reason, stack analysis seems to remain the most general approach.
More information about the users