Debugging Dynamic Memory Usage Errors Using HP WDB (766161-001, March 2014)

4. 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.
NOTE: The +mem_check <enable> option for the chatr command is available for
dynamic linker versions B.11.61 and later on HP 9000 systems, and dynamic linker versions
B.12.46 and later on Integrity systems.
The +rtc <enable> option for the chatr command is available for dynamic linker versions
B.11.66 and later on HP 9000 systems, and dynamic linker versions B.12.51 and later on
Integrity systems.
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 , which is different from the default path, you must use
the LD_PRELOAD environment variable.
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.
NOTE: If the application invokes calls such as system(3s), and popen(), which invoke
a new shell, librtc.[sl|so] must not be loaded to the invoked shell. You must use
LD_PRELOAD_ONCE, instead of LD_PRELOAD, to exclusively load thelibrtc.[sl|so] file
to the calling process only.
Following is the syntax for using LD_PRELOAD_ONCE:
LD_PRELOAD_ONCE = /opt/langtools/lib/librtc.sl
Example 16 (page 56) illustrates the batch mode debugging of the memtest.c program. The
debugging results are stored in memtest.8494.mem, memtest.8494.heap, and
memtest.8494.leaks.
Supported Modes of Memory-debugging in WDB 55