Debugging Dynamic Memory Usage Errors Using HP WDB (766161-001, March 2014)
NOTE: To enable or disable multiple checks in a single call at a time, user can OR the values.
For example:
rtc_enable (RTC_CHECK_HEAP | RTC_CHECK_BOUNDS | RTC_CHECK_STRING );
The above single rtc_enable() call will enable heap check, bounds check and string check
at a time.
int rtc_running (void)
Use this API to enquire if the RTC is running or not.
Return values:
• 1 indicates RTC is running
• 0 indicates RTC is not running
Example 27 (page 90) illustrates how to use RTC APIs in HP C/C++ programs.
Memory-debugging without prior preparation
From Version WDB-6.5 and later, HP WDB on HP Integrity systems, supports basic leak or heap
memory reporting of a running process without making it mandatory for the users to preload the
librtc library before invoking the application (which was a necessity until now). This feature in
conjunction with the nudge triggered memory report generation (introduced in WDB 6.4 release)
empowers the users to obtain memory reports at any point in time during execution of a process
without any prior preparation or environmental settings.
Following HP WDB command helps in turning the dynamic-rtc feature ON/OFF:
set dynamic-rtc [on/off]
Corresponding show command provides the present status.
The following steps provide information on how basic heap or leak reports can be obtained without
prior preparation:
1. Attach HP WDB to the running process. Turn on the dynamic-rtc feature and detach or
quit WDB:
a. Attach WDB to the process.
$ gdb -q -p 10764
Attaching to process 10764
...
b. Turn on the dynamic-rtc feature
(gdb) set dynamic-rtc on
To check if the dynamic-rtc feature is turned on:
(gdb) show dynamic-rtc
Dynamic run time memory checking is on.
c. Detach or quit WDB:
(gdb) q
The program is running. Quit anyway (and detach it)? (y or n) y
Detaching from program: /user/xyz/…/test-case, process 10764
Once the debugger is detached, the application resumes execution. The next memory allocation
or de-allocation call from the application causes libc to load librtc into the memory.
Memory-debugging without prior preparation 65