Visual Studio 2008 team: no call stack when I throw an exception

I am building a debug version of my application with full symbols. I have set a breakpoint on the following line:

throw std :: range_error ("invalid utf32");

When the breakpoint is hit, my stack looks fine. I see all of my routines. But if I run around and let the exception be thrown, I see a useless stack. it has MyApp.exe! _threadstartex () at the bottom, a few disabled entries labeled kernel32.dll, and the line "Frames below may be wrong and / or missing", etc.

It really sucks! Because very often I get an exception in my debug build and this $ 5000 IDE doesn't even show me my own stack! I am statically linking to everything so there is no DLL problem.

Help!

+2


source to share


4 answers


I think you are mixing smth. Here.

If you catch an exception in any catch statement, or it will propagate until your main stack is unwound and you cannot expect VC ++ to remember the entire stack.

For example, in the Java stack, tracing is part of the exception itself. Depending on your compiler, you can write an exception class that records a stack trace if constructed (but not copied) and carries information. When the class is caught, you can evaluate the information. If you are programming with MFC take a look at AfxDumpStack.



Hope it helps,
Hovhannes

PS: This DDJ article might be helpful to you: C ++ Stack Traces

+2


source


The problem is that you don't have debug symbols loaded for the location where the debugger stopped. This means that the rest of the call stack is nonsense.



Fortunately, the solution is easy: starting from the call stack window, right-click on each selected entry (for example KernelBase.dll! ...) and select Load Symbols From / Microsoft Symbol Servers . This will show your real call stack for one or two entries.

+3


source


I'm pretty sure the problem is that you don't have "break on exception". I had the same problem and couldn't believe I couldn't find helpful answers to this ... how did my vs2008 set up differently? I dont know. But one day, my call stack became useless when the debugged program crashed. Finally I went and checked all these exception classes to make the program "break on exception" and now it breaks when an exception is thrown (eg bad access) and I have a useful call stack for debugging. Hooray!

+3


source


You are probably looking at the wrong flow stack. Go to the protector panel, in Debug-> Windows-> Threads and then select the thread you want.

+1


source







All Articles