From ebe11593f213c58cbc17872f1ba998cd436a52ed Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Wed, 1 May 2002 01:25:45 +0000 Subject: [PATCH] Build and install 'cachegrind' along with 'valgrind'. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@181 --- Makefile.am | 2 +- addrcheck/Makefile.am | 2 +- cachegrind.in | 135 +++++++++++++++++++++++++++++++++++++++++ cachegrind/Makefile.am | 2 +- configure.in | 1 + corecheck/Makefile.am | 2 +- coregrind/Makefile.am | 2 +- coregrind/vg_main.c | 17 ++++-- helgrind/Makefile.am | 2 +- lackey/Makefile.am | 2 +- memcheck/Makefile.am | 2 +- none/Makefile.am | 2 +- vg_main.c | 17 ++++-- 13 files changed, 169 insertions(+), 19 deletions(-) create mode 100755 cachegrind.in diff --git a/Makefile.am b/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/addrcheck/Makefile.am b/addrcheck/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/addrcheck/Makefile.am +++ b/addrcheck/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/cachegrind.in b/cachegrind.in new file mode 100755 index 0000000000..aafdbac2cd --- /dev/null +++ b/cachegrind.in @@ -0,0 +1,135 @@ +#!/bin/sh +# Should point to the installation directory +prefix="@prefix@" +exec_prefix="@exec_prefix@" +VALGRIND="@libdir@/valgrind" + + +# Other stuff ... +version="@VERSION@" +emailto="jseward@acm.org" + +# name we were invoked with +vgname=`echo $0 | sed 's,^.*/,,'` + +# Cachegrind options +vgopts= + +# Prog and arg to run +argopts= + +# Show usage info? +dousage=0 + +# show version info? +doversion=0 + +# Collect up args for Cachegrind +while [ $+ != 0 ] +do + arg=$1 + case "$arg" in +# options for the user + --help) dousage=1; break;; + --version) doversion=1; break;; + --logfile-fd=*) vgopts="$vgopts $arg"; shift;; + -v) vgopts="$vgopts $arg"; shift;; + --verbose) vgopts="$vgopts -v"; shift;; + -q) vgopts="$vgopts $arg"; shift;; + --quiet) vgopts="$vgopts $arg"; shift;; + --demangle=no) vgopts="$vgopts $arg"; shift;; + --demangle=yes) vgopts="$vgopts $arg"; shift;; + --trace-children=no) vgopts="$vgopts $arg"; shift;; + --trace-children=yes) vgopts="$vgopts $arg"; shift;; + --suppressions=*) vgopts="$vgopts $arg"; shift;; +# options for debugging Cachegrind + --sanity-level=*) vgopts="$vgopts $arg"; shift;; + --single-step=yes) vgopts="$vgopts $arg"; shift;; + --single-step=no) vgopts="$vgopts $arg"; shift;; + --optimise=yes) vgopts="$vgopts $arg"; shift;; + --optimise=no) vgopts="$vgopts $arg"; shift;; + --instrument=yes) vgopts="$vgopts $arg"; shift;; + --instrument=no) vgopts="$vgopts $arg"; shift;; + --cleanup=yes) vgopts="$vgopts $arg"; shift;; + --cleanup=no) vgopts="$vgopts $arg"; shift;; + --smc-check=none) vgopts="$vgopts $arg"; shift;; + --smc-check=some) vgopts="$vgopts $arg"; shift;; + --smc-check=all) vgopts="$vgopts $arg"; shift;; + --trace-syscalls=yes) vgopts="$vgopts $arg"; shift;; + --trace-syscalls=no) vgopts="$vgopts $arg"; shift;; + --trace-signals=yes) vgopts="$vgopts $arg"; shift;; + --trace-signals=no) vgopts="$vgopts $arg"; shift;; + --trace-symtab=yes) vgopts="$vgopts $arg"; shift;; + --trace-symtab=no) vgopts="$vgopts $arg"; shift;; + --trace-malloc=yes) vgopts="$vgopts $arg"; shift;; + --trace-malloc=no) vgopts="$vgopts $arg"; shift;; + --trace-sched=yes) vgopts="$vgopts $arg"; shift;; + --trace-sched=no) vgopts="$vgopts $arg"; shift;; + --trace-pthread=none) vgopts="$vgopts $arg"; shift;; + --trace-pthread=some) vgopts="$vgopts $arg"; shift;; + --trace-pthread=all) vgopts="$vgopts $arg"; shift;; + --stop-after=*) vgopts="$vgopts $arg"; shift;; + --dump-error=*) vgopts="$vgopts $arg"; shift;; + -*) dousage=1; break;; + *) break;; + esac +done + +if [ z"$doversion" = z1 ]; then + echo "cachegrind-$version" + exit 1 +fi + +if [ $# = 0 ] || [ z"$dousage" = z1 ]; then + echo + echo "usage: $vgname [options] prog-and-args" + echo + echo " options for the user, with defaults in [ ], are:" + echo " --help show this message" + echo " --version show version" + echo " -q --quiet run silently; only print error msgs" + echo " -v --verbose be more verbose, incl counts of errors" + echo " --demangle=no|yes automatically demangle C++ names? [yes]" + echo " --trace-children=no|yes Cachegrind-ise child processes? [no]" + echo " --logfile-fd= file descriptor for messages [2=stderr]" + echo " --suppressions= is ignored" + echo + echo " options for debugging Cachegrind itself are:" + echo " --sanity-level= level of sanity checking to do [1]" + echo " --single-step=no|yes translate each instr separately? [no]" + echo " --optimise=no|yes improve intermediate code? [yes]" + echo " --instrument=no|yes actually do memory checks? [yes]" + echo " --cleanup=no|yes improve after instrumentation? [yes]" + echo " --smc-check=none|some|all check writes for s-m-c? [some]" + echo " --trace-syscalls=no|yes show all system calls? [no]" + echo " --trace-signals=no|yes show signal handling details? [no]" + echo " --trace-symtab=no|yes show symbol table details? [no]" + echo " --trace-malloc=no|yes show client malloc details? [no]" + echo " --trace-sched=no|yes show thread scheduler details? [no]" + echo " --trace-pthread=none|some|all show pthread event details? [no]" + echo " --stop-after= switch to real CPU after executing" + echo " basic blocks [infinity]" + echo " --dump-error= show translation for basic block" + echo " associated with 'th" + echo " error context [0=don't show any]" + echo + echo " Extra options are read from env variable \$CACHEGRIND_OPTS" + echo + echo " Valgrind is Copyright (C) 2000-2002 Julian Seward" + echo " and licensed under the GNU General Public License, version 2." + echo " Bug reports, feedback, admiration, abuse, etc, to: $emailto." + echo + exit 1 +fi + + +VG_ARGS="$CACHEGRIND_OPTS $vgsupp $vgopts --cachesim=yes" +export VG_ARGS +LD_LIBRARY_PATH=$VALGRIND:$LD_LIBRARY_PATH +export LD_LIBRARY_PATH +LD_PRELOAD=valgrind.so:$LD_PRELOAD +export LD_PRELOAD +#LD_DEBUG=files +#LD_DEBUG=symbols +#export LD_DEBUG +exec "$@" diff --git a/cachegrind/Makefile.am b/cachegrind/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/cachegrind/Makefile.am +++ b/cachegrind/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/configure.in b/configure.in index 76c947ad07..a65c4cde7e 100644 --- a/configure.in +++ b/configure.in @@ -251,6 +251,7 @@ AC_OUTPUT( vg_cachegen valgrind valgrind.spec + cachegrind Makefile docs/Makefile tests/Makefile diff --git a/corecheck/Makefile.am b/corecheck/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/corecheck/Makefile.am +++ b/corecheck/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/coregrind/Makefile.am b/coregrind/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/coregrind/Makefile.am +++ b/coregrind/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/coregrind/vg_main.c b/coregrind/vg_main.c index ee875e226b..3fbaca8706 100644 --- a/coregrind/vg_main.c +++ b/coregrind/vg_main.c @@ -840,10 +840,17 @@ static void process_cmd_line_options ( void ) VG_(clo_instrument) = False; } - if (VG_(clo_verbosity > 0)) - VG_(message)(Vg_UserMsg, - "valgrind-%s, a memory error detector for x86 GNU/Linux.", - VERSION); + if (VG_(clo_verbosity > 0)) { + if (VG_(clo_cachesim)) { + VG_(message)(Vg_UserMsg, + "cachegrind-%s, an I1/D1/L2 cache profiler for x86 GNU/Linux.", + VERSION); + } else { + VG_(message)(Vg_UserMsg, + "valgrind-%s, a memory error detector for x86 GNU/Linux.", + VERSION); + } + } if (VG_(clo_verbosity > 0)) VG_(message)(Vg_UserMsg, @@ -855,7 +862,7 @@ static void process_cmd_line_options ( void ) } } - if (VG_(clo_n_suppressions) == 0) { + if (VG_(clo_n_suppressions) == 0 && !VG_(clo_cachesim)) { config_error("No error-suppression files were specified."); } } diff --git a/helgrind/Makefile.am b/helgrind/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/helgrind/Makefile.am +++ b/helgrind/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/lackey/Makefile.am b/lackey/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/lackey/Makefile.am +++ b/lackey/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/memcheck/Makefile.am b/memcheck/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/memcheck/Makefile.am +++ b/memcheck/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/none/Makefile.am b/none/Makefile.am index 7086d48297..e6e58a8dcd 100644 --- a/none/Makefile.am +++ b/none/Makefile.am @@ -8,7 +8,7 @@ LDFLAGS = -Wl,-z -Wl,initfirst INCLUDES = -I$(srcdir)/demangle -bin_SCRIPTS = valgrind vg_annotate vg_cachegen +bin_SCRIPTS = valgrind cachegrind vg_annotate vg_cachegen SUPP_FILES = glibc-2.1.supp glibc-2.2.supp xfree-3.supp xfree-4.supp diff --git a/vg_main.c b/vg_main.c index ee875e226b..3fbaca8706 100644 --- a/vg_main.c +++ b/vg_main.c @@ -840,10 +840,17 @@ static void process_cmd_line_options ( void ) VG_(clo_instrument) = False; } - if (VG_(clo_verbosity > 0)) - VG_(message)(Vg_UserMsg, - "valgrind-%s, a memory error detector for x86 GNU/Linux.", - VERSION); + if (VG_(clo_verbosity > 0)) { + if (VG_(clo_cachesim)) { + VG_(message)(Vg_UserMsg, + "cachegrind-%s, an I1/D1/L2 cache profiler for x86 GNU/Linux.", + VERSION); + } else { + VG_(message)(Vg_UserMsg, + "valgrind-%s, a memory error detector for x86 GNU/Linux.", + VERSION); + } + } if (VG_(clo_verbosity > 0)) VG_(message)(Vg_UserMsg, @@ -855,7 +862,7 @@ static void process_cmd_line_options ( void ) } } - if (VG_(clo_n_suppressions) == 0) { + if (VG_(clo_n_suppressions) == 0 && !VG_(clo_cachesim)) { config_error("No error-suppression files were specified."); } } -- 2.47.3