views:

174

answers:

2

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

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

When the breakpoint hits, my stack looks normal. I can see all my routines. But if I run, and let the exception get thrown, I see a worthless stack. it has MyApp.exe!_threadstartex() towards the bottom, a few disabled entries labeled kernel32.dll, and the line "Frames below may be incorrect and/or missing" etc.

This really sucks! Because very often I will get an exception in my debug build, and this $5000 development environment is not even showing me my own stack! I am statically linking with everything so its not a DLL problem.

Help!

+2  A: 

I think you mix up smth. here.

If you catch the exception in some catch statement or it is propagated until main your stack was unwound and you can not expect VC++ to remember the entire stack.

For example in Java stack trace is part of the exception itself. Dependent on you compiler you can write an exception class which records the stack trace if it is constructed (but not copy constructed) and carries the information. When the class is caught you can evaluate the info. If you program using MFC take a look at AfxDumpStack.

Hope that helps,
Ovanes

P.S: This DDJ article might be helpful to you: C++ Stack Traces

ovanes
A: 

Probably you are watching the callstack of the wrong thread. Go to the Tread Panel, in Debug->Windows->Threads, and then select the correct thread.

CHP
oh, if only it was that...
TheVinn
I hope so.Visual Studio will discover the callstack correctly, at least in debug-builds. But if you attach to a process after the exception has thrown, it doesn't show the right thread by default.
CHP
Let me be clear - this is not the problem I am facing.
TheVinn
Are you sure you checked the callstack of every thread in your process?
CHP