Philippe Waroquiers ce806ed31f (fixes bug 289939 wish: complete monitor cmd 'leak_check' with details
about leaked or reachable blocks)

This patch implements two new memcheck gdbserver monitor commands:
  block_list <loss_record_nr>
        after a leak search, shows the list of blocks of <loss_record_nr>
  who_points_at <addr> [<len>]
        shows places pointing inside <len> (default 1) bytes at <addr>
        (with len 1, only shows "start pointers" pointing exactly to <addr>,
         with len > 1, will also show "interior pointers")


Compiled and reg-tested on f12/x86, deb5/amd64, f16/ppc64.

The 'block_list' command is implemented on top of the 
lr_array/lc_chunks/lc_extras arrays used during the last leak search.
NB: no impact on the memory for the typical Valgrind usage where a leak
search is only done at the end of the run.
Printing the block_list of a loss record simply consists in scanning the
lc_chunks to find back the chunks corresponding to the loss record for which
block lists is requested.

The 'who_points_at' command is implemented by doing a scan similar to 
(but simpler than) the leak search scan.
lc_scan_memory has been enhanced to have a mode to search for a specific
address, rather than to search for all allocated blocks.
VG_(apply_to_GP_regs) has been enhanced to also provide the ThreadId and
register name in the callback function.

The patch touches multiple files (but most changes are easy/trivial or factorise
existing code).

Most significant changes are in memcheck/mc_leakcheck.c :
    * changed the LC_Extra struct to remember the clique for indirect leaks
      (size of structure not changed).
    * made lr_array a static global
    * changed lc_scan_memory:
        to have a search mode for a specific address (for who_points_at)
        (for leak search) to pass a 'current clique' in addition to the clique
         leader
         so as to have a proper clique hierarchy for indirectly leaked blocks.
    * print_results: reset values at the beginning of the print_result of the
      next leak search, rather than at the end of print_results of the previous
       leak search.
      This allows to continue showing the same info for loss records till a new
      leak search is done.
    * new function print_clique which recursively prints a group of leaked
      blocks, starting from the clique leader.
    * new function MC_(print_block_list) : calls print_clique for each clique
      leader found for the given loss record.
    * static void scan_memory_root_set : code extracted from
      MC_(detect_memory_leaks) (no relevant change)
    * void MC_(who_points_at) : calls scan_memory_root_set, lc_scan_memory
        and VG_(apply_to_GP_regs)(search_address_in_GP_reg) to search 
        pointers to the given address.



git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12357
2012-01-26 23:13:52 +00:00

121 lines
2.8 KiB
Makefile

include $(top_srcdir)/Makefile.tool-tests.am
dist_noinst_SCRIPTS = \
invoker simulate_control_c make_local_links \
filter_gdb filter_make_empty \
filter_memcheck_monitor filter_stderr filter_vgdb
EXTRA_DIST = \
README_DEVELOPERS \
mcblocklistsearch.stderr.exp \
mcblocklistsearch.stdinB.gdb \
mcblocklistsearch.vgtest \
mcblocklistsearch.stderrB.exp \
mcbreak.stderrB.exp \
mcbreak.stderr.exp \
mcbreak.stdinB.gdb \
mcbreak.stdoutB.exp \
mcbreak.stdout.exp \
mcbreak.vgtest \
mcclean_after_fork.stderrB.exp \
mcclean_after_fork.stderr.exp \
mcclean_after_fork.stdinB.gdb \
mcclean_after_fork.stdoutB.exp \
mcclean_after_fork.vgtest \
mchelp.stderrB.exp \
mchelp.stderr.exp \
mchelp.stdoutB.exp \
mchelp.vgtest \
mcinfcallRU.stderrB.exp \
mcinfcallRU.stderr.exp \
mcinfcallRU.stdinB.gdb \
mcinfcallRU.vgtest \
mcinfcallWSRU.stderrB.exp \
mcinfcallWSRU.stderr.exp \
mcinfcallWSRU.stdinB.gdb \
mcinfcallWSRU.vgtest \
mcinvokeRU.stderrB.exp \
mcinvokeRU.stderr.exp \
mcinvokeRU.stdoutB.exp \
mcinvokeRU.vgtest \
mcinvokeWS.stderrB.exp \
mcinvokeWS.stderr.exp \
mcinvokeWS.stdoutB.exp \
mcinvokeWS.vgtest \
mcleak.stderrB.exp \
mcleak.stderr.exp \
mcleak.stdinB.gdb \
mcleak.stdoutB.exp \
mcleak.vgtest \
mcmain_pic.stderrB.exp \
mcmain_pic.stderr.exp \
mcmain_pic.stdinB.gdb \
mcmain_pic.stdoutB.exp \
mcmain_pic.stdout.exp \
mcmain_pic.vgtest \
mcmain_pic.stderrB.exp \
mcmain_pic.stderr.exp \
mcmain_pic.stdinB.gdb \
mcmain_pic.stdoutB.exp \
mcmain_pic.stdout.exp \
mcsignopass.stderrB.exp \
mcsignopass.stderr.exp \
mcsignopass.stdinB.gdb \
mcsignopass.stdoutB.exp \
mcsignopass.vgtest \
mcsigpass.stderrB.exp \
mcsigpass.stderr.exp \
mcsigpass.stdinB.gdb \
mcsigpass.stdoutB.exp \
mcsigpass.vgtest \
mcvabits.stderrB.exp \
mcvabits.stderr.exp \
mcvabits.stdinB.gdb \
mcvabits.stdoutB.exp \
mcvabits.vgtest \
mcwatchpoints.stderrB.exp \
mcwatchpoints.stderr.exp \
mcwatchpoints.stdinB.gdb \
mcwatchpoints.stdoutB.exp \
mcwatchpoints.vgtest \
mssnapshot.stderrB.exp \
mssnapshot.stderr.exp \
mssnapshot.stdinB.gdb \
mssnapshot.stdoutB.exp \
mssnapshot.vgtest \
nlcontrolc.stderrB.exp \
nlcontrolc.stderr.exp \
nlcontrolc.stdinB.gdb \
nlcontrolc.stdoutB.exp \
nlcontrolc.vgtest \
nlfork_chain.stderr.exp \
nlfork_chain.stdout.exp \
nlfork_chain.vgtest \
nlpasssigalrm.vgtest \
nlpasssigalrm.stderrB.exp \
nlpasssigalrm.stderr.exp \
nlpasssigalrm.stdinB.gdb \
nlpasssigalrm.stdoutB.exp \
nlsigvgdb.vgtest \
nlsigvgdb.stderr.exp \
nlsigvgdb.stderrB.exp \
nlsigvgdb.stdinB.gdb
check_PROGRAMS = \
clean_after_fork \
fork_chain \
passsigalrm \
sleepers \
main_pic \
t \
watchpoints
AM_CFLAGS += $(AM_FLAG_M3264_PRI)
AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
LDADD = -lpthread
main_pic_LDFLAGS = -pie
main_pic_CFLAGS = $(AM_CFLAGS) -fPIC