blob: 95b6f8b6177a98e45bc295bf4096b753aab70696 [file] [log] [blame]
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -02001#!/bin/bash
2# perf archive
3# Arnaldo Carvalho de Melo <acme@redhat.com>
4
5PERF_DATA=perf.data
6if [ $# -ne 0 ] ; then
7 PERF_DATA=$1
8fi
9
Stephane Eranian45de34b2010-06-01 21:25:01 +020010#
11# PERF_BUILDID_DIR environment variable set by perf
12# path to buildid directory, default to $HOME/.debug
13#
14if [ -z $PERF_BUILDID_DIR ]; then
15 PERF_BUILDID_DIR=~/.debug/
16else
17 # append / to make substitutions work
18 PERF_BUILDID_DIR=$PERF_BUILDID_DIR/
19fi
20
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020021BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
Arnaldo Carvalho de Melo66301252010-03-02 15:25:38 -030022NOBUILDID=0000000000000000000000000000000000000000
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020023
Arnaldo Carvalho de Melo66301252010-03-02 15:25:38 -030024perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020025if [ ! -s $BUILDIDS ] ; then
26 echo "perf archive: no build-ids found"
27 rm -f $BUILDIDS
28 exit 1
29fi
30
31MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
Chanho Parke3b61932012-04-02 15:28:29 +090032PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020033
34cut -d ' ' -f 1 $BUILDIDS | \
35while read build_id ; do
Stephane Eranian45de34b2010-06-01 21:25:01 +020036 linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020037 filename=$(readlink -f $linkname)
Stephane Eranian45de34b2010-06-01 21:25:01 +020038 echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
Chanho Parke3b61932012-04-02 15:28:29 +090039 echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020040done
41
Stephane Eranian45de34b2010-06-01 21:25:01 +020042tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020043rm -f $MANIFEST $BUILDIDS
Arnaldo Carvalho de Melo88978e52010-03-23 14:33:58 -030044echo -e "Now please run:\n"
45echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n"
46echo "wherever you need to run 'perf report' on."
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020047exit 0