Skip to content

Commit e3b6193

Browse files
cometzeroacmel
authored andcommitted
perf archive: Correct cutting of symbolic link
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 <[email protected]> Signed-off-by: Kyungmin Park <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Kyungmin Park <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 77394ad commit e3b6193

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/perf/perf-archive.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@ if [ ! -s $BUILDIDS ] ; then
2929
fi
3030

3131
MANIFEST=$(mktemp /tmp/perf-archive-manifest.XXXXXX)
32+
PERF_BUILDID_LINKDIR=$(readlink -f $PERF_BUILDID_DIR)/
3233

3334
cut -d ' ' -f 1 $BUILDIDS | \
3435
while read build_id ; do
3536
linkname=$PERF_BUILDID_DIR.build-id/${build_id:0:2}/${build_id:2}
3637
filename=$(readlink -f $linkname)
3738
echo ${linkname#$PERF_BUILDID_DIR} >> $MANIFEST
38-
echo ${filename#$PERF_BUILDID_DIR} >> $MANIFEST
39+
echo ${filename#$PERF_BUILDID_LINKDIR} >> $MANIFEST
3940
done
4041

4142
tar cfj $PERF_DATA.tar.bz2 -C $PERF_BUILDID_DIR -T $MANIFEST

0 commit comments

Comments
 (0)