Is there any way to know from where the C++ exception originates ?

Till Straumann strauman at
Wed Sep 22 00:41:55 UTC 2004

Valery Pykhtin wrote:

>Hi All,
>may be this is an unappropriate place to ask, but may be someone knows the
>answer in the topic ?
>Best regards,
That's why we were taught 'never user GOTO' in the old days. C++ people
will probably tell you that you don't _have_ to know and start singing about
'encapsulation' etc.

If I need to know, I set a breakpoint to __throw or similar (depends on 
gcc version)
in the debugger. If you don't have debugger support on your RTEMS target
you can usually either patch your binary or use the linker's --wrap 
option to
hook into 'throw'. Write a little routine that dumps a stack trace and then
branches to the real 'throw'. If your application throws and handles a lot
of exceptions but you need to catch a 'fatal' one, let the hook routine 
the stack trace to memory and print it on 'exit', or from a global 
'catch' statement.

That's the easiest that comes to my mind.
-- Till

More information about the users mailing list