perf-archive.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-2.0
  3. # perf archive
  4. # Arnaldo Carvalho de Melo <acme@redhat.com>
  5. PERF_DATA=perf.data
  6. if [ $# -ne 0 ] ; then
  7. PERF_DATA=$1
  8. fi
  9. #
  10. # PERF_BUILDID_DIR environment variable set by perf
  11. # path to buildid directory, default to $HOME/.debug
  12. #
  13. if [ -z $PERF_BUILDID_DIR ]; then
  14. PERF_BUILDID_DIR=~/.debug/
  15. else
  16. # append / to make substitutions work
  17. PERF_BUILDID_DIR=$PERF_BUILDID_DIR/
  18. fi
  19. BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
  20. NOBUILDID=0000000000000000000000000000000000000000
  21. perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS
  22. if [ ! -s $BUILDIDS ] ; then
  23. echo "perf archive: no build-ids found"
  24. rm $BUILDIDS || true
  25. exit 1
  26. fi
  27. MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
  28. PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/
  29. cut -d ' ' -f 1 $BUILDIDS | \
  30. while read build_id ; do
  31. linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
  32. filename=$(readlink -f $linkname)
  33. echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
  34. echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
  35. done
  36. tar cjf $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST
  37. rm $MANIFEST $BUILDIDS || true
  38. echo -e "Now please run:\n"
  39. echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n"
  40. echo "wherever you need to run 'perf report' on."
  41. exit 0