Breakpoints pause program execution at a certain location or when a particular condition occurs. You can set source breakpoints and module load breakpoints in the Code Editor before and during a debugging session. You can set data breakpoints and address breakpoints only when the application is running in debug mode (F9),
Procedures described in this Topic:
- To set a source breakpoint
- To set an address breakpoint
- To set a data breakpoint
- To set a module load breakpoint
- To create a breakpoint group
- To enable or disable a breakpoint or a breakpoint group
- To create a conditional breakpoint
- To associate actions with a breakpoint
- To change the colors associated with breakpoints
During a debugging session, any line of code that is eligible for a breakpoint is marked with a blue dot in the left gutter of the Code Editor.
You can also set breakpoints on frames displayed in the Call Stack window. The breakpoint icons in the Call Stack window are similar to those in the Code Editor, except that the blue dot indicates only that debug information is available for the frame, not whether a breakpoint can be set on that frame.
Breakpoints are displayed in the Breakpoint List window, available by selecting ViewDebug windowsBreakpoints.
The following icons are used to represent breakpoints in the Code Editor gutter.
Icon |
Description |
|
The breakpoint is valid and enabled. The debugger is inactive. |
|
The breakpoint is valid and enabled. The debugger is active. |
|
The breakpoint is invalid and enabled. The breakpoint is set at an invalid location, such as a comment, a blank line, or invalid declaration. |
|
The breakpoint is valid and disabled. The debugger is inactive. |
|
The breakpoint is valid and disabled. The debugger is active. |
|
The breakpoint is invalid and disabled. The breakpoint is set at an invalid location. |
To set a source breakpoint
- To prefill the line number in the dialog box, click the line of source in the Code Editor at the point where you want to stop execution.
- Choose RunAdd BreakpointSource Breakpoint to display the Add Source Breakpoint dialog box.
Tip: To change the Code Editor
gutter, choose ToolsOptionsEditor OptionsDisplay and adjust the Gutter width option.
- In the Add Source Breakpoint dialog box, the file name is prefilled with the name of the file, and Pass count is set to 0 (meaning that the breakpoint fires on the first pass). In the Line number field, enter the line in the Code Editor where you want to set the breakpoint.
- To apply a condition to the address breakpoint, enter a conditional expression in the Condition field. The conditional expression is evaluated each time the breakpoint is encountered, and program execution stops when the expression evaluates to True.
- To associate the source breakpoint with a breakpoint group, enter the name of a group or select from the Group dropdown list.
- To set any of the Advanced options, see the help topic for the Add Address Breakpoint or Add Data Breakpoint dialog box.
Note: To quickly set a breakpoint on a line of source code, click the left gutter of the Code Editor
next to the line of code where you want to pause execution.
To set an address breakpoint
- Choose RunAdd BreakpointAddress Breakpoint to display the Add Address Breakpoint dialog box.
- In the Address field, enter the address in memory (such as $00011111) at which you want to set the breakpoint.
- To apply a condition to the address breakpoint, enter a conditional expression in the Condition field. The conditional expression is evaluated each time the breakpoint is encountered, and program execution stops when the expression evaluates to true.
- To specify that the address breakpoint will only fire after a number of passes, enter the number in the Pass count field.
- To associate the address breakpoint with an existing breakpoint group, enter the group name in the Group field, or select the name of an existing group from the dropdown list.
- To set any of the Advanced options, see the help topic for the Add Address Breakpoint or Add Data Breakpoint dialog box.
Note: You can also set an address breakpoint in the CPU view
or the Disassembly view by clicking in the gutter.
To set a data breakpoint
- The application must be running in debug mode (for example, use F9, F8, F7, or F4).
- Choose RunAdd BreakpointData Breakpoint to display the Add Data Breakpoint dialog box.
- In the Address field, enter the address of the data you want to function as the data breakpoint.
- In the Length field, specify the length of the data operand that is to constitute the breakpoint. Note that a warning is displayed for the following issues:
- The length of the data breakpoint should not cross an even-byte boundary. (A data breakpoint with a 1-byte length has no alignment problems, but 2-byte and 4-byte data breakpoints might cover more or fewer addresses than you intend.)
- The data breakpoint should not be set on a stack location. (The breakpoint might be hit so often that the program cannot run properly.)
- To apply a condition to the breakpoint, enter a conditional expression in the Condition field. The conditional expression is evaluated each time the breakpoint is encountered, and program execution stops when the expression evaluates to true.
- To specify that the breakpoint only fires after a number of passes, enter the number in the Pass count field.
- To associate the data breakpoint with an existing breakpoint group, enter the group name in the Group field, or select the name of an existing group from the dropdown list.
- To set any of the Advanced options, see the help topic for the Add Address Breakpoint or Add Data Breakpoint dialog box.
To set a module load breakpoint
- Choose RunAdd BreakpointModule Load Breakpoint to display the Add Module Load Breakpoint dialog box.
- In the Module name field, enter the name of the DLL, package, or other module type that you want to monitor, or select a name from the drop down list.
Note: You can also use the Modules view
to set a module load breakpoint.
When the module you specify is loaded during program execution, the breakpoint is hit and program execution pauses.
To modify a breakpoint
- Open the Breakpoints List by selecting ViewDebug WindowsBreakpoints. Right-click the icon for the breakpoint you want to modify. For a source breakpoint, you can right-click the breakpoint icon in the Code Editor gutter, and choose Breakpoint Properties.
- Set the options in the Breakpoint Properties dialog box to modify the breakpoint. For example, you can set a condition, create a breakpoint group, or specify an action that is to occur when execution reaches the breakpoint.
- Click Help for more information about the options on the dialog box.
- Click OK.
To create a breakpoint group
- Open the Breakpoints List by choosing ViewDebug WindowsBreakpoints.
- Right-click the breakpoint and choose Breakpoint Properties.
- To create a breakpoint group, enter a group name in the Group field. To add the breakpoint to an existing group, select a name from the dropdown list box.
- Click OK.
To enable or disable a breakpoint or a breakpoint group
- Right-click the breakpoint icon in the Code Editor or in the Breakpoint List window and choose Enabled to toggle between enabled and disabled. In the Breakpoint List, you can click the checkbox at the left of the icon.
- To enable or disable all breakpoints, right-click a blank area (not on a breakpoint) in the Breakpoint List window and choose Enable All or Disable All.
- To enable or disable a breakpoint group, right-click a blank area (not on a breakpoint) in the Breakpoint List window and choose Enable Group or Disable Group.
Tip: Press the Ctrl
key while clicking a breakpoint in the
Code Editor gutter to toggle between enabled and disabled. Disabling a breakpoint or breakpoint group prevents it from pausing execution, but retains the breakpoint settings, so that you can enable it later.
To create a conditional breakpoint
- Choose RunAdd Breakpoint and select the type of breakpoint you want from the submenu.
- Complete the fields in the dialog box as described in the procedure given earlier for that breakpoint type.
- In the Condition field, enter a conditional expression to be evaluated each time this breakpoint is encountered during program execution. The breakpoint pauses execution when the expression evaluates to True.
- Complete other fields as appropriate.
- Click OK.
Conditional breakpoints are useful when you want to see how your program behaves when a variable falls into a certain range or what happens when a particular flag is set.
If the conditional expression evaluates to true (or not zero), the debugger pauses the program at the breakpoint location. If the expression evaluates to false (or zero), the debugger does not stop at the breakpoint location.
To associate actions with a breakpoint
- On the Breakpoint List, right-click the breakpoint and choose Breakpoint Properties.
- Click Advanced to display additional options.
- Check the actions that you want to occur when the breakpoint is encountered. For example, you can specify an expression to be evaluated and write the result of the evaluation to the Event Log.
- Click OK.
To change the color of the text at the execution point or the color of breakpoints
- Choose ToolsOptionsEditor OptionsColor.
- In the code sample window, select the appropriate language tab. For example, to change the breakpoint color for Delphi code, select the Delphi tab.
- Scroll the code sample window to display the execution and breakpoint icons in the left gutter of the window.
- Click anywhere on the execution point or breakpoint line that you want to change.
- Use the Foreground Color and Background Color dropdown lists to change the colors associated with the selected execution point or breakpoint.
- Click OK.
Note: You can also set breakpoints in the Breakpoint List
, the
CPU window (and the
Disassembly view), the
Call Stack view, and the
Modules window.