Building an executable for debugging

To debug an application, you must compile its executable for debugging. The executable binary then contains symbols that let the debugger match machine instructions with specific source code lines.

The IDE uses different icons to distinguish between executable variants:
  • a bug icon () for executables that contain debug symbols
  • a forward arrow icon () for those that don't contain symbols

Although you can debug regular (non-debug) executables, you have much more information and control by using debug variants of executables.

The QNX build tools (qcc and q++) use the same flag for adding debug symbols as the GDB tools (gcc and g++), namely, the -g option. For standard makefiles, which are used by C and C++ projects, you simply add this option to the debug compiler flags:
CCFLAGS_debug += -g -O0 -fno-builtin
To specify the -g option for a QNX C or QNX C++ project:
  1. In the Project Explorer view, right-click the project and select Properties.
  2. In the left pane, select QNX C/C++ Project.
  3. In the right pane, select the Build Variants tab.
  4. Under your selected build variants (i.e., architectures), make sure Debug is checked.
  5. Click OK.
  6. If you're not using the autobuild feature, rebuild your project manually.
For a QNX project, the filename for the debug variant of the executable has _g appended to it.