Debug your application

In the IDE, the source-level debugger provides a debugging environment that's completely integrated with the other workbench tools, giving you the flexibility you need to debug your applications. For detailed information about debugging in the IDE, see Debug a program in the IDE.
To start the debugger:
  1. Right-click on your project in the Project Explorer view and select Debug As.
    Select one of the following:
    • BlackBerry Tablet OS C/C++ Application — Debug using an existing debug configuration for the selected project.
    • BlackBerry Tablet OS C/C++ Application Dialog — Open the Launch Configuration selection dialog from where you select a project, and then it opens the Debug configuration dialog to create, manage, and run your configurations.
    • Debug Configurations — Open the Debug Configurations dialog. From this dialog, you can create, manage, and run your configurations.
  2. In the Debug launch configuration dialog, select or create a BlackBerry Tablet OS launch configuration created for launching your BlackBerry Tablet OS C/C++ Application.
    • BlackBerry Tablet OS Attach To Running Process — For more information about attaching to a running process, see Debug by attaching to a process .
    • BlackBerry Tablet OS C/C++ Application — For more information about debugging your BlackaBerry Tablet OS application, see Debug a program in the IDE.
    • BlackBerry Tablet OS Postmortem Debugging — For more information about postmortem debugging, see Postmortem debugging .
    • BlackBerry Tablet OS Attach to Running Process — If you're connecting to your target 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 Launch Group type .
  3. At a minimum, on the Main tab, select the build configuration you intend to use for debugging your application.
    If the Debug button is not available, ensure that you have a project specified and that your build configuration you selected is valid for the selected project, and that it is connected.
  4. Click Debug to start the debugger.
    The IDE now switches to the Debug perspective and transfers your program from your development machine across the network to your simulator or device, and then starts it under the control of the debugger. You will see that the debugger stops in the first line of your program. In the Debug view, you'll see an overview of your process, including the call stack. Using the buttons in the main bar of the Debug view, you can control the debugger.

If you're using the Application Developer or System Developer profiles, you won't be able to debug the 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 unsigned the core OS/kernel, or replace signed RIM processes.

Using the Step Over button, you can 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, and you can, for example, 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 (described in the previous step) to start your program. Or create a new launch configuration and select the binary without debug information.