Setting a conditional breakpoint

Conditional breakpoints have properties assigned to test for conditions that must be satisfied to trigger the breakpoint. For example, you can:

Conditional breakpoints can be very intrusive and lower the performance if they are hit frequently. This is because the debugger stops the target every time the breakpoint triggers. The specified condition is checked and if it evaluates to true then the target remains in the stopped state, otherwise execution resumes.

Note

You must not assign a script to a breakpoint that has sub-breakpoints. If you do, the debugger attempts to execute the script for each sub-breakpoint. If this happens, an error message is displayed.

You can assign conditions to an existing breakpoint in the Breakpoint Properties dialog box:

  1. In the Breakpoints view, right-click on the breakpoint that you want modify to display the context menu.

  2. Select Properties... to display the Breakpoint Properties dialog box.

  3. If you want to set a conditional expression for a specific breakpoint then enter a C-style expression in the Stop Condition field. For example, if your application has a variable x, then you can specify:

    x == 10

  4. If you want the debugger to delay hitting the breakpoint until a specific number of passes has occurred, then enter the number of passes in the Ignore Count field. For example, if you have a loop that performs 100 iterations, and you want a breakpoint in that loop to be hit after 50 passes, then enter 50.

  5. If you want to run a script when the selected breakpoint is triggered then specify the script file in the On break, run script field:

    • enter the location and file name in the field provided

    • click on File System... to locate the file in an external directory from the workspace

    • click on Workspace... to locate the file in a project directory or sub-directory within the workspace.

    Note

    Take care with the commands used in a script file that is attached to a breakpoint. For example, if the script file contains the quit command, the debugger disconnects from the target when the breakpoint is hit.

  6. If you want to enable the debugger to automatically continue running the application on completion of all the breakpoint actions then select the Continue Execution checkbox.

    Alternatively you can enter the continue command as the last command in a script file, that is attached to a breakpoint.

  7. If you want to set a breakpoint in one or more threads or processors:

    1. Select Break on Selected Threads or Cores to enable the selection panel.

    2. Select the checkbox for each thread or processor that you want to assign the breakpoint to.

  8. Click OK to save the changes.

Figure 9. Setting a conditional breakpoint

Setting a conditional breakpoint

Breakpoints that are set on a single line of source code with multiple statements are assigned as sub-breakpoints to a parent breakpoint. You can enable, disable, and view the properties of each sub-breakpoint in the same way as a single statement breakpoint. Conditions are assigned to top level breakpoints only and therefore affect both the parent breakpoint and sub-breakpoints.

Show/hideConsiderations when setting multiple conditions on a breakpoint

Be aware of the following when setting multiple conditions on a breakpoint:

  • If you set a Stop Condition and an Ignore Count, then the Ignore Count is not decremented until the Stop Condition is met. For example, you might have a breakpoint in a loop that is controlled by the variable c and has 10 iterations .If you set the Stop Condition c==5 and the Ignore Count to 3, then the breakpoint might not activate until it has been hit with c==5 for the fourth time. It subsequently activates every time it is hit with c==5.

  • If you choose to break on selected thread or processor, then the Stop Condition and Ignore Count are checked only for the selected thread or processor.

  • Conditions are evaluated in the following order:

    1. thread or processor

    2. condition

    3. ignore count.

Show/hideSee also

Copyright © 2010, 2011 ARM. All rights reserved.ARM DUI 0446H
Non-ConfidentialID111711