Debugging Dynamic Memory Usage Errors Using HP WDB (5900-1474; WDB 6.2; January 2011)
Table 11 Commands for Monitoring Heap Corruption
DescriptionCommand
Toggles validation of calls to strcpy(),
strncpy(), memcpy(), memccpy(),memset(),
memmove(), bzero(), and, bcopy()
NOTE: HP WDB 6.0 and later versions of the
debugger improves performance of memory
debugging when the string option is set for 32-bit
applications on HP-UX 11i v2 and later Integrity
systems. However, the performance degrades for
64-bit applications on HP-UX 11i v2 and later
Integrity systems.
set heap-check string <on |off>
Toggles the bounds-checking feature for detection of
heap-corruption in WDB
set heap-check bounds <on|off>
Sets the Header guard for each block of the allocated
memory. The default number of bytes for the header
is 16 bytes if this option is not used.
set heap-check header-size <number of
bytes>
Sets the Footer guard for each block of the allocated
memory. The default number of bytes for the footer
is one byte if this option is not used.
set heap-check footer-size <number of
bytes>
Enables you to detect the dangling pointers and in
block corruption of freed blocks.
set heap-check retain-freed-blocks
<on/off>
Checks for corruption in the currently allocated heap
blocks. In addition, it lists the in-block corruptions in
the freed blocks if set heap-check
retain-freed-blocks is set to on.
info corruption
Displays a list of all the dangling pointers and
dangling blocks that are potential sources of memory
corruption.
info dangling
Scrambles a memory block and overwrites it with a
specific pattern when it is allocated and de-allocated
set heap-check scramble <on | off>
Monitoring String Corruption
The set heap-check string <on/off> command toggles the string corruption
detection feature. It enables you to detect string corruption if functions of the strcpy()
family write out-of-bounds of the allocated memory. Example 11 (page 47)illustrates the
use of the set heap-check string command.
This command currently detects string corruption when writing out-of-bounds for
strcpy(), strncpy(), memcpy(), memccpy(),memset(), memmove(), bzero(),
and, bcopy() functions.
46