RAD Studio (Common)
ContentsIndex
PreviousUpNext
Setting and Modifying Breakpoints

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 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 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 
Breakpoint in Code Editor  
The breakpoint is valid and enabled. The debugger is inactive.  
Breakpoint in debugger  
The breakpoint is valid and enabled. The debugger is active.  
Invalid breakpoint  
The breakpoint is invalid and enabled. The breakpoint is set at an invalid location, such as a comment, a blank line, or invalid declaration.  
Disabled breakpoint  
The breakpoint is valid and disabled. The debugger is inactive.  
Disabled breakpoint in debugger  
The breakpoint is valid and disabled. The debugger is active.  
Invalid breakpoint in debugger  
The breakpoint is invalid and disabled. The breakpoint is set at an invalid location.  
To set a source breakpoint

  1. 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.
  2. 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.
  3. 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.
  4. 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.
  5. To associate the source breakpoint with a breakpoint group, enter the name of a group or select from the Group dropdown list.
  6. 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

  1. Choose RunAdd BreakpointAddress Breakpoint to display the Add Address Breakpoint dialog box.
  2. In the Address field, enter the address in memory (such as $00011111) at which you want to set the breakpoint.
  3. 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.
  4. To specify that the address breakpoint will only fire after a number of passes, enter the number in the Pass count field.
  5. 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.
  6. 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

  1. The application must be running in debug mode (for example, use F9, F8, F7, or F4).
  2. Choose RunAdd BreakpointData Breakpoint to display the Add Data Breakpoint dialog box.
  3. In the Address field, enter the address of the data you want to function as the data breakpoint.
  4. 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.)
  5. 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.
  6. To specify that the breakpoint only fires after a number of passes, enter the number in the Pass count field.
  7. 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.
  8. 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

  1. Choose RunAdd BreakpointModule Load Breakpoint to display the Add Module Load Breakpoint dialog box.
  2. 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

  1. 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.
  2. 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.
  3. Click Help for more information about the options on the dialog box.
  4. Click OK.

To create a breakpoint group

  1. Open the Breakpoints List by choosing ViewDebug WindowsBreakpoints.
  2. Right-click the breakpoint and choose Breakpoint Properties.
  3. 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.
  4. Click OK.

To enable or disable a breakpoint or a breakpoint group

  1. 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.
  2. 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.
  3. 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

  1. Choose RunAdd Breakpoint and select the type of breakpoint you want from the submenu.
  2. Complete the fields in the dialog box as described in the procedure given earlier for that breakpoint type.
  3. 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.
  4. Complete other fields as appropriate.
  5. 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

  1. On the Breakpoint List, right-click the breakpoint and choose Breakpoint Properties.
  2. Click Advanced to display additional options.
  3. 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.
  4. Click OK.

To change the color of the text at the execution point or the color of breakpoints

  1. Choose ToolsOptionsEditor OptionsColor.
  2. In the code sample window, select the appropriate language tab. For example, to change the breakpoint color for Delphi code, select the Delphi tab.
  3. Scroll the code sample window to display the execution and breakpoint icons in the left gutter of the window.
  4. Click anywhere on the execution point or breakpoint line that you want to change.
  5. Use the Foreground Color and Background Color dropdown lists to change the colors associated with the selected execution point or breakpoint.
  6. 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.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!