Debugging with GDB (February 2008)

Table Of Contents
144 Debugging with GDB
- Preload the librtc runtime library, as follows: LD_
PRELOAD=/opt/langtools/lib/hpux32/librtc.so <executable>
<arguments if any>
(Or)
- Preload the librtc runtime library, as follows: $ chatr +mem_check
enable <executable>
Example from Integrity Systems: Example-2
Step 1: Compile the source files.
Step 2: The rtcconfig file should contain entries such as the following:
check_heap=on
check_leaks=on
check_free=on
files=exec1:exec2:exec3
output_dir=/tmp/results
Step 3: Set the following environment variables as follows:
export BATCH_RTC=on
Step 4: Complete one of the following steps:
- Use the +mem_check option for the chatr command on each of the re-
quired executable files that must be instrumented, as follows:
$ chatr +mem_check enable exec1 exec2 exec3
(Or)
- Preload the librtc library as follows:
export LD_PRELOAD /opt/langtools/lib/hpux32/librtc.so
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.