HP WDB GUI 5.8 Reference Manual ( February 2008 )

Debugging with WDB GUI
Debugging Memory Problems
Chapter 374
Debugging Memory Problems
WDB GUI provides support to debug memory-related errors.
Before debugging memory-related errors in a program, you must preload the librtc.[sl|so]
runtime library for the required program. You can use the LD_PRELOAD environment variable
or the +mem_check option for the chatr command to preload librtc.[sl|so].
To enable memory debugging, select Tools ->Memory Check. The Memory Check dialog
window is dynamically displayed. You can enter the memory checking preferences in this
window.
NOTE You must enable memory checking and data collection before running your
program in the debugger. Additionally, if you change memory checking and data
collection settings during a program run, you may need to rerun your program
for the new settings to take effect.
Following are the memory checking features, which can be enabled in the Memory Check
dialog window:
RTC heap corruption checks for calls to strcpy, memset,and memcpy
This feature supports the set heap-check string [on|off] command to validate calls
to string functions such as strcpy(), strncpy(), memcpy(), memmove(), memset(),
bzero(), and bcopy(). When this feature is enabled in the Memory Check dialog
window, the warnings are displayed in the command window.
Stop at free of an unallocated or deallocated block address.
Monitors bad calls to free() in the program. Bad calls to free() include freeing
addresses that have not been allocated or addresses that have been freed. When the
debugger detects a bad call to free(), it stops the program and reports the bad call in the
status bar at the bottom of the debugger window.
Stop when freeing a block if bad writes occurred outside block boundary
When bounds checking is turned on, WDB allocates extra space at the beginning and end
of a block during allocation and fills it up with a specific pattern. When blocks are freed,
WDB verifies whether these patterns are intact. If they are corrupted, it indicates an
underflow or and WDB reports the problem.
Scramble previous memory contents on malloc/free