The situation is as follows: Thread A catches an exception, saves the exception's data somewhere in memory (using GetExceptionInformation in the exception filter), and afterwords Thread B gets that exception information and wants to rethrow it. But the thing is, when thread B rethrows the caught exception, i'm missing the original call stack that lead to the exception.
How can I rethrow the exception without losing the original call stack? (note that this question is about C++).
views:
294answers:
2
+2
A:
You could unwind the stack in the catch block and save it as part of the exception you are rethrowing. Unwinding the stack in C++ is a bit tricky, but you could have a al look at the crashdump collector code that comes with WxWidgets for an example.
Adrian Grigore
2009-12-12 16:25:03
marked as answer though not entirely practical in my case
2010-01-21 08:47:10
A:
Question is why would you need to pass the stack to the "receiving" thread.
I assume you need the stack in order to basically report it to some error log. You can walk the stack in the catching thread, or produce a mini dump, or whatever error info you wish to collect, and then just pass a copy of the exception (if possible, beware of slicing) to the receiving thread.
Assaf Lavie
2009-12-12 17:46:33