views:

24

answers:

3

Hi,

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

In debug mode how can i find the previous line that got executed.? i.e 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.

A: 

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.

John Knoeller
A: 

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

Timores
A: 

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.

marklam