Root/tools/perf/perf-archive.sh

Source at commit ec7cab4cbb721bff91ec924ec691efd8daf36579 created 9 years 7 months ago.
By Maarten ter Huurne, MIPS: JZ4740: A320: Updated quickstart documentation.
1#!/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
10#
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
21BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
22NOBUILDID=0000000000000000000000000000000000000000
23
24perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS
25if [ ! -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)
32
33cut -d ' ' -f 1 $BUILDIDS | \
34while read build_id ; do
35    linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
36    filename=$(readlink -f $linkname)
37    echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
38    echo ${filename#$PERF_BUILDID_DIR} >> $MANIFEST
39done
40
41tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST
42rm -f $MANIFEST $BUILDIDS
43echo -e "Now please run:\n"
44echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n"
45echo "wherever you need to run 'perf report' on."
46exit 0
47

Archive Download this file



interactive