When I run valgrind --leak-check=yes on a program, a few bytes of lost memory are reported. Is it possible to view the contents of this memory (i.e. dump the data that is stored in it)?
When I run valgrind –leak-check=yes on a program, a few bytes of lost memory
Share
You can do that with the last version of Valgrind (3.8.1):
Start your executable activating the gdbserver at startup:
Then in another window, connect a gdb to Valgrind (following the indications
given by Valgrind).
Then put a breakpoint at a relevant place (e.g. at the end of main)
and use the gdb
command till the breakpoint is reached.
Then do a leak search from gdb:
Then list the address(es) of the reachable blocks of the relevant loss record nr
You can then use gdb features to examine the memory of the given address(es).
Note also the potentially interesting command “who_points_at”
if you are searching who has kept a pointer to this memory.