Debugging with GDB (February 2008)

Table Of Contents
Chapter 14: HP-UX Configuration-Specific Information 145
To enable or disable the target application to preload the librtc runtime
library, enter the following command at the HP-UX prompt:
$ chatr +mem_check <enable|disable> <executable>
Note: To attach and find leaks for PA-32 applications from the startup, the
environment variable RTC_INIT should be set to on in addition to preloading
the librtc.[sl|so] library before starting the application, as follows:
$ RTC_INIT=on <executable>
(Or)
- Instead of automatically preloading librtc and mapping the shared libraries,
you can explicitly preload the required librtc library.
In the case of HP 9000 systems, you must explicitly map the share libraries as
private by using the +dbg enable option for the chatr command, as follows:
$ chatr +dbg enable ./<executable> (This step is not required on Integrity
systems.)
To explicitly preload the librtc runtime library and start the target applica-
tion, enter one of the following commands:
- For 32 bit IPF applications,
LD_PRELOAD=/opt/langtools/lib/hpux32/librtc.so <executable>
- For 64 bit IPF applications,
LD_PRELOAD=/opt/langtools/lib/hpux64/librtc.so <executable>
- For 32 bit PA applications,
LD_PRELOAD=/opt/langtools/lib/librtc.sl <executable>
- For 64-bit PA applications,
LD_PRELOAD=/opt/langtools/lib/pa20_64/librtc.sl <executable>
Note: To attach and find leaks for PA-32 applications from the startup, the
environment variable RTC_INIT should be set to on in addition to preloading
the librtc.[sl|so] library before starting the application, as follows:
$ LD_PRELOAD=/opt/langtools/lib/librtc.sl RTC_INIT=on <application>
If RTC_INIT is turned on, librtc starts recording heap information for PA32
process, by default. Hence, you must set this environment variable only when
it is required, and you must not export this environment variable for shell.
2. Run the program.
3. Start a debugging session as follows:
gdb -leaks <executable-name> <process-id>
4. Use info heap and info leaks commands to obtain a memory analysis report of
the application.
Note: From HP WDB 5.7 onwards, the archive version of the run time check li-
brary, librtc.a, is not available. You must use the shared version of the library,
librtc.[sl|so], instead.