Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # perf archive |
| 3 | # Arnaldo Carvalho de Melo <acme@redhat.com> |
| 4 | |
| 5 | PERF_DATA=perf.data |
| 6 | if [ $# -ne 0 ] ; then |
| 7 | PERF_DATA=$1 |
| 8 | fi |
| 9 | |
Stephane Eranian | 45de34b | 2010-06-01 21:25:01 +0200 | [diff] [blame] | 10 | # |
| 11 | # PERF_BUILDID_DIR environment variable set by perf |
| 12 | # path to buildid directory, default to $HOME/.debug |
| 13 | # |
| 14 | if [ -z $PERF_BUILDID_DIR ]; then |
| 15 | PERF_BUILDID_DIR=~/.debug/ |
| 16 | else |
| 17 | # append / to make substitutions work |
| 18 | PERF_BUILDID_DIR=$PERF_BUILDID_DIR/ |
| 19 | fi |
| 20 | |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 21 | BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX) |
Arnaldo Carvalho de Melo | 6630125 | 2010-03-02 15:25:38 -0300 | [diff] [blame] | 22 | NOBUILDID=0000000000000000000000000000000000000000 |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 23 | |
Arnaldo Carvalho de Melo | 6630125 | 2010-03-02 15:25:38 -0300 | [diff] [blame] | 24 | perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 25 | if [ ! -s $BUILDIDS ] ; then |
| 26 | echo "perf archive: no build-ids found" |
| 27 | rm -f $BUILDIDS |
| 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX) |
| 32 | |
| 33 | cut -d ' ' -f 1 $BUILDIDS | \ |
| 34 | while read build_id ; do |
Stephane Eranian | 45de34b | 2010-06-01 21:25:01 +0200 | [diff] [blame] | 35 | linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2} |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 36 | filename=$(readlink -f $linkname) |
Stephane Eranian | 45de34b | 2010-06-01 21:25:01 +0200 | [diff] [blame] | 37 | echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST |
| 38 | echo ${filename#$PERF_BUILDID_DIR} >> $MANIFEST |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 39 | done |
| 40 | |
Stephane Eranian | 45de34b | 2010-06-01 21:25:01 +0200 | [diff] [blame] | 41 | tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 42 | rm -f $MANIFEST $BUILDIDS |
Arnaldo Carvalho de Melo | 88978e5 | 2010-03-23 14:33:58 -0300 | [diff] [blame] | 43 | echo -e "Now please run:\n" |
| 44 | echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n" |
| 45 | echo "wherever you need to run 'perf report' on." |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 46 | exit 0 |