|
From: TSalm <TS...@fr...> - 2011-05-01 21:11:49
|
Le 01/05/2011 00:26, K. Frank a écrit : > Hi TSalm! > > On Sat, Apr 30, 2011 at 5:55 PM, TSalm<TS...@fr...> wrote: >> Hi, >> >> Is there away to catch an exception and display his stacktrace ? > I believe that the answer is no, if I understand your question. > > Ordinary, built-in c++ exceptions do not take a snapshot of the > stack or build a stacktrace as they unwind the stack. This is > by design, as c++ doesn't want to impose on you the cost of > building and maintaining this stacktrace. > > The stack gets unwound between where you throw the exception > and where you catch it. This can be inconvenient when debugging, > because if your code throws an exception deep down in some nested > function calls, seeing the stacktrace (at the time the exception was > thrown) can help make the bug apparent. (I think java exceptions do > give you the stacktrace, and this can be very helpful.) > > When I'm doing development and debugging, I generally put in assets. > These cause the program to core dump (or send control back to the > debugger) right at the point where the error is detected (i.e., the assert > fails), and then you can look at the state of the stack when the error > occurred (unless your bug has corrupted the stack...). I understand. On an other side, why the -g switch doesn't insert something to manage this stacktrace when an exception occurs ? Thanks. ____________ Analyse antivirus effectuée par G Data AntiVirus |