perf-archive.sh 1.2 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 -f $BUILDIDS
  24. exit 1
  25. fi
  26. MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
  27. cut -d ' ' -f 1 $BUILDIDS | \
  28. while read build_id ; do
  29. linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
  30. filename=$(readlink -f $linkname)
  31. echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
  32. echo ${filename#$PERF_BUILDID_DIR} >> $MANIFEST
  33. done
  34. tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST
  35. rm -f $MANIFEST $BUILDIDS
  36. echo -e "Now please run:\n"
  37. echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n"
  38. echo "wherever you need to run 'perf report' on."
  39. exit 0