Debugging Dynamic Memory Usage Errors Using HP WDB (766161-001, March 2014)
Scanning for memory leaks...
420042 bytes leaked in 2 blocks
No. Total bytes Blocks Address Function
0 210021 1 0x405d2a30 fun()
1 210021 1 0x4059f5c0 fun()
NOTE:
Function name "???" implies that user has set min-leak-size; function names
are not fetched for leaks of smaller sizes for better performance.
(gdb) info dangling
Scanning for dangling blocks...
1024 bytes dangling in 1 blocks
No. Total bytes Blocks Address Function
0 1024 1 0x40639310 main()
NOTE:
Function name "???" implies that user has set min-leak-size; function names
are not fetched for leaks of smaller sizes for better performance.
Debugging in Attach Mode
WDB can attach to a running process and debug memory problems. However to use the debugger
in this mode, the application must be launched after preloading the librtc.[sl|so] runtime
library.
To debug memory on attaching GDB to a running process, complete the following steps:
1. You can setup the configuration file, rtcconfig for attach mode in the same way as batch
mode, although there is one difference. In attach mode, for configuration file to get processed,
the GDBRTC_CONFIG environment variable must be set to a non-NULL value. If the value is a
valid pathname of the configuration file (including the filename), that same configuration file
can be processed. However, if the value is an invalid path and is not NULL, the librtc
library searches for the rtcconfig configuration file at the following locations in the following
order:
1. Current working directory.
2. Home directory of the user if the environment variable $HOME is set.
3. Default rtcconfig configuration file provided under /opt/langtools/wdb/ (Installed
along with HP WDB Version 6.3 and later.)
Configuring rtcconfig file in attach mode enables the librtc library to collect data from
the start of application. In HP WDB Version 6.3 and later, you can configure rtcconfig
file in attach mode along with batch mode.
2. You can use the +rtc <enable|disable> option for the chatr command to automatically
preload librtc.[sl|so] or you can explicitly preload librtc.[sl|so] from the
appropriate path by using the LD_PRELOAD environment variable.
To preload the librtc.[sl|so] runtime library, complete one of the following steps:
• To automatically preload librtc.[sl|so] by using the +rtc <enable|disable>
for the chatr command, enter the following command at the HP-UX prompt:
$ chatr +rtc <enable> <executable>
Supported Modes of Memory-debugging in WDB 61