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

Table 11 Commands for Monitoring Heap Corruption (continued)
DescriptionCommand
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.
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
info corruption
freed blocks if set heap-check
retain-freed-blocks is set to on.
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 38)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.
Memory-Debugging Features of WDB 37