Valgrind tells me function xxx allocated memory which was not freed. Fine. It's proving more difficult than usual to trace however.
To this end I have created numerous:
#ifdef DEBUG
fprintf(stderr, "something happening:%lx\n", (unsigned long)ptr);
#endif
So I just need to match these ptr addresses that are displayed with the addresses of non-freed memory.
How can I get valgrind to tell me the address of each non-freed block of memory?
I don't believe Memcheck's leak checker supports printing addresses, unfortunately. This is due to the fact it's willing to merge multiple unallocated blocks into one "loss report" if they're similar.
If you don't mind poking around in Memcheck, this functionality should be abled to be added in memcheck/mc_leakcheck.c in the Valgrind source. I'll take a look at it when I get home and post a more detailed location.
Thanks to Falaina for the code location.
For valgrind-3.2.3, location that worked for me was in memcheck/mc_leakcheck.c, lc_scan_memory_WRK function.
Added this after lc_markstack_push_WRK(addr, clique); on line # 472
if (clique != -1) { VG_(printf)("clique %d: %p\n", clique, ptr); }