How to recover an exception without losing the original call stack?

The situation is as follows: Thread A receives an exception, saves the exception data somewhere in memory (using GetExceptionInformation in the exception filter), and the afterword Thread B receives this information about the exceptions and wants to recover it. But the fact is that when thread B redraws the caught exception, I skip the original call stack, which leads to the exception.
How can I rebuild the exception without losing the original call stack? (note that this question is for C ++).

+6
c ++ windows exception exception-handling
source share
2 answers

You can expand the stack in a catch block and save it as part of the exception you are rebuilding. Unwinding the stack in C ++ is a bit complicated, but you could take a look at the crashdump collector code that comes with WxWidgets for an example.

+2
source share

The question is why you need to pass the stack to the receive stream.

I assume you need a stack to basically report this to the error log. You can go through the stack in a trap or create a mini-dump or any error information that you want to collect, and then just pass a copy of the exception (if possible, beware of slicing) to the receiving stream.

0
source share

All Articles