Debugging a Program in the IDE

Once you have successfully built your project, you're ready to debug it. Some debugging techniques that you might use include stepping through your code as it executes, stopping your program at various code points when specific conditions are met, and reviewing and changing your data.

The IDE supports the following types of debugging:

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

Note:

The IDE updates the views in the Debug perspective only when the program is suspended. 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.

Target debugging utilitites (qconn and pdebug)

The qconn utility provides information and performs tasks for the IDE. When you debug your app, you should have qconn running on your target and we recommend that it be running with root privilege (where the user ID is 0).

The pdebug utility is a debug agent that is the interface between the GDB/IDE and the process being debugged. Typically, qconn starts the pdebug utility as needed. It requires pseudo-terminals (ptys), i.e. devc-pty must be running, and it requires a shell (e.g. ksh ) to be available on the target system.

To use the Debug perspective, you must use executables that are compiled for debugging. These executables contain information that lets the debugger make associations between the source code and binaries. For information about compiling your program for debugging, see Build an executable for debugging.

Lazy binding

By default, lazy binding — the process by which symbol resolution isn't done until a symbol is actually used — is turned off ( pdebug sets LD_BIND_NOW to 1). Without LD_BIND_NOW, you'll see a different backtrace for the first function call into the shared object as the runtime linker resolves the symbol. You can prevent pdebug from setting LD_BIND_NOW by specifying the -l ("el") option. For more information about lazy binding, see the Compiling and Debugging chapter in the QNX Neutrino Programmer's Guide.