blob: 783502839992bfed84391c7e7e96a4816d421f50 [file] [log] [blame]
njne43d3ae2003-05-05 13:04:49 +00001
njne43d3ae2003-05-05 13:04:49 +00002Building and not installing it
3~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
njne43d3ae2003-05-05 13:04:49 +00004
njn090dc842005-03-12 16:47:07 +00005To run Valgrind without having to install it, run coregrind/valgrind
sewardj45f4e7c2005-09-27 19:20:21 +00006with the VALGRIND_LIB environment variable set, where <dir> is the root
njn090dc842005-03-12 16:47:07 +00007of the source tree (and must be an absolute path). Eg:
8
sewardj45f4e7c2005-09-27 19:20:21 +00009 VALGRIND_LIB=~/grind/head4/.in_place ~/grind/head4/coregrind/valgrind
njne43d3ae2003-05-05 13:04:49 +000010
11This allows you to compile and run with "make" instead of "make install",
12saving you time.
13
14I recommend compiling with "make --quiet" to further reduce the amount of
15output spewed out during compilation, letting you actually see any errors,
16warnings, etc.
17
18
19Running the regression tests
20~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21To build and run all the regression tests, run "make [--quiet] regtest".
22
23To run a subset of the regression tests, execute:
24
25 perl tests/vg_regtest <name>
26
27where <name> is a directory (all tests within will be run) or a single
28.vgtest test file, or the name of a program which has a like-named .vgtest
29file. Eg:
30
31 perl tests/vg_regtest memcheck
32 perl tests/vg_regtest memcheck/tests/badfree.vgtest
33 perl tests/vg_regtest memcheck/tests/badfree
34
nethercote16b59ee2004-10-09 15:59:05 +000035
njn5359b6f2006-06-02 23:57:22 +000036Running the performance suite
37~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38To build and run the whole performance suite, run "make [--quiet] perf".
39
40To run a subset of the regression tests, execute:
41
42 perl perf/vg_perf <name>
43
44where <name> is a directory (all tests within will be run) or a single
45.vgperf test file, or the name of a program which has a like-named .vgperf
46file. Eg:
47
48 perl perf/vg_perf perf/
49 perl perf/vg_perf perf/bz2.vgperf
50 perl perf/vg_perf perf/bz2
51
52To compare multiple versions of Valgrind, use the --vg= options multiple
53times. For example, if you have two Valgrinds next to each other, one in
54trunk1/ and one in trunk2/, from either trunk1/ or trunk2/ do this to
55compare them on the entire suite:
56
57 perl perf/vg_perf --vg=../trunk1 --vg=../trunk2 perf/
58
59
nethercote16b59ee2004-10-09 15:59:05 +000060Debugging Valgrind with GDB
61~~~~~~~~~~~~~~~~~~~~~~~~~~~
tom4a5223b2005-11-17 12:31:12 +000062To debug the valgrind launcher program (<prefix>/bin/valgrind) just
63run it under gdb in the normal way.
nethercote4fffabd2004-11-02 09:13:12 +000064
tom4a5223b2005-11-17 12:31:12 +000065Debugging the main body of the valgrind code (and/or the code for
66a particular tool) requires a bit more trickery but can be achieved
67without too much problem by following these steps:
nethercote16b59ee2004-10-09 15:59:05 +000068
tom4a5223b2005-11-17 12:31:12 +000069(1) Set VALGRIND_LAUNCHER to <prefix>/bin/valgrind:
nethercote16b59ee2004-10-09 15:59:05 +000070
tom4a5223b2005-11-17 12:31:12 +000071 export VALGRIND_LAUNCHER=/usr/local/bin/valgrind
nethercote16b59ee2004-10-09 15:59:05 +000072
tom4a5223b2005-11-17 12:31:12 +000073(2) Run "gdb <prefix>/lib/valgrind/<platform>/<tool>":
nethercote16b59ee2004-10-09 15:59:05 +000074
tom4a5223b2005-11-17 12:31:12 +000075 gdb /usr/local/lib/valgrind/ppc32-linux/lackey
nethercote16b59ee2004-10-09 15:59:05 +000076
tom4a5223b2005-11-17 12:31:12 +000077(3) Do "handle SIGSEGV SIGILL nostop noprint" in GDB to prevent GDB from
78 stopping on a SIGSEGV or SIGILL:
79
80 (gdb) handle SIGILL SIGSEGV nostop noprint
81
82(4) Set any breakpoints you want and proceed as normal for gdb. The
83 macro VG_(FUNC) is expanded to vgPlain_FUNC, so If you want to set
84 a breakpoint VG_(do_exec), you could do like this in GDB:
85
86 (gdb) b vgPlain_do_exec
87
88(5) Run the tool with required options:
89
90 (gdb) run pwd
nethercote16b59ee2004-10-09 15:59:05 +000091
njn585b8b32005-10-10 11:36:55 +000092
93Self-hosting
94~~~~~~~~~~~~
95To run Valgrind under Valgrind:
96
97(1) Check out 2 trees, "inner" and "outer". "inner" runs the app
98 directly and is what you will be profiling. "outer" does the
99 profiling.
100
101(2) Configure inner with --enable-inner and build/install as
102 usual.
103
104(3) Configure outer normally and build/install as usual.
105
106(4) Choose a very simple program (date) and try
107
njn86d68072005-11-12 19:07:45 +0000108 outer/.../bin/valgrind --sim-hints=enable-outer --trace-children=yes \
njn585b8b32005-10-10 11:36:55 +0000109 --tool=cachegrind -v inner/.../bin/valgrind --tool=none -v prog
110
njn7cce5b82005-11-16 20:12:22 +0000111If you omit the --trace-children=yes, you'll only monitor inner's launcher
112program, not its stage2.
113
114The whole thing is fragile, confusing and slow, but it does work well enough
115for you to get some useful performance data. The inner Valgrind has most of
116its output (ie. those lines beginning with "==<pid>==") prefixed with a '>',
117which helps a lot.
njn15a65632005-10-10 11:43:14 +0000118
119At the time of writing the allocator is not annotated with client requests
120so Memcheck is not as useful as it could be. It also has not been tested
121much, so don't be surprised if you hit problems.
njn0dc09e82005-11-03 16:24:53 +0000122
weidendo10e80e32006-05-01 01:49:28 +0000123When using self-hosting with an outer callgrind tool, use '--pop-on-jump'
124(on the outer). Otherwise, callgrind has much higher memory requirements.
125
njn0b5efe72005-11-10 03:40:36 +0000126
njn0dc09e82005-11-03 16:24:53 +0000127Printing out problematic blocks
128~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129If you want to print out a disassembly of a particular block that
130causes a crash, do the following.
131
132Try running with "--vex-guest-chase-thresh=0 --trace-flags=10000000
133--trace-notbelow=999999". This should print one line for each block
134translated, and that includes the address.
135
136Then re-run with 999999 changed to the highest bb number shown.
137This will print the one line per block, and also will print a
138disassembly of the block in which the fault occurred.