Test and Debug

In the Momentics IDE for BlackBerry, the source debugging tool provides a debugging environment that is integrated with the other workbench tools. It can debug multiprocess and multithreaded applications that are written in C, C++, QML, or JavaScript.

The debugging tool uses the GNU Debugger (GDB) as the underlying debugging tool.

The Debug view

In the Debug perspective, the Debug view shows the launch, debugging tool, and thread instance, as well as the stack frames and controls for each device that you debug on. It displays the debugging information in a tree hierarchy. It shows stack frames as child elements, and includes the reason for a suspension beside the thread. For example, a thread is suspended when it reaches the end of the stepping range, a breakpoint, or a received signal. When an app exits, the Momentics IDE also shows the exit code.

Screen showing the Debug view with debug sessions, running processes, threads, and call stacks.

The thread label includes the thread's state. For example, the label might indicate that the thread is suspended because the app hit a breakpoint. You can't suspend only one thread in a process; suspension affects all threads. The number beside the thread label is a reference counter for the Momentics IDE, not a thread ID (TID) number.

Editing your source after compiling causes the line numbering to be out of step because the debug information is tied directly to the source. Debugging an optimized binary can also cause unexpected jumps in the execution trace, especially when the debug symbols for that library aren't available and loaded.

Debug your app

When you debug using the toolbar, you select a launch configuration and a device to debug your app with. The Momentics IDE builds the app with the corresponding build configuration (either Device-Debug or Simulator-Debug), and then launches the app with the selected configuration. You don't need to build the app, configure the build configuration, or configure the launch configuration, because the Momentics IDE does it for you.

The debugging controls appear in the Debug view toolbar, the right-click context menu, and the Run menu.

  1. On the toolbar, select the Launch configuration for your app.
  2. In the Launch mode drop-down list, select Debug.
  3. In the Launch target drop-down list, select a device or simulator.

    To resolve any device connection issues, click Edit, and follow the instructions on the Device Properties dialog box.

    Screen showing the Launch Target drop-down list with the Edit icon, which opens the Device Properties dialog box.

  4. Click Momentics Launch button.

    The Momentics IDE changes to the Debug perspective, installs the app on your simulator or device, and starts the app under the control of the debugging tool. The debugging tool stops in the first line of your code and waits for your input.

  5. In the Debug view, select the thread that you want to control.
  6. To control the debugging tool, use the buttons in the Debug view toolbar.
  7. When you are finished debugging, on the Debug view toolbar, click The Terminate icon.

    You must terminate the debug session before you rebuild the project, or the build fails.

Control your debug session from the C/C++ editor

To control your debug session using the C/C++ editor, you allow the app to run until it hits the line that your cursor is on. If the app never hits that line, the app runs until it finishes or hits another breakpoint. You can use the context menu in the C/C++ editor to resume execution at a specific line or to add a watch expression.

The debugging tool controls the debugging session in the C/C++ editor.

  1. In the editor, select a file that is associated with the process that you are debugging.
  2. Click where you want to insert the cursor and interrupt the execution.
  3. Right-click near the cursor and select Run To Line, Resume at line, or Add watch expression.

    Run To Line works only in the current stack frame, which means that you can use it only within the function that is running.

Last modified: 2014-06-24



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

comments powered by Disqus