Debugging Dynamic Memory Usage Errors Using HP WDB v6.3 (5900-2181, August 2012)

2. To activate the memory debugging, perform either of the following:
Invoke WDB with the -leaks option as follows:
$ gdb -leaks <executable>
This enables leak checking. To enable other memory debugging features you must use
the appropriate set of commands.
Alternatively, enter the following command at the gdb prompt:
$ gdb <executable>
(gdb)set heap-check on
This enables leaks checking, bounds checking, and check for double-frees.
3. Place breakpoints at probe points by entering the following command:
(gdb)b <probe_point>
4. To generate a leak profile at the breakpoint, enter the following command:
(gdb)info leaks <filename>
5. To generate a snapshot heap profile at the breakpoint, enter the following command:
(gdb) info heap <filename>
Debugging in Batch Mode
In this mode, the user does not interactively issue commands in a debugger session. Instead, the
memory-debugging commands are stored in a user-specified configuration file. The configuration
file gets processed during the run of the application and at the end of the program the debugger
creates output data files for that run. It creates three separate output files for leak profile, heap
profile, and the memory corruption reports.
Batch mode memory-debugging stops the application at the end of the program when exit() is
called or when all the statically linked libraries (including librtc.[sl|so]) are unloaded. After
the application is stopped, librtc invokes the debugger to print the leak or heap data.
NOTE: On Itanium systems, librtc from version 6.1 and later does not invoke the debugger
to print the leak or heap data. Librtc versions prior to 6.1 invokes the debugger to print the leak
or heap data after the application is stopped.
Following is the naming convention for the output files:
<file_name>.<pid>.<suffix>
Where:
<pid> is the process id and <suffix> can be either leaks, heap, or mem based on the type
of report.
For example: memtest.8494.mem
Environment Variables for Batch Memory-Debugging
This section discusses the environment variables that must be set for using the batch mode of memory
debugging.
Enabling and Disabling Batch Mode Memory-Debugging
The environment variable, BATCH_RTC, must be configured to enable and disable batch mode
memory-debugging.
Following is the syntax for enabling and disabling batch mode debugging:
export BATCH_RTC=<on/off>
Supported Modes of Memory-debugging in WDB 49