blob: 0cfb3e2cefef48bd630f0463469738f0c72692cc [file] [log] [blame]
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -02001#!/bin/bash
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01002# SPDX-License-Identifier: GPL-2.0
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -02003# perf archive
4# Arnaldo Carvalho de Melo <acme@redhat.com>
5
6PERF_DATA=perf.data
7if [ $# -ne 0 ] ; then
8 PERF_DATA=$1
9fi
10
Stephane Eranian45de34b2010-06-01 21:25:01 +020011#
12# PERF_BUILDID_DIR environment variable set by perf
13# path to buildid directory, default to $HOME/.debug
14#
15if [ -z $PERF_BUILDID_DIR ]; then
16 PERF_BUILDID_DIR=~/.debug/
17else
18 # append / to make substitutions work
19 PERF_BUILDID_DIR=$PERF_BUILDID_DIR/
20fi
21
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020022BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
Arnaldo Carvalho de Melo66301252010-03-02 15:25:38 -030023NOBUILDID=0000000000000000000000000000000000000000
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020024
Arnaldo Carvalho de Melo66301252010-03-02 15:25:38 -030025perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020026if [ ! -s $BUILDIDS ] ; then
27 echo "perf archive: no build-ids found"
Irina Tirdea73eb4222012-09-14 01:07:42 +030028 rm $BUILDIDS || true
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020029 exit 1
30fi
31
32MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
Chanho Parke3b61932012-04-02 15:28:29 +090033PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020034
35cut -d ' ' -f 1 $BUILDIDS | \
36while read build_id ; do
Stephane Eranian45de34b2010-06-01 21:25:01 +020037 linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020038 filename=$(readlink -f $linkname)
Stephane Eranian45de34b2010-06-01 21:25:01 +020039 echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
Chanho Parke3b61932012-04-02 15:28:29 +090040 echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020041done
42
Irina Tirdea87ff50a2012-09-14 01:07:43 +030043tar cjf $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST
Irina Tirdea73eb4222012-09-14 01:07:42 +030044rm $MANIFEST $BUILDIDS || true
Arnaldo Carvalho de Melo88978e52010-03-23 14:33:58 -030045echo -e "Now please run:\n"
46echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n"
47echo "wherever you need to run 'perf report' on."
Arnaldo Carvalho de Melo2c585172010-01-15 13:17:52 -020048exit 0