If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Visual Studio Debugging - revisiting same memory state

Hello,

When running my code in Visual Studio, there is a particular point in the code where my program is crashing. To debug this, I am adding a break point in Debug mode just before that point, and observing what happens as I step through the code. However, to get to this break point in the code takes about a minute of running the program. So I'm wondering if there is a tool in Visual Studio to reload the state of a program's memory from a previous run, so that I can immediately get to the break point without having to wait for a minute each time?

Re: Visual Studio Debugging - revisiting same memory state

Originally Posted by karnavor

Hello,

When running my code in Visual Studio, there is a particular point in the code where my program is crashing. To debug this, I am adding a break point in Debug mode just before that point, and observing what happens as I step through the code. However, to get to this break point in the code takes about a minute of running the program.

What if this "minute of running the program" is what causes the ultimate crash, or at least makes it reproducible?

You shouldn't be changing any behaviour in the program if you're trying to debug a crash. Doing so may make that crash no longer appear.

If the wait is truly innocuous, then change the code to skip the code that waits, or change the code to make the wait shorter, or while debugging, change the value of variables or change execution paths (Set Next Statement, for example) to skip the slow code.

But still, my warning stands -- change the code or execution path during debugging, and you may not be able to recreate the problem if the problem is one of memory corruption or issues similar to that.

Re: Visual Studio Debugging - revisiting same memory state

Originally Posted by karnavor

... So I'm wondering if there is a tool in Visual Studio to reload the state of a program's memory from a previous run, so that I can immediately get to the break point without having to wait for a minute each time?

I would try to create a dump using MiniDumpWriteDump() function at the point you are interested in.
Then you can load this dump as many time as you want and start debugging.
This, of course, require a special build, so I am not sure if you can save any time with that.

Re: Visual Studio Debugging - revisiting same memory state

In fact, it can be done even with a regular debug build. You put a breakpoint wherever you need to start from, and wait until it gets hit. Then in the bottom of Debug menu VS will provide an entry something like Save Dump As.

The problem is that the first method may cause the problem to go away or manifest itself in another manner. This is a sign of a very hard to track down bug, typically a memory overwrite somewhere, the point of failure can be totally different from the point of detection.
THe problem with the 2nd method is that it may slow down debugging significantly, or it may be impossible to codify in the breakpoint condition system of VS.