CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    Oct 2009
    Posts
    37

    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

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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.

  3. #3
    Join Date
    Oct 2009
    Posts
    37

    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?

  4. #4
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Visual Studio 2005: "step back"

    Quote Originally Posted by Momentum View Post
    ...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?
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    Re: Visual Studio 2005: "step back"

    Quote Originally Posted by Momentum View Post
    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.

  6. #6
    Join Date
    Aug 2000
    Location
    New York, NY, USA
    Posts
    5,656

    Re: Visual Studio 2005: "step back"

    Quote Originally Posted by GCDEF View Post
    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()
    Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
    Convenience and productivity tools for Microsoft Visual Studio:
    FeinWindows - replacement windows manager for Visual Studio, and more...

  7. #7
    Join Date
    Oct 2009
    Posts
    37

    Re: Visual Studio 2005: "step back"

    Quote Originally Posted by VladimirF View Post
    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.

  8. #8
    Join Date
    Oct 2009
    Posts
    37

    Re: Visual Studio 2005: "step back"

    Quote Originally Posted by GCDEF View Post
    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?

  9. #9
    Join Date
    Oct 2009
    Posts
    37

    Re: Visual Studio 2005: "step back"

    Quote Originally Posted by VladimirF View Post
    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?

  10. #10
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,635

    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.

  11. #11
    Join Date
    Oct 2009
    Posts
    37

    Re: Visual Studio 2005: "step back"

    Quote Originally Posted by GCDEF View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured