From ba0886495454bdc2d777aa38f3c573463c4cd94f Mon Sep 17 00:00:00 2001 From: Aaron Barany Date: Thu, 29 Apr 2021 16:27:15 -0700 Subject: [PATCH] PerformanceAnalyzer: Fix tracepoints script Fixed issues seen running the tracepoint script in Arch Linux: * Use /lib/ rather than /lib for the call to find to work with cases where /lib is a symlink. * When finding _ret entries in match_tracepoints, search for _ret__return if the initial check failed. Newer versions of perf seem to decorate the name with __return when the function name is followed by %return. * Handle arrays output from the call to awk in match_tracepoints. This can happen when multiple functions are added with the tracepoint, and breaks when checking for "bad" probes when a loop isn't used to add individual checks for each entry. Fixes: QTCREATORBUG-25651 Change-Id: Ie528b4d80f9ece8f23d27a84356c74577219ed45 Reviewed-by: Ulf Hermann --- src/plugins/perfprofiler/tracepoints.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/plugins/perfprofiler/tracepoints.sh b/src/plugins/perfprofiler/tracepoints.sh index 1352c4dd324..989e5004bf5 100644 --- a/src/plugins/perfprofiler/tracepoints.sh +++ b/src/plugins/perfprofiler/tracepoints.sh @@ -49,8 +49,20 @@ match_tracepoints() { BASE="perfprofiler_${MACHINE}_${NAME}" RETURN=`perf probe -l "${BASE}_ret" | awk '{print $3}'` + if [ -z "$RETURN" ]; then + RETURN=`perf probe -l "${BASE}_ret__return" | awk '{print $3}'` + fi + + CHECK= + for RET in $RETURN; do + if [ -n "$CHECK" ]; then + CHECK="$CHECK && " + fi + CHECK="$CHECK\$3 != \"$RET\"" + done + ENTRY=`echo ${RETURN} | awk '{sub(/%return/, ""); print $1}'` - BAD=`perf probe -l "${BASE}*" | awk '{ if ($3 != "'$RETURN'" && $3 != "'$ENTRY'") { print $1 } }'` + BAD=`perf probe -l "${BASE}*" | awk '{ if ('"$CHECK"' && $3 != "'$ENTRY'") { print $1 } }'` for PROBE in $BAD; do perf probe -d $PROBE done @@ -121,7 +133,7 @@ set_tracepoint() { } HOST_MACHINE=`uname -m` -find /lib -name libc.so.6 | while read LIBC; do +find /lib/ -name libc.so.6 | while read LIBC; do echo $LIBC | awk -F '/' '{print $(NF-1)}' | while IFS='-' read MACHINE KERNEL SYSTEM; do if [ "$MACHINE" = "lib" ]; then MACHINE=$HOST_MACHINE; fi >&2 echo "

Removing old trace points for $MACHINE

"