简体   繁体   中英

Find previous debug line in Visual studio 2005

I'm trying to debug a C++ project in VS 2005.

In debug mode how can i find the previous line that got executed.? ie Consider the control is in line 5000. How can i find the previous line which got executed before coming to line 5000. Actually there are few goto statements involved. Call stack is just displaying the previous functions which were called.

Though i know it is not a good practice to use goto, this is an existing project which I'm debugging. Thanks in advance.

If you got to line 5000 by a goto or a jump (rather than by a call), then there is no record of where you came from. You will just have to go back and trace through the code and watch it as it jumps to line 5000.

This information is lost. You should single-step in the code or add logging to know which lines were executed.

If you can recompile the source (which I guess you can since you've got debug information) you might want to sprinkle the code with calls to OutputDebugString each with a different bit of text - for example before each label and each goto.

That way when your line gets hit you can check which messages got dumped to the output window to find the execution path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM