mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 16:54:20 +08:00
e3b6193378
If a '$PERF_BUILDID_DIR'(typically $HOME/.debug) is a symbolic link directory, cutting of the path will fail. Here is an example where a buildid directory is a symbolic link. / # ls -al /root lrwxrwxrwx 1 root root 13 Mar 26 2012 /root -> opt/home/root / # cd ~ /opt/home/root # perf record -a -g sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.322 MB perf.data (~14057 samples) ] /opt/home/root # perf archive tar: Removing leading `/' from member names Now please run: $ tar xvf perf.data.tar.bz2 -C ~/.debug wherever you need to run 'perf report' on. /opt/home/root # mkdir temp /opt/home/root # tar xf perf.data.tar.bz2 -C ./temp /opt/home/root # find ./temp -name "*kernel*" ./temp/opt/home/root/.debug/[kernel.kallsyms] -> If successfully cut off the path, [kernel.kallsyms] is located in top of the archived file. This patch enables to cut correctly even if the buildid directory is a symbolic link. Signed-off-by: Chanho Park <chanho61.park@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1333348109-12598-1-git-send-email-chanho61.park@samsung.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
48 lines
1.3 KiB
Bash
48 lines
1.3 KiB
Bash
#!/bin/bash
|
|
# perf archive
|
|
# Arnaldo Carvalho de Melo <acme@redhat.com>
|
|
|
|
PERF_DATA=perf.data
|
|
if [ $# -ne 0 ] ; then
|
|
PERF_DATA=$1
|
|
fi
|
|
|
|
#
|
|
# PERF_BUILDID_DIR environment variable set by perf
|
|
# path to buildid directory, default to $HOME/.debug
|
|
#
|
|
if [ -z $PERF_BUILDID_DIR ]; then
|
|
PERF_BUILDID_DIR=~/.debug/
|
|
else
|
|
# append / to make substitutions work
|
|
PERF_BUILDID_DIR=$PERF_BUILDID_DIR/
|
|
fi
|
|
|
|
BUILDIDS=$(mktemp /tmp/perf-archive-buildids.XXXXXX)
|
|
NOBUILDID=0000000000000000000000000000000000000000
|
|
|
|
perf buildid-list -i $PERF_DATA --with-hits | grep -v "^$NOBUILDID " > $BUILDIDS
|
|
if [ ! -s $BUILDIDS ] ; then
|
|
echo "perf archive: no build-ids found"
|
|
rm -f $BUILDIDS
|
|
exit 1
|
|
fi
|
|
|
|
MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
|
|
PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/
|
|
|
|
cut -d ' ' -f 1 $BUILDIDS | \
|
|
while read build_id ; do
|
|
linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
|
|
filename=$(readlink -f $linkname)
|
|
echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
|
|
echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
|
|
done
|
|
|
|
tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST
|
|
rm -f $MANIFEST $BUILDIDS
|
|
echo -e "Now please run:\n"
|
|
echo -e "$ tar xvf $PERF_DATA.tar.bz2 -C ~/.debug\n"
|
|
echo "wherever you need to run 'perf report' on."
|
|
exit 0
|