Debugging with GDB (February 2008)

Table Of Contents
136 Debugging with GDB
info leak leaknumber
Produces detailed information on the specified leak including the allocation call
stack.
set heap-check block-size num-bytes
Instructs WDB to stop the program whenever it tries to allocate a block larger
than num-bytes in size.
set heap-check heap-size num-size
Instructs WDB to stop the program whenever it tries to increase the program
heap by at least num-bytes.
min-heap-size
This option reports the heap allocations that exceed the specified number <num>
of bytes based on the cumulative number of bytes that are allocated at each
call-site, which is inclusive of multiple calls to malloc at a particular call site.
set heap-check watch address
Stops the program whenever a block at a specified address is allocated or deal-
located.
set heap-check null-check [N | random]
Force malloc to return NULL after N or random number of invocations of malloc.
Use set heap-check random-range N and set heap-check seed-value N to
define the seed value and range for random number calculation. Useful for
simulating out-of-memory situations.
set heap-check null-check-size N
Force malloc to return NULL after N bytes have been allocated by the program.
catch nomem
Allows the user to get control of an out-of-memory event. The user can step
through once the nomem event is caught to see whether the out-of-memory event
is handled correctly.
set heap-check free [on | off]
When set to on, forces WDB to stop the program when it detects a call to
free() with an improper argument, a call to realloc() that does not point to
a valid currently allocated heap block, or a call to free a block of memory, which
has been corrupted. Refer to ’set heap-check bounds’ for details on detecting
memory corruption.
set heap-check string [on | off]
Toggles validation of calls to strcpy, strncpy, memcpy, memccpy, memset,
memmove, bzero, and, bcopy. WDB 5.6 and later versions of the debugger
also validates calls to strcat and strncat.
set heap-check bounds [on | off]
Allocates extra space at the beginning and end of a heap block during alloca-
tion and fills it with a specific pattern. When blocks are freed, WDB verifies
whether these patterns are intact. If they are corrupted, an underflow or over-
flow must have occurred and WDB reports the problem. This option increases
the program’s memory requirements.