Debugging Dynamic Memory Usage Errors Using HP WDB (766161-001, March 2014)

Use the RTC application programming interface (API) for fine-grained control over the collection
and display of memory debugging data.
Output from RTC APIs is printed to the STDOUT or a user specified log- file.
Calling RTC APIs from user application
You can control run time memory checking data collection and its reporting, by calling RTC APIs
from within your program. The following are the available APIs:
int rtc_running (void);
int rtc_enable (int which_check);
int rtc_disable (int which_check);
int rtc_leaks (int new_or_all);
int rtc_heap (void);
int rtc_heap_corruption (void);
int rtc_logfile (char * log_file_name, int set_or_unset);
To call RTC APIs from HP ANSI C and C++ programs, you should include the header file rtcapi.h,
available at /opt/langtools/wdb/include/ in your code and link librtc library to your
application.
It should come first in the linking compilation command.
NOTE: HP recommends you to use RTC API mode independently and not to mix with batch,
attach or interactive modes. In general, do not mix different RTC modes, for better RTC reports.
Details of RTC APIs
# include <rtc-api.h>
This header file is located in the same directory where WDB is installed. Add the compiler option
-I/opt/langtool/wdb/include to your Makefile, if necessary.
int rtc_logfile (char * log_file_name, int set_or_unset)
Use this API to start or stop the redirection of printing of formatted output from RTC APIs to the
specified log file.
Parameters:
log_file_name - Path of the log file.
set_or_unset - can be one of the following values:
RTC_LOG_UNSET (0) : Stops redirecting the output of RTC APIs to the log file and output
redirected to STDOUT.
RTC_LOG_SET (1) : Redirects the output of RTC APIs to the log file.
Return Values:
0 indicates success.
-1 indicates error and error string printed to STDERR.
By default RTC APIs output is printed to STDOUT, unless user set the output redirection by calling
rtc_logfile() to redirect the output to the log-file. If the log-file is already present, the output is
appended at the end of the log file else new log file is created.
Before setting the output redirection to another file, user has to unset the output redirection to the
current log file and then set redirection to the new log file.
int rtc_leaks (int new_or_all)
Use this API to get leaks information in the running process. The report is printed on the STDOUT
or redirected to a user specified log-file.
Supported Modes of Memory-debugging in WDB 63