Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 1 | #!/bin/bash |
Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 2 | # SPDX-License-Identifier: GPL-2.0 |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 3 | # perf archive |
| 4 | # Arnaldo Carvalho de Melo <acme@redhat.com> |
| 5 | |
| 6 | PERF_DATA=perf.data |
| 7 | if [ $# -ne 0 ] ; then |
| 8 | PERF_DATA=$1 |
| 9 | fi |
| 10 | |
Stephane Eranian | 45de34b | 2010-06-01 21:25:01 +0200 | [diff] [blame] | 11 | # |
| 12 | # PERF_BUILDID_DIR environment variable set by perf |
| 13 | # path to buildid directory, default to $HOME/.debug |
| 14 | # |
| 15 | if [ -z $PERF_BUILDID_DIR ]; then |
| 16 | PERF_BUILDID_DIR=~/.debug/ |
| 17 | else |
| 18 | # append / to make substitutions work |
| 19 | PERF_BUILDID_DIR=$PERF_BUILDID_DIR/ |
| 20 | fi |
| 21 | |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 22 | BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX) |
| 23 | |
Nicholas Fraser | ec4d0a7 | 2021-02-19 11:09:32 -0500 | [diff] [blame] | 24 | perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " > $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" |
Irina Tirdea | 73eb422 | 2012-09-14 01:07:42 +0300 | [diff] [blame] | 27 | rm $BUILDIDS || true |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 28 | exit 1 |
| 29 | fi |
| 30 | |
| 31 | MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX) |
Chanho Park | e3b6193 | 2012-04-02 15:28:29 +0900 | [diff] [blame] | 32 | PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/ |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 33 | |
| 34 | cut -d ' ' -f 1 $BUILDIDS | \ |
| 35 | while read build_id ; do |
Stephane Eranian | 45de34b | 2010-06-01 21:25:01 +0200 | [diff] [blame] | 36 | 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] | 37 | filename=$(readlink -f $linkname) |
Stephane Eranian | 45de34b | 2010-06-01 21:25:01 +0200 | [diff] [blame] | 38 | echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST |
Chanho Park | e3b6193 | 2012-04-02 15:28:29 +0900 | [diff] [blame] | 39 | echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 40 | done |
| 41 | |
Irina Tirdea | 87ff50a | 2012-09-14 01:07:43 +0300 | [diff] [blame] | 42 | tar cjf $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST |
Irina Tirdea | 73eb422 | 2012-09-14 01:07:42 +0300 | [diff] [blame] | 43 | rm $MANIFEST $BUILDIDS || true |
Arnaldo Carvalho de Melo | 88978e5 | 2010-03-23 14:33:58 -0300 | [diff] [blame] | 44 | echo -e "Now please run:\n" |
| 45 | echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n" |
| 46 | echo "wherever you need to run 'perf report' on." |
Arnaldo Carvalho de Melo | 2c58517 | 2010-01-15 13:17:52 -0200 | [diff] [blame] | 47 | exit 0 |