編輯後繼續 (C++)Edit and Continue (C++)

您可以在 c + + 專案中使用 [編輯後繼續]。You can use Edit and Continue in C++ projects. 如需 [編輯後繼續] 限制的相關資訊,請參閱支援的程式 代碼變更 (c + +) See Supported Code Changes (C++) for information about the limitations of Edit and Continue.

如需 Visual Studio 2015 Update 3 改善的詳細資訊,請參閱 Visual Studio 2015 update 3 中的 c + + 編輯後繼續For more information about Visual Studio 2015 Update 3 improvements, see C++ Edit and Continue in Visual Studio 2015 Update 3.

在 Visual Studio 2013 Update 3 中推出的 /Zo (增強最佳化偵錯) 編譯器選項會將額外資訊新增至不使用 /Od (停用 (偵錯)) 選項編譯之二進位碼檔案的 .pdb (符號) 檔案。The /Zo (Enhance Optimized Debugging) compiler option that was introduced in Visual Studio 2013 Update 3 adds additional information to .pdb (symbol) files for binaries compiled without the /Od (Disable (Debug)) option.

/Zo 會停用 [編輯後繼續]。/Zo disables Edit and Continue. 請參閱如何:對最佳化程式碼進行偵錯See How to: Debug Optimized Code.

啟用或停用編輯後繼續Enable or disable Edit and Continue

如果您不希望在目前的偵錯工作階段中套用正在編輯的程式碼內容,您可能需要停用 [編輯後繼續] 的自動引動過程。You may want to disable the automatic invocation of Edit and Continue if you are making edits to the code that you do not want applied during the current debugging session. 您也可以重新啟用自動的 [編輯後繼續]。You can also re-enable automatic Edit and Continue.

重要

如需有關功能相容性的必要組建設定及其他資訊,請參閱 Visual Studio 2015 Update 3 中的 c + + 編輯後繼續For required build settings and other information about feature compatibility, see C++ Edit and Continue in Visual Studio 2015 Update 3.

  1. 如果您是在偵測會話中,請停止調試 (Shift + F5) 。If you are in a debugging session, stop debugging (Shift + F5).

  2. 在 [工具] 功能表上,選擇 [選項]。On the Tools menu, choose Options.

  3. 在 [ 選項 ] 對話方塊中,選取 [調試 > 一般]。In the Options dialog box, select Debugging > General.

  4. 若要啟用,請選取 [ 啟用編輯後繼續]。To enable, select Enable Edit and Continue. 若要停用,請清除該核取方塊。To disable, clear the checkbox.

  5. 在 [編輯後繼續] 群組中,選取或清除 [啟用原生編輯後繼續] 核取方塊。In the Edit and Continue group, select or clear the Enable Native Edit and Continue check box.

    修改這個設定會影響您處理的所有專案。Altering this setting affects all projects you work on. 變更這個設定之後不需要重建應用程式。You do not need to rebuild your application after changing this setting. 如果您從命令列或 makefile 建立您的應用程式,但在 Visual Studio 環境中進行偵錯工具,您仍然可以在設定 /zi 選項時使用 [編輯後繼續]。If you build your application from the command line or from a makefile, but you debug in the Visual Studio environment, you can still use Edit and Continue if you set the /ZI option.

如何明確套用程式碼變更How to apply code changes explicitly

在 c + + 中,[編輯後繼續] 可以用兩種方式套用程式碼變更。In 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.

如何停止程式碼變更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.

如何重設執行點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.

在 c + + 中,對話方塊會在執行點變更時通知您。In 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.

如何使用過時程式碼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. 如果您編輯呼叫目前函式的函式,或將 64 位元組以上的新變數加入至呼叫堆疊上的某個函式時,就會發生這種情況。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 until the changes can be applied. 過時程式碼會在不同的來源視窗中顯示為暫時原始程式檔視窗,並使用像是 enc25.tmp的標題。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.

另請參閱See also