开发者

Debugging C++ code in Visual Studio: Breaking out at a non-pre-determined time

I had a question about debugging in Visual Studio (2010 if it actually matters). Sometimes I am running an applicati开发者_如何学JAVAon and I want to break out of it to debug or to see where it has hung, etc. However, I find that very very often the "break-out point" seems to be in some random .c file in the standard library. I understand why this is (its executing some method somewhere), but I want to know where the last point it was in the code I have written is. Is there a way to do this? If I try and "step", the debugger seems to always return something like "there is no code to debug for the current location" or something, which I am guess means that it is making its way through some machine code. Again, that's fine, but I want to know what the last executed call in my main.cpp file was; is there a way to get this information? The call stack doesn't seem to help either, it always has a list of non-sensicle calls and even if I can locate the latest point in the call stack that is from my main.cpp, it doesn't seem to provide any useful information (like a line number or a function name... I think it's showing the mangled name).

What do most people do in this situation? I apologize, I know I'm a beginner, and I'm sorry I don't have a concrete example, but I feel I see this often at work.

Any help appreciated, thanks!

K


Once you've paused the program observe the call stack (Debug->Windows->Call Stack) at that point, find where the last layer of your code is and get there by clicking on the corresponding line in the call stack window.


The "Step Out" command, Shift+F11, will finish execution of the current function and break immediately after the return.

You can use Step Out a few times to step out of the system calls back to your code.

The "Step Into Just My Code" option sounds like it may do what you want, but I've never used it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜