Visual Studio 2005: "step back"
Hi,
During debugging of code, you are able to step forward each line, and into a function, but are you able to "step back" a line with all varables and application state resetting to previous values?
thanks
Re: Visual Studio 2005: "step back"
Sort of. You can set the current instruction pointer anywhere you want, but the variables won't be restored.
You can also use the call stack to pop back to the previous place on the stack. When you do that, your variables will be restored and you can set the instruction pointer anywhere you like.
Results can be unpredictable.
Re: Visual Studio 2005: "step back"
thanks for the reply.
I noticed my call stack window only displays the current line being processed. I do not get a listing of processed calls to pop back to.
I viewed the options for the stack windows and did not see anything that hints to listing all calls in a function. what am I missing?
Re: Visual Studio 2005: "step back"
Quote:
Originally Posted by
Momentum
...what am I missing?
Your stack frame, obviously :)
Seriously: is it a regular Debug session or are you at the scene of a crash? Is your stack pointer corrupted by chance?
Re: Visual Studio 2005: "step back"
Quote:
Originally Posted by
Momentum
thanks for the reply.
I noticed my call stack window only displays the current line being processed. I do not get a listing of processed calls to pop back to.
I viewed the options for the stack windows and did not see anything that hints to listing all calls in a function. what am I missing?
You'll only get a call stack if you've actually made calls. If it's a simple program without any function calls, that's to be expected.
Re: Visual Studio 2005: "step back"
Quote:
Originally Posted by
GCDEF
You'll only get a call stack if you've actually made calls. If it's a simple program without any function calls, that's to be expected.
Debugging this code (breakpoint is on "return 0;")
Code:
#include "stdafx.h"
int main()
{
return 0;
}
I have this much in my Call Stack:
Code:
> ConsTest.exe!main() Line 5 C++
ConsTest.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C
ConsTest.exe!mainCRTStartup() Line 414 C
kernel32.dll!7c817077()
Re: Visual Studio 2005: "step back"
Quote:
Originally Posted by
VladimirF
Your stack frame, obviously :)
Seriously: is it a regular Debug session or are you at the scene of a crash? Is your stack pointer corrupted by chance?
I don't think anything's corrupted, I'm currently able to step forward and into functions without any problems.
Re: Visual Studio 2005: "step back"
Quote:
Originally Posted by
GCDEF
You'll only get a call stack if you've actually made calls. If it's a simple program without any function calls, that's to be expected.
I only have a simple class, with member functions.
in the main, I'm just calling the constructor and the member functions.
I understood your suggestion to be, use the call stack window, which will list all calls made to a function.
So when I step into a function or step forward within main, I thougt I'll see the listing of pass calls to the stack in the call stack window?
Re: Visual Studio 2005: "step back"
Quote:
Originally Posted by
VladimirF
Debugging this code (breakpoint is on "return 0;")
Code:
#include "stdafx.h"
int main()
{
return 0;
}
I have this much in my Call Stack:
Code:
> ConsTest.exe!main() Line 5 C++
ConsTest.exe!__tmainCRTStartup() Line 597 + 0x19 bytes C
ConsTest.exe!mainCRTStartup() Line 414 C
kernel32.dll!7c817077()
ok, so if you were to add 3 other functions within main, I thought each call will be logged in the call stack window so u could step back to the first function if need be, with varables set to previous value?
Re: Visual Studio 2005: "step back"
If you're inside a function, the call stack will show you how you got there and the debugger will let you move around the current stack. Once you return from a function, it's popped from the stack and you can't get there again through the debugger unless you can place the instruction pointer at the place where the function was called and step into it again.
Re: Visual Studio 2005: "step back"
Quote:
Originally Posted by
GCDEF
If you're inside a function, the call stack will show you how you got there and the debugger will let you move around the current stack. Once you return from a function, it's popped from the stack and you can't get there again through the debugger unless you can place the instruction pointer at the place where the function was called and step into it again.
bingo! thanks for the explanation.
also thanks VladimirF.