18c2ecf20Sopenharmony_ci#!/bin/bash 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 38c2ecf20Sopenharmony_ci# perf archive 48c2ecf20Sopenharmony_ci# Arnaldo Carvalho de Melo <acme@redhat.com> 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ciPERF_DATA=perf.data 78c2ecf20Sopenharmony_ciif [ $# -ne 0 ] ; then 88c2ecf20Sopenharmony_ci PERF_DATA=$1 98c2ecf20Sopenharmony_cifi 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci# 128c2ecf20Sopenharmony_ci# PERF_BUILDID_DIR environment variable set by perf 138c2ecf20Sopenharmony_ci# path to buildid directory, default to $HOME/.debug 148c2ecf20Sopenharmony_ci# 158c2ecf20Sopenharmony_ciif [ -z $PERF_BUILDID_DIR ]; then 168c2ecf20Sopenharmony_ci PERF_BUILDID_DIR=~/.debug/ 178c2ecf20Sopenharmony_cielse 188c2ecf20Sopenharmony_ci # append / to make substitutions work 198c2ecf20Sopenharmony_ci PERF_BUILDID_DIR=$PERF_BUILDID_DIR/ 208c2ecf20Sopenharmony_cifi 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciBUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX) 238c2ecf20Sopenharmony_ciNOBUILDID=0000000000000000000000000000000000000000 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciperf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS 268c2ecf20Sopenharmony_ciif [ ! -s $BUILDIDS ] ; then 278c2ecf20Sopenharmony_ci echo "perf archive: no build-ids found" 288c2ecf20Sopenharmony_ci rm $BUILDIDS || true 298c2ecf20Sopenharmony_ci exit 1 308c2ecf20Sopenharmony_cifi 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciMANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX) 338c2ecf20Sopenharmony_ciPERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_cicut -d ' ' -f 1 $BUILDIDS | \ 368c2ecf20Sopenharmony_ciwhile read build_id ; do 378c2ecf20Sopenharmony_ci linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2} 388c2ecf20Sopenharmony_ci filename=$(readlink -f $linkname) 398c2ecf20Sopenharmony_ci echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST 408c2ecf20Sopenharmony_ci echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST 418c2ecf20Sopenharmony_cidone 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_citar cjf $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST 448c2ecf20Sopenharmony_cirm $MANIFEST $BUILDIDS || true 458c2ecf20Sopenharmony_ciecho -e "Now please run:\n" 468c2ecf20Sopenharmony_ciecho -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n" 478c2ecf20Sopenharmony_ciecho "wherever you need to run 'perf report' on." 488c2ecf20Sopenharmony_ciexit 0 49