Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
1. 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>
NOTE: To preload from a path that is different from the default paths, you
must use the LD_PRELOAD environment variable.
• Instead of automatically preloading librtc and mapping the shared libraries,
you can explicitly preload the required librtc library.
Set the environment variable, LD_PRELOAD as follows:
◦ For 32-bit applications running on Itanium,
LD_PRELOAD=/opt/langtools/lib/hpux32/librtc.so <executable> <arguments>
◦ For 64-bit applications running on Itanium,
LD_PRELOAD=/opt/langtools/lib/hpux64/librtc.so <executable> <arguments>
◦ For 32-bit applications running on PA-RISC,
LD_PRELOAD=/opt/langtools/lib/librtc.sl <executable> <arguments>
◦ For 64-bit applications running on PA-RISC,
LD_PRELOAD=/opt/langtools/lib/pa20_64/librtc.sl <executable> <arguments>
If LD_PRELOAD and chatr +rtc are used to preload the librtc.[sl|so]
runtime library, librtc[sl|so] is loaded from the path specified by
LD_PRELOAD.
2. Identify the required process (using the ps command) and attach the debugger to
the process as follows.
gdb -leaks <executable-name> <process-id>
3. Insert breakpoints at suitable probe-points. When the breakpoints trigger, use the
info heap and info leaks commands to display the heap and leak profile.
74