Partager via


Edit and Continue (Visual C++)

This article describes procedures to work with Edit and Continue in Visual C++ projects. See Supported Code Changes and Limitations (C++) for information about the limitations of Edit and Continue.

Warning

The /Zo (Enhance Optimized Debugging) compiler option that was introduced in Visual Studio Update 3 adds additional information to .pdb (symbol) files for binaries compiled without the /Od (Disable (Debug)) option.

/Zo disables Edit and Continue. See How to: Debug Optimized Code.

In this article

Enable or disable automatic invocation of Edit and Continue

How to apply code changes explicitly

How to stop code changes

How to reset the point of execution

How to work with stale code

Enable or disable automatic invocation of Edit and Continue

You can disable the automatic invocation of Edit and Continue (invocation by the Continue, Go, and Step commands). You might do this if you are making edits to the code that you do not want applied during the current debugging session. You can also re-enable the automatic invocation of Edit and Continue.

  1. On the Debug menu, choose Options and Settings.

  2. In the Options dialog box, select the Edit and Continue category.

  3. In the Edit and Continue group, select or clear the Invoked by debug commands check box.

    Note

    You can also have the debugger ask you before applying code changes prior to a debug command. If you want to be asked, select the Ask me first check box.

Because Invoked by debug commands is a tools option, altering this setting affects all projects you work on. You do not need to rebuild your application after changing this setting. You can change the setting even while debugging. If you build your application from the command line or from a Makefile, but debug in the Visual C++ environment, you can still use Edit and Continue if you set the /ZI option.

Back to topIn this article

How to apply code changes explicitly

In Visual C++, Edit and Continue can apply code changes in two ways. Code changes can be applied implicitly, when you choose an execution command, or explicitly, using the Apply Code Changes command.

When you apply code changes explicitly, your program remains in break mode – no execution occurs.

  • To apply code changes explicitly, on the Debug menu, choose Apply Code Changes.

Back to topIn this article

How to stop code changes

While Edit and Continue is in the process of applying code changes, you can stop the operation.

To stop applying code changes:

  • On the Debug menu, choose Stop Applying Code Changes.

This menu item is visible only when code changes are being applied.

If you choose this option, none of the code changes are committed.

Back to topIn this article

How to reset the point of execution

Some code changes can cause the point of execution to move to a new location when Edit and Continue applies the changes. Edit and Continue places the point of execution as accurately as possible, but the results may not be correct in all cases.

In Visual C++, a dialog box informs you when the point of execution changes. You should verify that the location is correct before you continue debugging. If it is not correct, use the Set Next Statement command. For more information, see Set the next statement to execute.

Back to topIn this article

How to work with stale code

In some cases, Edit and Continue cannot apply code changes to the executable immediately, but might be able to apply the code changes later if you continue debugging. This happens if you edit a function that calls the current function or if you add more than 64 bytes of new variables to a function on the call stack

In such cases, the debugger continues executing the original code (called stale code) until the changes can be applied. The stale code appears as a temporary source file window in a separate source window, with a title such as enc25.tmp. The edited source continues to appear in the original source window. If you try to edit the stale code, a warning message appears.

Back to topIn this article

See Also

Reference

Supported Code Changes and Limitations (C++)