njn | e43d3ae | 2003-05-05 13:04:49 +0000 | [diff] [blame] | 1 | |
njn | e43d3ae | 2003-05-05 13:04:49 +0000 | [diff] [blame] | 2 | Building and not installing it |
| 3 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
njn | e43d3ae | 2003-05-05 13:04:49 +0000 | [diff] [blame] | 4 | |
njn | 090dc84 | 2005-03-12 16:47:07 +0000 | [diff] [blame] | 5 | To run Valgrind without having to install it, run coregrind/valgrind |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 6 | with the VALGRIND_LIB environment variable set, where <dir> is the root |
njn | 090dc84 | 2005-03-12 16:47:07 +0000 | [diff] [blame] | 7 | of the source tree (and must be an absolute path). Eg: |
| 8 | |
sewardj | 45f4e7c | 2005-09-27 19:20:21 +0000 | [diff] [blame] | 9 | VALGRIND_LIB=~/grind/head4/.in_place ~/grind/head4/coregrind/valgrind |
njn | e43d3ae | 2003-05-05 13:04:49 +0000 | [diff] [blame] | 10 | |
| 11 | This allows you to compile and run with "make" instead of "make install", |
| 12 | saving you time. |
| 13 | |
| 14 | I recommend compiling with "make --quiet" to further reduce the amount of |
| 15 | output spewed out during compilation, letting you actually see any errors, |
| 16 | warnings, etc. |
| 17 | |
| 18 | |
| 19 | Running the regression tests |
| 20 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 21 | To build and run all the regression tests, run "make [--quiet] regtest". |
| 22 | |
| 23 | To run a subset of the regression tests, execute: |
| 24 | |
| 25 | perl tests/vg_regtest <name> |
| 26 | |
| 27 | where <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 |
| 29 | file. 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 | |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 35 | |
njn | 5359b6f | 2006-06-02 23:57:22 +0000 | [diff] [blame^] | 36 | Running the performance suite |
| 37 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 38 | To build and run the whole performance suite, run "make [--quiet] perf". |
| 39 | |
| 40 | To run a subset of the regression tests, execute: |
| 41 | |
| 42 | perl perf/vg_perf <name> |
| 43 | |
| 44 | where <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 |
| 46 | file. Eg: |
| 47 | |
| 48 | perl perf/vg_perf perf/ |
| 49 | perl perf/vg_perf perf/bz2.vgperf |
| 50 | perl perf/vg_perf perf/bz2 |
| 51 | |
| 52 | To compare multiple versions of Valgrind, use the --vg= options multiple |
| 53 | times. For example, if you have two Valgrinds next to each other, one in |
| 54 | trunk1/ and one in trunk2/, from either trunk1/ or trunk2/ do this to |
| 55 | compare them on the entire suite: |
| 56 | |
| 57 | perl perf/vg_perf --vg=../trunk1 --vg=../trunk2 perf/ |
| 58 | |
| 59 | |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 60 | Debugging Valgrind with GDB |
| 61 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
tom | 4a5223b | 2005-11-17 12:31:12 +0000 | [diff] [blame] | 62 | To debug the valgrind launcher program (<prefix>/bin/valgrind) just |
| 63 | run it under gdb in the normal way. |
nethercote | 4fffabd | 2004-11-02 09:13:12 +0000 | [diff] [blame] | 64 | |
tom | 4a5223b | 2005-11-17 12:31:12 +0000 | [diff] [blame] | 65 | Debugging the main body of the valgrind code (and/or the code for |
| 66 | a particular tool) requires a bit more trickery but can be achieved |
| 67 | without too much problem by following these steps: |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 68 | |
tom | 4a5223b | 2005-11-17 12:31:12 +0000 | [diff] [blame] | 69 | (1) Set VALGRIND_LAUNCHER to <prefix>/bin/valgrind: |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 70 | |
tom | 4a5223b | 2005-11-17 12:31:12 +0000 | [diff] [blame] | 71 | export VALGRIND_LAUNCHER=/usr/local/bin/valgrind |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 72 | |
tom | 4a5223b | 2005-11-17 12:31:12 +0000 | [diff] [blame] | 73 | (2) Run "gdb <prefix>/lib/valgrind/<platform>/<tool>": |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 74 | |
tom | 4a5223b | 2005-11-17 12:31:12 +0000 | [diff] [blame] | 75 | gdb /usr/local/lib/valgrind/ppc32-linux/lackey |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 76 | |
tom | 4a5223b | 2005-11-17 12:31:12 +0000 | [diff] [blame] | 77 | (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 |
nethercote | 16b59ee | 2004-10-09 15:59:05 +0000 | [diff] [blame] | 91 | |
njn | 585b8b3 | 2005-10-10 11:36:55 +0000 | [diff] [blame] | 92 | |
| 93 | Self-hosting |
| 94 | ~~~~~~~~~~~~ |
| 95 | To 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 | |
njn | 86d6807 | 2005-11-12 19:07:45 +0000 | [diff] [blame] | 108 | outer/.../bin/valgrind --sim-hints=enable-outer --trace-children=yes \ |
njn | 585b8b3 | 2005-10-10 11:36:55 +0000 | [diff] [blame] | 109 | --tool=cachegrind -v inner/.../bin/valgrind --tool=none -v prog |
| 110 | |
njn | 7cce5b8 | 2005-11-16 20:12:22 +0000 | [diff] [blame] | 111 | If you omit the --trace-children=yes, you'll only monitor inner's launcher |
| 112 | program, not its stage2. |
| 113 | |
| 114 | The whole thing is fragile, confusing and slow, but it does work well enough |
| 115 | for you to get some useful performance data. The inner Valgrind has most of |
| 116 | its output (ie. those lines beginning with "==<pid>==") prefixed with a '>', |
| 117 | which helps a lot. |
njn | 15a6563 | 2005-10-10 11:43:14 +0000 | [diff] [blame] | 118 | |
| 119 | At the time of writing the allocator is not annotated with client requests |
| 120 | so Memcheck is not as useful as it could be. It also has not been tested |
| 121 | much, so don't be surprised if you hit problems. |
njn | 0dc09e8 | 2005-11-03 16:24:53 +0000 | [diff] [blame] | 122 | |
weidendo | 10e80e3 | 2006-05-01 01:49:28 +0000 | [diff] [blame] | 123 | When using self-hosting with an outer callgrind tool, use '--pop-on-jump' |
| 124 | (on the outer). Otherwise, callgrind has much higher memory requirements. |
| 125 | |
njn | 0b5efe7 | 2005-11-10 03:40:36 +0000 | [diff] [blame] | 126 | |
njn | 0dc09e8 | 2005-11-03 16:24:53 +0000 | [diff] [blame] | 127 | Printing out problematic blocks |
| 128 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 129 | If you want to print out a disassembly of a particular block that |
| 130 | causes a crash, do the following. |
| 131 | |
| 132 | Try running with "--vex-guest-chase-thresh=0 --trace-flags=10000000 |
| 133 | --trace-notbelow=999999". This should print one line for each block |
| 134 | translated, and that includes the address. |
| 135 | |
| 136 | Then re-run with 999999 changed to the highest bb number shown. |
| 137 | This will print the one line per block, and also will print a |
| 138 | disassembly of the block in which the fault occurred. |