|
| 1 | +#!/bin/bash |
| 2 | +# Parameters |
| 3 | +SRC=$1 |
| 4 | +TOOL='svf' |
| 5 | + |
| 6 | +DIR="${BASH_SOURCE%/*}" |
| 7 | +if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi |
| 8 | +. "$DIR/base_analyzer" |
| 9 | + |
| 10 | +prepare_env() { |
| 11 | + pip3 install setuptools |
| 12 | + pip3 install pydot gprof2dot |
| 13 | +} |
| 14 | + |
| 15 | +build() { |
| 16 | + printf "\n###Debug: build\n" |
| 17 | + echo "tool: dynamic" >> $DEST_PKG/report |
| 18 | + DEB_CFLAGS_SET="-fprofile-arcs -pg" DEB_CXXFLAGS_SET="-fprofile-arcs -pg" \ |
| 19 | + dpkg-buildpackage -b 2> error |
| 20 | + cp error $DEST_PKG/build.war |
| 21 | + echo "build: success" >> $DEST_PKG/report |
| 22 | +} |
| 23 | + |
| 24 | +analyze() { |
| 25 | + printf "\n###Debug: analyze\n" |
| 26 | + cd $PWD_SRC |
| 27 | + for bin in $(find . -type f -executable); do |
| 28 | + out=$(basename $bin) |
| 29 | + mkdir -p $DEST_PKG/$out |
| 30 | + if gprof $bin > profile.out; then |
| 31 | + if gprof2dot -f prof -o graph.dot profile.out; then |
| 32 | + dot2csv graph.dot $out.gprof.csv -p |
| 33 | + cp $out.gprof.csv $DEST_PKG/$out |
| 34 | + fi |
| 35 | + fi |
| 36 | + echo "" > temp123121 |
| 37 | + echo "#####################$bin##########################" |
| 38 | + echo "#####################$out##########################" |
| 39 | + valgrind --tool=callgrind --callgrind-out-file=./$out.txt $bin < temp123121 |
| 40 | + if [ -f $bin.txt ]; then |
| 41 | + echo "#####################11111111111111##########################" |
| 42 | + if gprof2dot -f callgrind -o graph.dot $out.txt; then |
| 43 | + echo "#####################22222222222222##########################" |
| 44 | + dot2csv graph.dot $out.callgrind.csv |
| 45 | + cp $out.callgrind.csv $DEST_PKG/$out |
| 46 | + fi |
| 47 | + fi |
| 48 | + done |
| 49 | +} |
| 50 | + |
| 51 | +main () { |
| 52 | + TOOL_DIR="$PWD_SRC/dynamic_data" |
| 53 | + init |
| 54 | + prepare_env |
| 55 | + build |
| 56 | + analyze |
| 57 | +} |
| 58 | + |
| 59 | +main |
| 60 | + |
| 61 | +exit 0 |
0 commit comments