Debugging with GDB (February 2008)

Table Of Contents
138 Debugging with GDB
4. Set one or more breakpoints in the code where you want to examine cumulative leaks:
(gdb) b myfunction
5. Run the program in the debugger:
(gdb) run
6. Use the info command to show list of memory leaks:
(gdb) info leaks
Scanning for memory leaks...done
2439 bytes leaked in 25 blocks
No. Total bytes Blocks Address Function
0 1234 1 0x40419710 foo()
1 333 1 0x40410bf8 main()
2 245 8 0x40410838 strdup()
[...]
The debugger assigns each leak a numeric identifier.
7. To display a stack trace for a specific leak, use the info leak command and specify
the number from the list associated with a leak:
(gdb) info leak 2
245 bytes leaked in 8 blocks (10.05% of all bytes leaked)
These range in size from 26 to 36 bytes and are allocated
in strdup ()
in link_the_list () at test.c:55
in main () at test.c:13
in _start ()
14.10.5 Debugging Memory in Batch Mode
HP WDB supports batch mode memory leak detection, also called batch Run Time
Checking (Batch RTC). Most of the memory debugging features supported in interactive
mode are also supported in batch mode.
Note:
The batch mode commands may not always work when invoked through a
shell script.
14.10.5.1 Setting Configuration Options for Batch Mode
You can specify the batch mode configuration through a configuration file called
rtcconfig. The configuration file supports these variables: