File: profile.sh

package info (click to toggle)
bart-cuda 0.8.00-2
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm, sid
  • size: 7,752 kB
  • sloc: ansic: 100,267; python: 717; makefile: 576; sh: 564; cpp: 104
file content (70 lines) | stat: -rw-r--r-- 1,193 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/sh
set -e

usage="Usage: $0 <input.log> <output.log>"

helpstr=$(cat <<- EOF
Postprocess debugging output from BART to extract profiling
information and to translate pointer values to symbol names.

-h help
EOF
)


while getopts "h" opt; do
        case $opt in
	h)
		echo "$usage"
		echo
		echo "$helpstr"
		exit 0
	;;
        \?)
		echo "$usage" >&2
		exit 1
        ;;
        esac
done

shift $((OPTIND - 1))


if [ $# -lt 2 ] ; then

	echo "$usage" >&2
	exit 1
fi

in=$(readlink -f "$1")
out=$(readlink -f "$2")

if [ ! -e $input ] ; then
        echo "Input file does not exist." >&2
        echo "$usage" >&2
        exit 1
fi

if [ ! -e $TOOLBOX_PATH/bart ] ; then
        echo "\$TOOLBOX_PATH is not set correctly!" >&2
        exit 1
fi

#WORKDIR=$(mktemp -d)
# Mac: http://unix.stackexchange.com/questions/30091/fix-or-alternative-for-mktemp-in-os-x
WORKDIR=`mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir'`
trap 'rm -rf "$WORKDIR"' EXIT
cd $WORKDIR


nm --defined-only $TOOLBOX_PATH/bart | cut -c11-16,19- | sort > bart.syms


cat $in	| grep "^TRACE" \
	| grep " 0x" \
	| cut -c7-23,25-31,34- \
	| sort -k3 \
	| join -11 -23 bart.syms - \
	| cut -c8- \
	| sort -k2 > $out