|
From: Eric E. <eri...@fr...> - 2004-08-18 15:13:25
|
Patrick Ohly wrote: >>>perhaps I am missing something obvious, but >>>is there a possibility to print the address >>>of a memory block which was leaked in the >>>report of the leak? I'm using memcheck. > > Can you point me in the right direction so that (when > I find the time) I can provide a patch which does that? > Would that be accepted into valgrind mainline? I don't see why exactly you need the address of leaked blocks, except if: - your program logs additional information associated to the blocks when allocating them, e.g. for a web browser: block at 0xXYZ allocated when requesting doc http://xxx/zzz - you have a tool which consolidates the valgrind log with your custom log, so you can identify exactly the context in which your program triggered the leak In that case, it would be clever to add support for user data association to the blocks, probably through a valgrind user call. The pairs (key,value) associated with each block would be dumped directly in Valgrind log. That way the mechanism would be generic. This could also help tools like massif classifying the allocations based on user-defined contexts. Could you provide a detailed example (if different from what I supposed), so a generic way of solving that problem could be designed and implemented into Valgrind in the future ? For now, if you are in a hurry, you can have a look at memcheck/mac_leakcheck.c, and: - Add an address member in LossRecord structure - tweak MAC_(pp_LeakError) so as to print it - tweak MAC_(do_detect_memory_leaks): - do not compare blocks together - initialize the address in the LossRecord struct (But such a change is likely to be never accepted in Valgrind, since it is really kludgy !) Cheers -- Eric |