Holy cow, why didn’t anyone tell me about New EIP?
Holy cow. I found a blog post about a way-cool Visual Studio debugger feature… that’s also available in Delphi’s debugger… even for Win32! Sweeeet.
It’s a way to move the current execution pointer. How many times have you stepped over a function, realized it didn’t do what you wanted,
and wish you could step back? Well, as long as the function didn’t have any significant side effects (and, in Win32, as long as it didn’t smash any important registers), you can. Gotten into an infinite loop, and had to terminate the app and start over? Not necessary — you can just move the instruction pointer outside the loop and keep debugging.
In Visual Studio .NET, the feature is called “Set Next Statement” and is available right there in the code window’s context menu; just right-click on the line you want to move to. In Delphi for Win32, you have to open the CPU window, and then you can right-click on an instruction in there and use the ever-so-intuitively-named “New EIP” menu item. No wonder I never knew Delphi had this feature.
I’ll be curious to see how well this works, and how sensitive it really is to things like register usage (temporary variables?). But, man, oh, man. This is gonna be awesome…
July 16th, 2004 at 2:10 pm
Yeah, that feature is poorly exposed in Visual Studio. I guess I was lucky that I noticed it (or had it pointed out to me) years ago. It’s very handy at times.
Here’s the Visual Studio doc on what you can and can’t do:
In the Visual Studio debugger, you can move the execution point to set the next statement of code to be executed. A yellow arrowhead in the margin of a source or Disassembly window marks the current location of the execution point. By moving the execution point, you can skip over a portion of code or return to a line previously executed. This can be useful in some situations — for example, if you want to skip a section of code that contains a known bug and continue debugging other sections.
Caution Changing the execution point causes the program counter to jump directly to the new location. Use this command with caution. Note that instructions between the old and new execution points are not executed; if you move the execution point backwards, intervening instructions are not undone; moving the execution point to another function or scope usually results in call-stack corruption, causing a run-time error or exception; and if you try moving the execution point to another scope, the debugger opens a dialog box that gives you a warning and a chance to cancel the operation. (Moving the execution point to another function or scope is not possible in Visual Basic.)
Note In managed code, you cannot change the execution point after an exception has occurred.
You cannot set the execution point while your application is actively running. To set the next statement, the debugger must be in break mode.