perf-archive.sh 1.3 KB

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