You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/debugger/cpp-dynamic-debugging.md
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -166,20 +166,20 @@ First, let's review what it's like to debug optimized code. Then you can see how
166
166
167
167
1. Rerun the app.
168
168
169
-
Now when you hit the breakpoint on line 55, you see the values of `i` and `j` on the **Locals** window. The **Call Stack** window shows that `updateGrid()` is deoptimized and the filename is `life.alt.exe`. This alternate binary is used to debug optimized code.
169
+
Now when you hit the breakpoint on line 55, you see the values of `i` and `j` in the **Locals** window. The **Call Stack** window shows that `updateGrid()` is deoptimized and the filename is `life.alt.exe`. This alternate binary is used to debug optimized code.
170
170
171
171
:::image type="complex" source="media/vs-2022/dbg-deopt-update-grid-callstack.png" alt-text="A screenshot that shows debugging the updateGrid function.":::
172
172
A breakpoint is shown in the function updateGrid. The call stack shows that the function is deoptimized and the filename is life.alt.exe. The Locals window shows the values of i and j and the other local variables in the function.
173
173
:::image-end:::
174
174
175
175
The `updateGrid()` function is deoptimized on demand because you set a breakpoint in it. If you step over an optimized function while debugging, it isn't deoptimized. If you step *into* a function, it's deoptimized. The main way to cause a function to be deoptimized is if you set a breakpoint in it or step into it.
176
176
177
-
You can also deoptimize a function on the **Call Stack** window. Right-click the function, or a selected group of functions, and select **Deoptimize on next entry**. This feature is useful when you want to view local variables in an optimized function for which you haven't set a breakpoint elsewhere on the call stack. Functions that are deoptimized in this way are grouped together on the **Breakpoints** window as a breakpoint group named **Deoptimized Functions**. If you delete the breakpoint group, the associated functions revert to their optimized state.
177
+
You can also deoptimize a function in the **Call Stack** window. Right-click the function, or a selected group of functions, and select **Deoptimize on next entry**. This feature is useful when you want to view local variables in an optimized function for which you haven't set a breakpoint elsewhere on the call stack. Functions that are deoptimized in this way are grouped together in the **Breakpoints** window as a breakpoint group named **Deoptimized Functions**. If you delete the breakpoint group, the associated functions revert to their optimized state.
178
178
179
179
#### Use conditional and dependent breakpoints
180
180
181
181
1. Try setting a breakpoint again on line 19, `cout << (grid[i][j] ? '*' : ' ');` in `printGrid()`. Now it works. Setting a breakpoint in the function deoptimizes it so that you can debug it normally.
182
-
1. Right-click the breakpoint on line 19, select **Conditions**, and set the condition to `i == 10 && j== 10`. Then select the **Only enable when the following breakpoint is hit:** checkbox. Select the breakpoint on line 55 from the dropdown list. Now the breakpoint on line 19 doesn't hit until the breakpoint on line 50 is first hit, and then when `grid[10][10]` is about to output to the console.
182
+
1. Right-click the breakpoint on line 19, select **Conditions**, and set the condition to `i == 10 && j== 10`. Then select the **Only enable when the following breakpoint is hit:** checkbox. Select the breakpoint on line 55 from the dropdown list. Now the breakpoint on line 19 doesn't hit until the breakpoint on line 50 is hit first, and then when `grid[10][10]` is about to output to the console.
183
183
184
184
The point is that you can set conditional and dependent breakpoints in an optimized function and make use of local variables and lines of code that in an optimized build might be unavailable to the debugger.
185
185
@@ -206,7 +206,7 @@ First, let's review what it's like to debug optimized code. Then you can see how
206
206
You might need to debug optimized code without it being deoptimized, or put a breakpoint in optimized code and have the code stay optimized when the breakpoint hits. There are several ways to turn off Dynamic Debugging or keep it from deoptimizing code when you hit a breakpoint:
207
207
208
208
- On the Visual Studio main menu, select **Tools** > **Options** > **Debugging** > **General**. Clear the **Automatically deoptimize debugged functions when possible (.NET 8+, C++ Dynamic Debugging)** checkbox. The next time the debugger starts, code remains optimized.
209
-
- Many dynamic debugging breakpoints are two breakpoints: one in the optimized binary and one in the unoptimized binary. On the **Breakpoints** window, select **Show Columns** > **Function**. Clear the breakpoint associated with the `alt` binary. The other breakpoint in the pair breaks in the optimized code.
209
+
- Many dynamic debugging breakpoints are two breakpoints: one in the optimized binary and one in the unoptimized binary. In the **Breakpoints** window, select **Show Columns** > **Function**. Clear the breakpoint associated with the `alt` binary. The other breakpoint in the pair breaks in the optimized code.
210
210
- When you're debugging, on the Visual Studio main menu, select **Debug** > **Windows** > **Dissassembly**. Ensure that it has focus. When you step into a function via the **Dissassembly** window, the function won't be deoptimized.
211
211
- Disable dynamic debugging entirely by not passing `/dynamicdeopt` to `cl.exe`, `lib.exe`, and `link.exe`. If you're consuming third-party libraries and can't rebuild them, don't pass `/dynamicdeopt` during the final `link.exe` to disable Dynamic Debugging for that binary.
212
212
- To quickly disable Dynamic Debugging for a single binary (for example, `test.dll`), rename or delete the `alt` binary (for example, `test.alt.dll`).
@@ -289,14 +289,14 @@ If your project is built with the Visual Studio build system, a good way to make
289
289
290
290
1. The new configuration appears in the **Active solution configuration** dropdown list. Select **Close**.
291
291
1. With the **Configuration** dropdown list set to **ReleaseDD**, right-click your project in **Solution Explorer** and select **Properties**.
292
-
1. On **Configuration Properties** > **Advanced**, set **Use C++ Dynamic Debugging** to **Yes**.
292
+
1. In **Configuration Properties** > **Advanced**, set **Use C++ Dynamic Debugging** to **Yes**.
293
293
1. Ensure that **Whole Program Optimization** is set to **No**.
294
294
295
295
:::image type="complex" source="media/vs-2022/property-use-cpp-debugging.png" alt-text="A screenshot that shows the project properties.":::
296
296
The property page is opened to Configuration Properties > Advanced > Use C++ Dynamic Debugging. The property is set to Yes.
297
297
:::image-end:::
298
298
299
-
1. On **Configuration Properties** > **Linker** > **Optimization**, ensure that **Enable Incremental Linking** is set to **No (/OPT:NOICF)**.
299
+
1. In **Configuration Properties** > **Linker** > **Optimization**, ensure that **Enable Incremental Linking** is set to **No (/OPT:NOICF)**.
300
300
301
301
:::image type="complex" source="media/vs-2022/property-incremental-linking.png" alt-text="A screenshot that shows the project properties.":::
302
302
The property page is opened to Configuration Properties > Linker > Optimization > Enable Incremental Linking. The property is set to No.
@@ -308,7 +308,7 @@ You can add other switches that you use with your retail builds to this configur
308
308
309
309
For more information about configurations in Visual Studio, see [Create and edit configurations](/visualstudio/ide/how-to-create-and-edit-configurations).
310
310
311
-
### Make a new Debug configuration
311
+
### Creat a new Debug configuration
312
312
313
313
If you want to use debug binaries but you want them to run faster, you can modify your Debug configuration.
314
314
@@ -327,9 +327,9 @@ If you want to use debug binaries but you want them to run faster, you can modif
327
327
328
328
1. The new configuration appears in the **Active solution configuration** dropdown list. Select **Close**.
329
329
1. With the **Configuration** dropdown list set to **DebugDD**, right-click your project in **Solution Explorer** and select **Properties**.
330
-
1. On **Configuration Properties** > **C/C++** > **Optimization**, turn on the optimizations that you want. For example, you could set **Optimization** to **Maximize Speed (/O2)**.
331
-
1. On **C/C++** > **Code Generation**, set **Basic Runtime Checks** to **Default**.
332
-
1. On **C/C++** > **General**, disable **Support Just My Code Debugging**.
330
+
1. In **Configuration Properties** > **C/C++** > **Optimization**, turn on the optimizations that you want. For example, you could set **Optimization** to **Maximize Speed (/O2)**.
331
+
1. In **C/C++** > **Code Generation**, set **Basic Runtime Checks** to **Default**.
332
+
1. In **C/C++** > **General**, disable **Support Just My Code Debugging**.
333
333
1. Set **Debug Information Format** to **Program Database (/Zi)**.
334
334
335
335
You can add other switches that you use with your debug builds to this configuration so that you always have exactly the switches turned on or off that you expect when you use Dynamic Debugging. For more information about switches that you shouldn't use with Dynamic Debugging, see [Incompatible options](#incompatible-options).
@@ -349,7 +349,7 @@ For build distributors:
349
349
350
350
## Incompatible options
351
351
352
-
Some compiler and linker options are incompatible with C++ Dynamic Debugging. If you turn on C++ Dynamic Debugging by using the Visual Studio project settings, incompatible options are automatically turned off unless you specifically set them in the other command-line options setting.
352
+
Some compiler and linker options are incompatible with C++ Dynamic Debugging. If you turn on C++ Dynamic Debugging by using the Visual Studio project settings, incompatible options are automatically turned off unless you specifically set them in the additional command-line options setting.
353
353
354
354
The following compiler options are incompatible with C++ Dynamic Debugging:
0 commit comments