Debug a startup binary

Using the Debug perspective from the QNX Momentics IDE, you can debug the startup binary of the QNX Neutrino image created earlier.
To debug the startup binary:
  1. Change to the Debug perspective if it isn't currently open.

    The first thing you'll notice is that the target board has been automatically restarted. After waiting a certain number of seconds as specified in the Reset and Delay (seconds) checkbox on the Startup tab of the Debug launch configuration, the IDE will begin to upload the image to the target through the JTAG pins.

    After the image has been successfully uploaded, startup will commence until it hits a breakpoint.

    Once the IDE encounters a breakpoint, you'll see several things at once. In the top-left portion of the Debug perspective, you will see a stack trace for the current location of the code.

    In your debug results, it might appear to be more shallow than the stack traces that you would typically see because the code isn't running in a complicated environment, but directly on the hardware.

  2. You can also select the Variables tab to view the value of local and global variables for which symbols exist, and you'll see the Code view and Disassembly view. The Disassembly view will incorporate the source code into its display, allowing you to easily see which machine instructions correspond to which lines of code.
  3. In either the Code view or the Disassembly view, you can set and remove breakpoints by double-clicking on the margin. You can use the Step and Continue tools at the top of the screen to resume execution.

Once you've finished your debugging session, you should remove all breakpoints and click Continue to let startup finish booting up. A quick look at the serial console will show a fully-booted QNX Neutrino image.

Note:

Support for Mudflap has been removed in the upstream FSF gcc, and therefore future releases of the QNX Neutrino version of gcc won't support it either.

Mudflap provides runtime pointer checking capability to the GNU C/C++ compiler (gcc). It adds runtime error checking for pointers that are typically the cause for many programming errors in C and C++. Since Mudflap is included with the compiler, it doesn't require any additional tools in the tool chain, and it can be easily added to a build by specifying the necessary GCC options (see Options for Mudflap.)

Mudflap instruments all of the risky pointer and array dereferencing operations, some standard library string/heap functions, and some other associated constructs with range and validity tests. Instrumented modules will detect buffer overflows, invalid heap use, and some other classes of C/C++ programming errors. The instrumentation relies on a separate runtime library (libmudflap), which will be linked into a program when the compile option (-fmudflap) and linker option (-lmudflap) are provided for the build.