Test and Debug

In the Momentics IDE for BlackBerry, the source debugger 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++, or QML/JavaScript. You can debug programs simultaneously on one or multiple BlackBerry 10 devices or simulators.

The IDE debugger uses the GNU Debugger (GDB) as the underlying debug engine. The IDE debugger translates each GUI action into a sequence of GDB commands, and then processes the output from GDB to show the current state of the app that it is debugging.

Debug your app

When you debug using the toolbar button, the IDE builds the app with the build configuration for the device that you select (either Device-Debug or Simulator-Debug). It also creates the debug launch configuration.

  1. On the toolbar, in the Active Projects list, select your project.
  2. In the Active Device list, select the device that you want to use.
  3. In the Action list, click Debug.
  4. Click the Debug QNX Momentics 10.2 debug buttonbutton.

    The IDE switches to the Debug perspective, installs the app on your simulator or device, and starts your app under the control of the debugger. The Debug view provides an overview of your process, including the call stack. Use the Debug view toolbar to control the debugger.

Configure debugging for your app

Before you debug your app, you must build your app using the correct build configuration (either Device-Debug or Simulator-Debug), and create a debug launch configuration for the device that you want to build the application on. The debug build configuration adds debugging information into the application executable that lets the debugger make direct associations between the source code and the binaries that the original source generates.

  1. In the Project Explorer, right-click your project and select Debug As.
  2. Select one of the following:
    • BlackBerry C/C++ Application — Debug using an existing debug configuration for the selected project.
    • BlackBerry C/C++ Application Dialog — Open the Debug Configurations dialog box, where you select a project, and then create, manage, and run your configurations.
    • Debug Configurations — Open the Debug Configurations dialog. From this dialog, you can create, manage, and run your configurations.
  3. In the Debug Configurations dialog box, select or create a BlackBerry launch configuration created for launching your application.
    • BlackBerry Attach to Running Application
    • BlackBerry C/C++ Application .
    • BlackBerry Postmortem Debugging
    • BlackBerry Attach to Running Process — If you're connecting to your device by IP, select this configuration to connect to a remote process that is already running. This option lets you use the Application Profiler tool for profiling. Your target must be running qconn .
    • Launch Group — For more information about using launch groups, see .
  4. On the Main tab, select a Build configuration.
  5. Click Debug to start the debugger.

    The IDE switches to the Debug perspective and transfers your app from your development machine to your simulator or device, and then starts it under the control of the debugger. The debugger stops in the first line of your program. In the Debug view, you see an overview of your process, including the call stack. Use the buttons in the main bar of the Debug view to control the debugger.

If you're using the Application Developer or System Developer profiles, you won't be able to debug the BlackBerry 10 OS or other processes:

  • For external debugging, you can't debug BlackBerry and QNX processes, or debug the OS kernel.
  • You'll have access to only those processes of the third-party performing the debug tasks (authenticated access at the developer level).
  • To enable debugging, your user authentication is required on the device.
  • You can't run an unsigned process in the core OS/kernel, or replace signed BlackBerry processes.

Use the Step Over button to jump to the next line of code.

During debugging, you can watch the Variables view on the right, which displays how your variables change. You can use the Step Into button to let the debugger go into the code of a function (which, of course, is useful only if you have the source code for this function).

To set a breakpoint, place the mouse pointer over the left border of the source display, press the right mouse button and choose Toggle Breakpoint from the context menu. The breakpoint is shown as a little circle, which you can also set or remove while you write your code.

When a running program hits a breakpoint, it stops in the debugger. This allows you to access the program while it's stopped (for example, you can examine your variables). If you click the Resume button, your program continues until it hits the next breakpoint. To abort program execution, use the Terminate button. After the program has finished running, you can use the Remove All Terminated Launches button to clear all terminated launches from the Debug view.

The debugger keeps the project's files open while the program is running. Be sure to terminate the debug session before you try to rebuild your project, or else the build will fail.

To run your program as a standalone binary (without the debugger), open the dropdown menu beside the Run icon and choose Run Configurations...:

Then you can use the launch configuration gto start your program. Or create a new launch configuration and select the binary without debug information.

In the Project Explorer, the IDEuses an arrowhead icon for apps that weren't compiled for debugging, and a bug icon for apps that were.

Editing your source after compiling causes the line numbering to be out of step because the debug information is tied directly to the source. Similarly, debugging an optimized binary can also cause unexpected jumps in the execution trace.

Last modified: 2013-12-21

comments powered by Disqus