Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)
Memory debugging restrictions
Programs with these attributes are not supported:
• CMA or DCE threaded programs on 11.x (32-bit and 64-bit)
• Memory checking features. These features work only in programs that directly or indirectly
call malloc, realloc, free, mmap, or munmap from the standard C library libc.sl.
• Programs that link the archive version of the standard C library, libc.a, or the core library,
libcl.a, on HP-UX 11.x
NOTE: Linker with version number B.11.19 or higher is required for debugging memory
problems.
• From HP WDB 5.7 onwards, the archive version of the run time check library, librtc.a, is
not available. You must use the shared version of the library, librtc.[sl|so], instead.
Memory Debugging Methodologies
HP WDB enables you to debug memory problems in applications written for HP-UX 11.x or later
using C, aC++, FORTRAN 77, and Fortran 90.
HP WDB provides several commands that help expose memory-related problems.
HP WDB offers the following memory-debugging capabilities:
• Reports memory leaks
• Reports heap allocation profile
• Reports open file descriptors. This is applicable only in batch mode.
• Stops program execution if bad writes occur with string operations such as strcpy and
memcpy
• Stops program execution when freeing unallocated or de-allocated blocks
• Stops program execution when freeing a block if bad writes occur outside block boundary
• Stops program execution conditionally based on whether a specified block address is allocated
or de-allocated
• Scrambles previous memory contents at malloc() and free() calls
• Simulates and detects out-of-memory event errors
• Detects dangling pointers and dangling blocks
• Detects in-block corruption of freed blocks
• Specifies the amount of guard bytes for every block of allocated memory
• Displays the run time type information for C++ polymorphic objects
You can use any of the following methods to identify memory problems:
• See “Debugging Memory in Interactive Mode” (page 113).
• See “Debugging Memory in Batch Mode” (page 117).
• See “Debugging Memory Interactively After Attaching to a Running Process” (page 123).
Debugging Memory in Interactive Mode
This section describes the various commands which help in debugging memory problems when
the debugger is used in the interactive mode.
Commands for interactive memory debugging
To debug memory problems, use these commands:
Debugging Memory Problems 113