Debugging Dynamic Memory Usage Errors Using HP WDB

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, it invokes the debugger to print the leak or heap data.
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>
Pre-loading the Appropriate Version of librtc.[sl.so] Along With the Application
The environment variable LD_PRELOAD must be configured to preload the appropriate version
of librtc.[sl.so] with the application. This variable must be configured for the batch, and
attach modes of debugging.
Set the environment variable, LD_PRELOAD as follows:
For 32-bit applications running on Itanium
LD_PRELOAD=/opt/langtools/lib/hpux32/librtc.sl <executable> <arguments>
For 64-bit applications running on Itanium
LD_PRELOAD=/opt/langtools/lib/hpux64/librtc.sl <executable> <arguments>
For 32-bit applications running on PA-RISC
LD_PRELOAD=/opt/langtools/lib/librtc.sl <executable> <arguments>
56