Debugging with GDB (September 2007)
144 Debugging with GDB
Step 5: Run the program as follows:
./exec1
Suppose exec1 eventually spawns exec2, exec3, exec4, exec5, only exec1,
exec2, exec3 will be instrumented based on the settings in the rtcconfig
file.
14.10.6 Debugging Memory Interactively After Attaching to a
Running Process
HP WDB accepts -pid or -p followed by a process ID to attach a running process to
the debugger.
To use Batch RTC after attaching GDB to a running process, complete the following
steps:
1. Complete one of the following steps to preload the librtc runtime library:
- Set the target application to preload librtc by using the +mem_check option
for the chatr command.In addition to automatically loading the librtc li-
brary, the +mem_check 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 +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 syste ms, 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>