Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
$ gdb high
HP gdb 5.6 for HP Itanium (32 or 64 bit) and target HP-UX 11.2x.
Copyright 1986 - 2001 Free Software Foundation, Inc.
Hewlett-Packard Wildebeest 5.5.8 (based on GDB) is covered
by the GNU General Public License. Type "show copying" to
see the conditions to change it and/or distribute copies.
Type "show warranty" for warranty/support.
..
(gdb) set heap-check on
(gdb) set heap-check high-mem-count 2
(gdb) r
Starting program: high
warning: High water mark
(address = 0x4044ff00 total memory per call site = 100)
#1 func2() at high.c:15
#2 main() at high.c:40
#3 main_opd_entry() from
warning: Use command backtrace (bt) to see the current context.
Ignore top 4 frames belonging to leak detection library of gdb.
__rtc_event (ecode=RTC_NO_ERROR, pointer=0x0, pclist=0x0, size=0)
at ../../../Src/gnu/gdb/infrtc.c:1236
1236 {
Monitoring De-allocations to Detect Double-Frees
The set heap-check free <on/off> command enables you to detect double-frees
and frees with improper arguments.
When this command is enabled, the free() calls are monitored to verify whether the
parameters address valid heap blocks. If an erroneous free() is detected, the debugger
stops execution and reports the error. You can analyze the stack trace to analyze where
and how the error occurred. Example 19 (page 97) illustrates the use of the set
heap-check free command.
Monitoring Heap Corruption
WDB enables you to detect the presence of heap-corruption in your application. Table 11
lists the commands for monitoring heap corruption
Memory-Debugging Features of WDB 45