Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)

1. Complete one of the following steps to preload the librtc runtime library:
Set the target application to preload librtc by using the +rtc option for the chatr
command.In addition to automatically loading the librtc library, the +rtc option for the
chatr command also maps the shared libraries as private. To enable or disable the
target application to preload the librtc runtime library, enter the following command
at the HP-UX prompt:
$ chatr +rtc <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 application, 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 <executable-name> <process-id>
On Itanium, starting from HP WDB 6.4 , when a process is attached, all the rtc settings in the
process, if any, get updated to gdb and you can continue debugging the memory without
needing to do the heap checking settings again. However, if there is any heap check settings
done in gdb before/after attach, that is, through -leaks command line option or .gdbinit
124 HP-UX Configuration-Specific Information