Running memory-analyzing tools from the command line

Updated: October 26, 2022

You can run the same tool used by Memory Analysis as well as any Valgrind tool from the command line, outside of QNX Momentics IDE. This is handy for analyzing applications during system startup or when there's no network connection to the target.

Running an application with librcheck

The Memory Analysis tool in the IDE displays the data produced by the debug allocation library, librcheck, which is implemented separately from the tool. From the command line, you can launch an application with librcheck loaded. You must also set some environment variables to enable Memory Analysis; for information on doing so, see the Using the librcheck library section in the Programmer's Guide.

To view the memory data generated by librcheck, you must either attach the Memory Analysis tool to one of the application's processes or wait until the application exits and then copy the trace file from the target to the host and import it into the IDE. Although the trace file is text-based, its contents are too cryptic to read manually; the IDE is the only practical way to view librcheck data.

Running a Valgrind tool on an application

You can issue a command that tells Valgrind to run Massif, Memcheck, or Helgrind on the specified application with certain options and environment variables. For examples of such command lines, see the valgrind entry in the Utilities Reference.

To see backtrace information (i.e., source file names and line numbers) in the analysis results, you must provide Valgrind with an application binary and libraries that contain debug symbols, or with access to the debug symbols in separate .sym files. In the latter case, the symbol files must be kept in the same directory as the libraries (and binary); using LD_LIBRARY_PATH won't work because Valgrind doesn't use the dynamic loader.

The symbol files for SDP components delivered as libraries (e.g., audio drivers, networking protocols, video capture) are available from the QNX Software Center. Some component packages contain the stripped libraries and the debug symbol files. For others, there's a separate package for the symbols. Typically, symbol packages are automatically installed (if you've kept the default QNX Software Center settings), but you should confirm that the symbols that you need have been installed. For more information, see the QNX Software Center User's Guide, available from the QNX download center (http://www.qnx.com/download).

Valgrind produces a log file when it finishes executing the program. To see the analysis results, you must copy the log file from the target to the host, then import it into the IDE. Although the log file is somewhat readable, we recommend viewing the results in the IDE because it presents them in a more readable way and lets you navigate to the related source code.