Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
Table 15 The config_strings Options for RTC_MALLOC_CONFIG
Descriptionconfig_string Options
RTC_NO_ABORT must not be set.
If abort_on_bounds is set to 1, the batch mode
aborts execution of the program and reports the
bounds condition, when bound checking fails.
abort_on_bounds=[01]
RTC_NO_ABORT must not be set.
If abort_on_bad_free is set to 1, the batch mode
aborts execution when a free(), or a realloc()
call attempts to free a heap object that is not valid.
abort_on_bad_free=[01]
RTC_NO_ABORT must not be set.
If abort_on_nomem is set to 1, the batch mode
aborts execution when an out-of-memory condition
is detected.
abort_on_nomem=[01]
The appropriate logfiles for the heap, leak, and
corruption detection are displayed on stderr. The
logfiles are directed to the specified file
<filename>. Output is appended to the file if the
+ option is used.
mem_logfile=stderr[+]filename
heap_logfile=stderr[+]filename
leak_logfile=stderr[+]filename
Printing Hexadecimal Address of Functions in Allocating Stack Traces Produced in Batch Mode
Heap or Leak Report
From librtc 6.1 onwards, export the environment variable RTC_PRINT_ADDR to 1
to enable printing of hexadecimal address of functions in allocating stack traces. By
default, the batch mode heap or leak report does not show the hexadecimal address for
allocating stack traces.
An example output without the hexadecimal address for allocating stack traces is as
shown below:
20 bytes leaked at 0x40070410 (0.12% of all bytes leaked) #0 allocateMemory() at memLeak.c:11
#1 createHeader() at memLeak.c:24
#2 createString() at memLeak.c:38
#3 compareStrings() at memLeak.c:83
An example output with the hexadecimal address for allocating stack traces, after
exporting RTC_PRINT_ADDR to 1 and running the application in batch mode again to
collect the heap or leak report is as shown below:
20 bytes leaked at 0x40070440 (0.12% of all bytes leaked) #0 0x4000e62 in allocateMemory() at
memLeak.c:11
#1 0x4000f62 in createHeader() at memLeak.c:24
#2 0x4001032 in createString() at memLeak.c:38
#3 0x40014a2 in compareStrings() at memLeak.c:83
To enable printing of hexadecimal address in interactive mode, use set print
address on command in the debugger before issuing the info heap or info leak
command.
66