Configuring librcheck for Memory Analysis
QNX SDP8.0Programmer's GuideDeveloper
To start a program that uses librcheck and can send heap trace data to the Memory Analysis tool in the QNX Momentics IDE, you must preload the librcheck library and set environment variables to configure Memory Analysis options. Here, we give examples with minimal settings.
-
To start an application so the Memory Analysis tool can later be attached to the process from the IDE:
LD_PRELOAD=librcheck.so MALLOC_CTHREAD=1 MALLOC_FILE=/tmp/trace.rmat ./my_app
-
To start an application with allocations tracing so you can later do postmortem analysis:
LD_PRELOAD=librcheck.so MALLOC_FILE=/tmp/trace.rmat MALLOC_START_TRACING=1 ./my_app
-
To start an application with tracing initially disabled so you can use API controls to enable and disable tracing as the program runs:
LD_PRELOAD=librcheck.so MALLOC_FILE=/tmp/trace.rmat MALLOC_START_TRACING=0 ./my_app
-
To set the environment so all subsequent processes launched with Memory Analysis enabled have only memory errors logged:
export LD_PRELOAD=librcheck.so export MALLOC_FILE=/tmp/trace.rmat export MALLOC_TRUNCATE=1 ./my_app1 ./my_app2
-
To display a list of the environment variables for librcheck:
LD_PRELOAD=librcheck.so MALLOC_HELP=1 ./my_app
librcheck environment variables
The librcheck environment variables and their corresponding UI options in the
IDE (if any) are:
Environment variable | Where to find in Memory Analysis UI | What option to set | Additional information |
---|---|---|---|
LD_PRELOAD=librcheck.so | Advanced Settings | Runtime library | The library file is librcheck.so. |
MALLOC_ACTION=number | Memory Errors | When an error is detected | Set the error-handling action: 0 to ignore, 1 to abort, 2 to exit, 3 to core, 4 to stop. |
MALLOC_CKACCESS=0|1 | Memory Errors | Verify parameters in string and memory functions | Turn boundary checking on or off for string and memory functions. |
MALLOC_CKALLOC=0|1 | Memory Errors | Enable check on realloc()/free() argument | Enable or disable the checking that the pointers passed to realloc() and free() point to memory that the allocator manages. |
MALLOC_CTHREAD=0|1 | Advanced Settings | Create control thread | Don't start a control thread (0), or do start the thread and allow the IDE to send commands to the application through signals (1). |
MALLOC_CTRL_FILE=file | N/A | N/A | Specify a file for the control command (to use with the control signal). |
MALLOC_CTRL_SIG=sigs | N/A | N/A | Override the default signals; for example:
|
MALLOC_DUMP_LEAKS=0|1 | Memory Errors | Perform leak check when process exits | Enable or disable the dumping of leaks on exit. |
MALLOC_EVENTBTDEPTH=number | Memory Tracing | Limit back-trace depth to | Set the depth of allocation backtraces to a specific number. The default is 5. |
MALLOC_EVENTFILE=file | Advanced Settings | Target output file or device | Redirect the event output to a file. |
MALLOC_FILE=file | Advanced Settings | Target output file or device | Redirect the event and trace output to a file. Use a hyphen (-) to redirect the output to standard output (the default). |
MALLOC_HANDLE_SIGNALS=0|1 | N/A | N/A | Whether to install handlers for the SIGSEGV, SIGBUS, SIGILL, and SIGFPE signals. |
MALLOC_HELP=1 | N/A | N/A | Print a list of used environment variables. |
MALLOC_START_TRACING=0|1 | Memory Tracing | Enable memory allocation or deallocation tracing | Whether to automatically start tracing memory when the program starts. |
MALLOC_TRACEBTDEPTH=number | Memory Tracing | Limit back-trace depth to | Set the allocation backtraces depth to a specific number. |
MALLOC_TRACEMAX=number | Memory Tracing | Maximum allocation to trace | Only trace allocations of <= number of bytes. |
MALLOC_TRACEMIN=number | Memory Tracing | Minimum allocation to trace | Only trace allocations of >= number of bytes. |
MALLOC_TRUNCATE=0|1 | N/A | N/A | Whether to truncate the output files. |
MALLOC_VERBOSE=0|1 | Advanced Settings | Show debug output on console | A value of 1 makes the library send debug information to standard error. |
Page updated: