cachepc-linux

Fork of AMDESE/linux with modifications for CachePC side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-linux
Log | Files | Refs | README | LICENSE | sfeed.txt

perf-archive.sh (1272B)


      1#!/bin/bash
      2# SPDX-License-Identifier: GPL-2.0
      3# 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
     11#
     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
     22BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
     23
     24perf buildid-list -i $PERF_DATA --with-hits | grep -v "^ " > $BUILDIDS
     25if [ ! -s $BUILDIDS ] ; then
     26	echo "perf archive: no build-ids found"
     27	rm $BUILDIDS || true
     28	exit 1
     29fi
     30
     31MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
     32PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/
     33
     34cut -d ' ' -f 1 $BUILDIDS | \
     35while read build_id ; do
     36	linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
     37	filename=$(readlink -f $linkname)
     38	echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
     39	echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
     40done
     41
     42tar cjf $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST
     43rm $MANIFEST $BUILDIDS || true
     44echo -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."
     47exit 0