Use breakpoints

You set breakpoints on an executable line of code in your app. The debugging tool stops and suspends the app before the Momentics IDE for BlackBerry runs that line of code. Using breakpoints lets you access the app while it is stopped (for example, to examine variables).

Breakpoints override the debugging controls. For example, if you step over a function and the app hits a breakpoint, it pauses on that breakpoint even though it hasn't finished the function.

In the Debug perspective, the Breakpoints view lists all of the breakpoints that you set in your app.

Screen showing breakpoints in the Breakpoints view.

If the breakpoint is for a connected device or simulator, the Momentics IDE places a check mark on the icon (Breakpoint icon with a checkmark).

Add breakpoints

You can add a breakpoint in either the C/C++ or Debug perspective. For each breakpoint, you can add a condition to control whether your app stops.

  1. In the editor, open the file that you want to add the breakpoint to.
  2. You can add a breakpoint with or without a condition. Right-click the left edge of the editor beside the line of code where you want to add a breakpoint.
    • To add a breakpoint without a condition, select Toggle Breakpoint.
    • To add a breakpoint with a condition, select Add Breakpoint. In the Properties for C/C++ Line Breakpoint dialog box, in the Condition field, type the condition, and then click OK.

    A The Breakpoint icon in the left edge of the editor indicates that there is a breakpoint on that line of code. In the Breakpoints view, there is a corresponding The Breakpoint icon along with the file name.

    Screen showing a breakpoint in the Breakpoints view.

Add a condition to a breakpoint

You can add a condition to an existing breakpoint. The condition controls whether your app stops at the breakpoint. The app stops when it meets the condition that you set for the breakpoint. The condition is a Boolean expression that can be evaluated inside an if statement, such as x > y. The default value is TRUE.

  1. In the Breakpoints view, right-click a breakpoint, and then select Breakpoint Properties.

    Screen showing the Properties for C/C++ Line Breakpoint dialog box, where you can add a condition to a breakpoint.

  2. In the Properties for C/C++ Line Breakpoint dialog box, select the Enabled check box.
  3. In the Condition field, type the Boolean expression to evaluate.
  4. In the Ignore count field, type the number of times that the breakpoint can be hit before the condition is evaluated. It is not the number of times that the condition is true. The default is 0.
  5. To restrict the breakpoint to specific threads, click Filter on the left of the dialog box, and then select the threads.
  6. Click OK.

Import breakpoints

You can import breakpoints that you previously exported.

  1. On the File menu, click Import.
  2. In the Import dialog box, select Run/Debug > Breakpoints, and then click Next.
  3. Select the file that contains the breakpoints to import, and then click Finish. Screen showing the Import Breakpoints dialog box.

Set an action for a breakpoint

You can define one or more actions and then attach them to any breakpoint. When the debugging tool encounters the breakpoint, it performs the appropriate action. The actions that you can set include running a GDB command, playing a sound, logging a message, resuming execution, running an external tool, and reverse debugging.

Set actions for a specific breakpoint

You can create actions that apply to a specific breakpoint in your workspace.

  1. In the Breakpoints view, right-click a breakpoint, and then select Breakpoint Properties.
  2. On the left of the Properties for C/C++ Line Breakpoint dialog box, click Actions.

    Screen showing the breakpoint action options in the Properties for C/C++ Line Breakpoint dialog box.

  3. In the Available Actions area, click New to create an action.
  4. In the Action name field, type a name for the action.
  5. In the Action type drop-down list, select an action type. If you select the GDB Command Action action type, you must enter each GDB command on a separate line.
  6. Specify the corresponding behavior for the action, and then click OK.
  7. In the Available actions area, select an action, and then click Attach. The action is added to the selected breakpoint.
  8. To change the order in which the actions occur, use the Up and Down buttons in the Actions for this breakpoint area.
  9. Click Apply, and then click OK.

Create an action for any breakpoint

You can create actions that apply to all breakpoints in your workspace.

  1. On the Window menu, click Preferences.
  2. In the Preferences dialog box, select C/C++ > Debug > Breakpoint Actions.

    Screen showing the Breakpoint Actions options on the Preferences dialog box.

  3. Click New.
  4. In the New Breakpoint Action dialog box, in the Action name field, type a name for the action.
  5. In the Action type drop-down list, select an action type. If you select the GDB Command Action action type, you must type each GDB command on a separate line.
  6. Specify the corresponding behavior for the action, and then click OK.
  7. Click Apply, and then click OK.

Add event breakpoints

An event breakpoint is set on a specific event rather than a specific line of source code. You can set event breakpoints for exception caught and exception thrown events. You cannot set event breakpoints for these types of events: signal caught, stop on fork, stop on vfork, stop on exec, process exit, process start, end, library load and unload, and thread start, end, and join.

  1. In the Breakpoints view, on the toolbar, select Add Event Breakpoint (C/C++).

    Screen showing the event breakpoint options.

  2. In the Event Type drop-down list, click an event type.
  3. Click OK.

Disable breakpoints

You can disable a breakpoint temporarily without deleting it. You can also enable breakpoints that you previously disabled. You can disable individual breakpoints, or you can select multiple breakpoints and disable them at the same time.

  • To disable a single breakpoint, in the Breakpoints view, clear the check box beside the breakpoint.
  • To disable one or more breakpoints, in the Breakpoints view, select the breakpoints, right-click, and then select Disable.
  • To disable a breakpoint in the editor, right-click the breakpoint, and then select Disable Breakpoint.

Remove breakpoints

Select one or more breakpoints, right-click, and then select Remove or Remove All.

Last modified: 2014-11-17



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus