Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)
or gdb prompt, the gdb settings override the process rtc settings. The latest settings in gdb get
synced up in the process rtc as well.
Use '-leaks' command line option when invoking gdb or set heap-check commands at gdb
prompt (before attaching to gdb) for PA-RISC and older versions of HP WDB on Itanium and
PA-RISC to enable heap checking on attach.
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 library, librtc.a, is
not available. You must use the shared version of the library, librtc.[sl|so], instead.
• From HP WDB Version 6.3 and later, you can configure rtcconfig file in attach mode
along with batch mode.
Debugging Memory using RTC APIs
Starting from HP WDB 6.4 , WDB provides a list of memory debugging APIs on HP integrity system,
which can be invoked within a C/C++ user application. With these APIs, you can obtain a report
that contains the list of leaks, allocated blocks and corrupted blocks in the heap at the point of the
API invocation. The report provides you the detail of the leaks, allocated and the corrupted heap
blocks, along with the corresponding stack traces in the application. These APIs also allow you to
enable or disable certain checks on the fly.
Calling RTC APIs from user application
You can automatically control memory error data collection and reporting by calling RTC APIs
from within your program. The following are the APIs currently supported:
To check data collection is running or not:
int rtc_running (void)
To enable data collection:
int rtc_enable (int which_check)
To disable memory debugging:
To report leaks information:
To report leaks information:
To report heap information:
To report corrupted heap information:
To set and unset redirecting the report to a specified log file:
To call RTC APIs from ANSI C and C++ programs, you should include the header file rtcapi.h,
available at /opt/langtools/wdb/include/ and link librtc library (should come first in the
linking compilation command).
Calling RTC APIs from wdb
You can do command-line calls for RTC APIs from wdb debugger.
(gdb) set heap-check on
.
.
.
(gdb) print rtc_running()
(gdb) print rtc_leaks(ALL)
(gdb) print rtc_heap()
Debugging Memory Problems 125