Skip to content

Commit ba3d122

Browse files
committed
changes
1 parent 30f2eca commit ba3d122

File tree

3 files changed

+45
-41
lines changed

3 files changed

+45
-41
lines changed
-3.62 KB
Loading
5.62 KB
Loading

docs/debugger/using-breakpoints.md

+45-41
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,36 @@ ms.workload:
3838
- "multiple"
3939
---
4040
# Use breakpoints in the Visual Studio debugger
41-
Breakpoints are one of the most important debugging techniques in your toolbox. You set breakpoints where you want to pause debugger execution. For example, you may want to see the state of code variables or look at the call stack at the breakpoint.
41+
Breakpoints are one of the most important debugging techniques in your toolbox. You set breakpoints wherever you want to pause debugger execution. For example, you may want to see the state of code variables or look at the call stack at a certain breakpoint.
4242

4343
## <a name="BKMK_Overview"></a> Set line breakpoints in source code
44-
You can set a breakpoint on any line of executable code. For example, in the following C# code, you could set a breakpoint on the variable declaration, the `for` loop, or any code inside the `for` loop. You can't set a breakpoint on the namespace or class declarations, or the method signature.
44+
You can set a breakpoint on any line of executable code. For example, in the following C# code, you could set a breakpoint on the variable declaration, the `for` loop, or any code inside the `for` loop. You can't set a breakpoint on the namespace or class declarations, or on the method signature.
4545

46-
To set a line breakpoint in source code, select a line and then click in the left margin. You can also press **F9**, select **Debug** > **Toggle Breakpoint**, or right-click and select **Breakpoint** > **Insert breakpoint**. The breakpoint appears as a red dot in the left margin.
46+
To set a line breakpoint in source code, click in the far left margin next to a line of code. You can also select the line and press **F9**, select **Debug** > **Toggle Breakpoint**, or right-click and select **Breakpoint** > **Insert breakpoint**. The breakpoint appears as a red dot in the left margin.
4747

4848
![Set a breakpoint](../debugger/media/basicbreakpoint.png "Basic breakpoint")
4949

50-
When you debug the code, execution pauses at the breakpoint, before the code on that line is executed. The breakpoint symbol shows a yellow arrow.
50+
When you debug, execution pauses at the breakpoint, before the code on that line is executed. The breakpoint symbol shows a yellow arrow.
5151

5252
At the breakpoint in the following example, the value of `testInt` is still 1.
5353

5454
![Breakpoint execution stopped](../debugger/media/breakpointexecution.png "Breakpoint execution")
5555

5656
When the debugger stops at the breakpoint, you can look at the current state of the app, including variable values and the call stack. For more information about the call stack, see [How to: Use the Call Stack window](../debugger/how-to-use-the-call-stack-window.md).
5757

58-
- The breakpoint is a toggle. You can click it to delete it, then click again in the same spot to reinsert it, press **F9** to delete or reinsert it, or use **Debug** > **Toggle Breakpoint**.
58+
- The breakpoint is a toggle. You can click it, press **F9**, or use **Debug** > **Toggle Breakpoint** to delete or reinsert it.
5959

60-
- To disable a breakpoint without deleting it, hover over it, or right-click, and select **Disable breakpoint**. Disabled breakpoints appear as empty circles in the left margin. To re-enable a breakpoint, hover over it, or right-click, and select **Enable breakpoint**.
60+
- To disable a breakpoint without deleting it, hover over or right-click it, and select **Disable breakpoint**. Disabled breakpoints appear as empty dots in the left margin. To re-enable a breakpoint, hover over or right-click it, and select **Enable breakpoint**.
6161

62-
- You can set conditions and actions, add and edit labels, or export a breakpoint by right-clicking it and selecting the appropriate command, or hovering over it and selecting the **Settings** icon.
62+
- Set conditions and actions, add and edit labels, or export a breakpoint by right-clicking it and selecting the appropriate command, or hovering over it and selecting the **Settings** icon.
6363

64-
## <a name="BKMK_Set_a_breakpoint_in_a_function"></a> Set breakpoints in debugger windows
64+
## <a name="BKMK_Set_a_breakpoint_in_a_function"></a> Set breakpoints from debugger windows
6565

6666
You can also set breakpoints from the **Call Stack** and **Disassembly** debugger windows.
6767

6868
### <a name="BKMK_Set_a_breakpoint_in_the_call_stack_window"></a> Set a breakpoint in the Call Stack window
6969

70-
Set a breakpoint in the **Call Stack** window to break at the instruction or line that a calling function returns to. For more information about the call stack, see [How to: Use the Call Stack window](../debugger/how-to-use-the-call-stack-window.md).
70+
To break at the instruction or line that a calling function returns to, you can set a breakpoint in the **Call Stack** window.
7171

7272
**To set a breakpoint in the Call Stack window:**
7373

@@ -77,17 +77,19 @@ You can also set breakpoints from the **Call Stack** and **Disassembly** debugge
7777

7878
A breakpoint symbol appears next to the function call name in the left margin of the call stack.
7979

80-
The call stack breakpoint appears in the **Breakpoints** window as an address with a memory location that corresponds to the next executable instruction in the function.
80+
The call stack breakpoint appears in the **Breakpoints** window as an address, with a memory location that corresponds to the next executable instruction in the function.
8181

8282
The debugger breaks at the instruction.
8383

84-
To visually trace breakpoints during code execution, see [Map methods on the call stack while debugging](../debugger/map-methods-on-the-call-stack-while-debugging-in-visual-studio.md).
84+
For more information about the call stack, see [How to: Use the Call Stack window](../debugger/how-to-use-the-call-stack-window.md).
85+
86+
To visually trace breakpoints during code execution, see [Map methods on the call stack while debugging](../debugger/map-methods-on-the-call-stack-while-debugging-in-visual-studio.md).
8587

8688
### Set a breakpoint in the Disassembly window
8789

8890
1. To open the **Disassembly** window, you must be paused during debugging. Select **Debug** > **Windows** > **Disassembly**, or press **Ctrl**+**Alt**+**D**.
8991

90-
2. In the **Disassembly** window, click in the left margin of the instruction you want to break at, select it and press **F9**, or right-click and select **Breakpoint** > **Insert Breakpoint**.
92+
2. In the **Disassembly** window, click in the left margin of the instruction you want to break at. You can also select it and press **F9**, or right-click and select **Breakpoint** > **Insert Breakpoint**.
9193

9294
## <a name="BKMK_Set_a_breakpoint_in_a_source_file"></a> Set function breakpoints
9395

@@ -105,10 +107,10 @@ To visually trace breakpoints during code execution, see [Map methods on the cal
105107

106108
- Use the fully qualified function name.
107109
Example: `Namespace1.ClassX.MethodA()`
108-
110+
109111
- Add the parameter types of an overloaded function.
110112
Example: `MethodA(int, string)`
111-
113+
112114
- Use the '!' symbol to specify the module.
113115
Example: `App1.dll!MethodA`
114116

@@ -120,13 +122,16 @@ To visually trace breakpoints during code execution, see [Map methods on the cal
120122

121123
1. Select **OK**.
122124

123-
### Set a breakpoint with a memory address (native C++ only)
125+
### Set a function breakpoint using a memory address (native C++ only)
124126
You can use the address of an object to set a function breakpoint on a method called by a specific instance of a class. For example, given an addressable object of type `my_class`, you can set a function breakpoint on the `my_method` method that instance calls.
125127

126128
1. Set a breakpoint somewhere after the instance of the class is instantiated.
129+
127130
2. Find the address of the instance (for example, `0xcccccccc`).
131+
128132
3. Select **Debug** > **New Breakpoint** > **Function Breakpoint**, or press **Alt**+**F9** > **B**.
129-
4. Add the following text to the **Function Name** box:
133+
134+
4. Add the following to the **Function Name** box, and select **C++** language.
130135

131136
```C++
132137
((my_class *) 0xcccccccc)->my_method
@@ -138,33 +143,33 @@ To visually trace breakpoints during code execution, see [Map methods on the cal
138143

139144
**To set a data breakpoint:**
140145

141-
1. Start debugging, and wait until a breakpoint is reached. On the **Debug** menu, choose **New Breakpoint** > **Data Breakpoint**
146+
1. In a C++ project, start debugging, and wait until a breakpoint is reached. On the **Debug** menu, choose **New Breakpoint** > **Data Breakpoint**
142147

143148
You can also select **New** > **Data Breakpoint** in the **Breakpoints** window.
144149

145150
2. In the **Address** box, type a memory address, or an expression that evaluates to a memory address. For example, type `&avar` to break when the contents of the variable `avar` changes.
146151

147152
3. In the **Byte Count** dropdown, select the number of bytes you want the debugger to watch. For example, if you select **4**, the debugger will watch the four bytes starting at `&avar` and break if any of those bytes change value.
148153

149-
>[!NOTE]
150-
>Data breakpoints depend on specific memory addresses. The address of a variable changes from one debugging session to the next, so data breakpoints are automatically disabled at the end of each debugging session.
151-
>
152-
>If you set a data breakpoint on a local variable, the breakpoint remains enabled when the function ends, but the memory address is no longer applicable, so the behavior of the breakpoint is unpredictable. If you set a data breakpoint on a local variable, you should delete or disable the breakpoint before the function ends.
153-
154-
Data breakpoints don't work under these conditions:
154+
Data breakpoints don't work under the following conditions:
155155
- A process that is not being debugged writes to the memory location.
156156
- The memory location is shared between two or more processes.
157157
- The memory location is updated within the kernel. For example, if memory is passed to the 32-bit Windows `ReadFile` function, the memory will be updated from kernel mode, so the debugger won't break on the update.
158158

159+
>[!NOTE]
160+
>- Data breakpoints depend on specific memory addresses. The address of a variable changes from one debugging session to the next, so data breakpoints are automatically disabled at the end of each debugging session.
161+
>
162+
>- If you set a data breakpoint on a local variable, the breakpoint remains enabled when the function ends, but the memory address is no longer applicable, so the behavior of the breakpoint is unpredictable. If you set a data breakpoint on a local variable, you should delete or disable the breakpoint before the function ends.
163+
159164
## <a name="BKMK_Specify_advanced_properties_of_a_breakpoint_"></a> Manage breakpoints in the Breakpoints window
160165

161-
You can use the **Breakpoints** window (**Debug** > **Windows** > **Breakpoints**, or **Ctrl**+**Alt**+**B**) to see and manage all the breakpoints in your solution. This centralized location is especially helpful in a large solution or for complex debugging scenarios where breakpoints are critical.
166+
You can use the **Breakpoints** window to see and manage all the breakpoints in your solution. This centralized location is especially helpful in a large solution, or for complex debugging scenarios where breakpoints are critical.
162167

163168
In the **Breakpoints** window, you can search, sort, filter, enable/disable, or delete breakpoints. You can also set conditions and actions, or add a new function or data breakpoint.
164169

165-
To open the **Breakpoints** window, select **Debug > **Windows** > **Breakpoints** or press **Alt**+**F9**.
170+
To open the **Breakpoints** window, select **Debug** > **Windows** > **Breakpoints**, or press **Alt**+**F9** or **Ctrl**+**Alt**+**B**.
166171

167-
![Breakpoints window](../debugger/media/breakpointswindow.png "BreakpointsWindow")
172+
![Breakpoints window](../debugger/media/breakpointswindow.png "Breakpoints window")
168173

169174
### <a name="BKMK_Set_a_breakpoint_at_a_function_return_in_the_Call_Stack_window"></a> Breakpoint labels
170175
You can use labels to sort and filter the list of breakpoints in the **Breakpoints** window.
@@ -175,11 +180,10 @@ You can use labels to sort and filter the list of breakpoints in the **Breakpoin
175180
### Export and import breakpoints
176181
To save or share the state and location of your breakpoints, you can export or import them.
177182

178-
- To export a single breakpoint to an XML file, right-click the breakpoint in the source code or **Breakpoints** window, and select **Export** or **Export selected**. Select an export location, and then select **Save**.
179-
- To export several breakpoints, select the boxes next to the breakpoints in the **Breakpoints** window, or enter search criteria in the **Search** field. Select the **Export all breakpoints matching the current search criteria** icon, and save the file.
180-
- To export all breakpoints, deselect all boxes and leave the **Search** field blank, select the **Export all breakpoints matching the current search criteria** icon, and save the file.
181-
- To import breakpoints, in the **Breakpoints** window toolbar, select the **Import breakpoints from a file** icon, navigate to the XML file location, and select **Open**.
182-
183+
- To export a single breakpoint to an XML file, right-click the breakpoint in the source code or **Breakpoints** window, and select **Export** or **Export selected**. Select an export location, and then select **Save**. The default location is the solution folder.
184+
- To export several breakpoints, in the **Breakpoints** window, select the boxes next to the breakpoints, or enter search criteria in the **Search** field. Select the **Export all breakpoints matching the current search criteria** icon, and save the file.
185+
- To export all breakpoints, deselect all boxes and leave the **Search** field blank. Select the **Export all breakpoints matching the current search criteria** icon, and save the file.
186+
- To import breakpoints, in the **Breakpoints** window, select the **Import breakpoints from a file** icon, navigate to the XML file location, and select **Open**.
183187

184188
## Breakpoint conditions
185189
You can control when and where a breakpoint executes by setting conditions. The condition can be any valid expression that the debugger recognizes. For more information about valid expressions, see [Expressions in the debugger](../debugger/expressions-in-the-debugger.md).
@@ -190,11 +194,11 @@ You can use labels to sort and filter the list of breakpoints in the **Breakpoin
190194

191195
![Breakpoint settings](../debugger/media/breakpointsettings.png "BreakpointSettings")
192196

193-
1. In the dropdown, select **Conditional Expression**, **Hit Count**, or **Filter**, and set the conditions accordingly.
197+
1. In the dropdown, select **Conditional Expression**, **Hit Count**, or **Filter**, and set the value accordingly.
194198

195199
1. Select **Close** or press **Ctrl**+**Enter** to close the **Breakpoint Settings** window.
196-
197-
<a name="BKMK_Specify_a_breakpoint_condition_using_a_code_expression"></a> ### Conditional Expression
200+
<a name="BKMK_Specify_a_breakpoint_condition_using_a_code_expression"></a>
201+
### Conditional Expression
198202

199203
When you select **Conditional Expression**, you can choose between two conditions: **Is true** or **When changed**. Choose **Is true** to break when the expression is satisfied, or **When changed** to break when the value of the expression has changed.
200204

@@ -213,8 +217,8 @@ When you select **Conditional Expression**, you can choose between two condition
213217
>- For native code, the debugger doesn't consider the first evaluation of the condition to be a change, so doesn't hit the breakpoint on the first evaluation.
214218
>- For managed code, the debugger hits the breakpoint on the first evaluation after **When changed** is selected.
215219
216-
#### Using Object IDs in conditional expressions (C# and F# only)
217-
There are times when you want to observe the behavior of a specific object. For example, you might want to find out why an object was inserted more than once into a collection. In C# and F#, you can create object IDs for specific instances of [reference types](/dotnet/csharp/language-reference/keywords/reference-types), and use them in breakpoint conditions. The object ID is generated by the common language runtime (CLR) debugging services and associated with the object.
220+
### Using Object IDs in conditional expressions (C# and F# only)
221+
There are times when you want to observe the behavior of a specific object. For example, you might want to find out why an object was inserted into a collection more than once. In C# and F#, you can create object IDs for specific instances of [reference types](/dotnet/csharp/language-reference/keywords/reference-types), and use them in breakpoint conditions. The object ID is generated by the common language runtime (CLR) debugging services and associated with the object.
218222

219223
**To create an Object ID:**
220224

@@ -226,13 +230,13 @@ When you select **Conditional Expression**, you can choose between two condition
226230

227231
You should see a **$** plus a number in the **Locals** window. This is the object ID.
228232

229-
3. Add a new breakpoint at the point you want to investigate; for example, when the object is to be added to the collection, and open the **Conditions** dialog.
233+
3. Add a new breakpoint at the point you want to investigate; for example, when the object is to be added to the collection. Right-click the breakpoint and select **Conditions**.
230234

231-
4. Use the Object ID in the **Conditional Expression** field. For example, if the variable `item` is the object to be added to the collection, put **item == $\<n>**, where \<n> is the object ID number.
235+
4. Use the Object ID in the **Conditional Expression** field. For example, if the variable `item` is the object to be added to the collection, select **Is true** and type **item == $\<n>**, where \<n> is the object ID number.
232236

233237
Execution will break at the point when that object is to be added to the collection.
234238

235-
To later delete the Object ID, right-click the variable in the **Locals** window and select **Delete Object ID**.
239+
To delete the Object ID, right-click the variable in the **Locals** window and select **Delete Object ID**.
236240

237241
>[!NOTE]
238242
>Object IDs create weak references, and do not prevent the object from being garbage collected. They are valid only for the current debugging session.
@@ -278,9 +282,9 @@ Enclose string values in double quotes. You can combine clauses using `&` (AND),
278282
- **$TNAME** - Thread name
279283
- **$TICK** - Tick count (from Windows `GetTickCount`)
280284

281-
1. To break execution when the tracepoint is hit, clear the **Continue Execution** check box, or select the **Continue Execution** box to print the message to the **Output** window without breaking.
285+
1. To print the message to the **Output** window without breaking, select the **Continue Execution** check box. To print the message and break execution at the tracepoint, clear the check box.
282286

283-
Tracepoints appear as red diamonds in the left margin of in the source code and **Breakpoints** windows.
287+
Tracepoints appear as red diamonds in the left margin of the source code and **Breakpoints** windows.
284288

285289
## See also
286290
[Troubleshoot breakpoints in the Visual Studio debugger](../debugger/troubleshooting-breakpoints.md)

0 commit comments

Comments
 (0)