ROOTPWA
amplitude/test/runValgrind.sh
Go to the documentation of this file.
1 #!/bin/bash
2 ##########################################################################
3 #
4 # Copyright 2010
5 #
6 # This file is part of rootpwa
7 #
8 # rootpwa is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12 #
13 # rootpwa is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with rootpwa. If not, see <http://www.gnu.org/licenses/>.
20 #
21 ##########################################################################
22 #-------------------------------------------------------------------------
23 # File and Version Information:
24 # $Rev:: $: revision of last commit
25 # $Author:: $: author of last commit
26 # $Date:: $: date of last commit
27 #
28 # Description:
29 # runs a program with various valgrind tools
30 #
31 #
32 # Author List:
33 # Boris Grube TUM (original author)
34 #
35 #
36 #-------------------------------------------------------------------------
37 
38 
39 echo ">>> info: called ${0} ${*}"
40 
41 
42 #VALGRIND_TOOL="memcheck"
43 VALGRIND_TOOL="callgrind"
44 
45 PROGRAM="../../build/bin/calcAmplitudes"
46 PROGRAM_OPT="-n 200000 -k 1-4++1+f21270_32_pi-.key -p ./particleDataTable.txt -o 1-4++1+f21270_32_pi-.amp /dev/shm/allBins.ps.noTarget.root"
47 #PROGRAM="../debugBuild/bin/testLibppFunctions"
48 #PROGRAM_OPT=""
49 
50 LOG_FILE="./"$(basename ${PROGRAM})"_${VALGRIND_TOOL}.log"
51 OUT_FILE="./"$(basename ${PROGRAM})"_${VALGRIND_TOOL}.out"
52 
53 
54 echo ">>> info: ${0} started on $(date)"
55 echo ">>> info: running valgrind tool ${VALGRIND_TOOL} on '${PROGRAM}'"
56 echo
57 
58 # prepare command line
59 case ${VALGRIND_TOOL} in
60  "memcheck") # run memcheck tool
61  VALGRIND_OPT="--leak-check=full --suppressions=${ROOTSYS}/etc/valgrind-root.supp --show-reachable=yes --track-origins=yes --freelist-vol=100000000 --verbose"
62  ;;
63  "callgrind") # run callgrind tool
64  #!!! callgrind segfaults when demangling Boost symbols
65  #!!! workaround by disabling demangling and running c++filt as an afterburner
66  #!!! see http://bugs.kde.org/show_bug.cgi?id=197988
67  VALGRIND_OPT="--tool=callgrind --simulate-cache=yes --cacheuse=yes --demangle=no --callgrind-out-file=${OUT_FILE} --verbose"
68  ;;
69  *)
70  echo "!!! error: unknown valgrind tool ${VALGRIND_TOOL}. exiting."
71  exit 1
72  ;;
73 esac
74 
75 # do it
76 CMD="valgrind ${VALGRIND_OPT} ${PROGRAM} ${PROGRAM_OPT} &> ${LOG_FILE}"
77 echo "${CMD}"
78 time eval ${CMD}
79 echo
80 
81 # demangle symbols in callgrind output
82 if [[ ${VALGRIND_TOOL} = "callgrind" && -f "${OUT_FILE}" ]]
83 then
84  c++filt < ${OUT_FILE} > ${OUT_FILE}.demangled
85 fi
86 
87 echo ">>> info: ${0} finished on $(date)"
88 exit 0