diff options
| author | Ian Rogers <irogers@google.com> | 2026-09-25 23:20:05 -0700 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2026-09-26 20:49:30 +0200 |
| commit | 279b402e5143214c077f1a95132134c27d907e4c (patch) | |
| tree | a094e511ada767b39226f276e7ad9a3d9b9c5b9e /tools/perf/tests/shell | |
| parent | 8c302c91402a3f543e661ace28bacf49f803b88b (diff) | |
| download | linux-next-279b402e5143214c077f1a95132134c27d907e4c.tar.gz linux-next-279b402e5143214c077f1a95132134c27d907e4c.zip | |
perf python: Port arm-cs-trace-disasm to perf module
Port arm-cs-trace-disasm.py to a standalone script in tools/perf/python/
using the perf module directly.
Improvements compared to the legacy script:
- Encapsulate trace disassembly state in a TraceDisasm class.
- Default to itrace="b" when creating perf.session() (overridable via
--itrace or PERF_ITRACE) so all CoreSight branch samples are
synthesized without requiring --itrace=b on the command line.
- Automatically search standard kernel debug paths (find_vmlinux())
when -k/--vmlinux is not specified, and query
perf.config_get("annotate.objdump") for the default objdump binary.
- Bound DISASM_CACHE memory consumption by evicting the cache at 1024
entries and skipping caching of oversized (> 512 lines) objdump
outputs.
- Use sample.srccode() from the perf extension module to annotate
disassembly output with source filenames, line numbers, and source
lines.
Update the ARM CoreSight disassembly shell test
(test_arm_coresight_disasm.sh) to invoke the standalone script.
Assisted-by: Antigravity:gemini-3.1-pro
Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/shell')
| -rwxr-xr-x | tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh b/tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh index f3ebad596378..82cdb1762285 100755 --- a/tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh +++ b/tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Check Arm CoreSight disassembly script completes without errors (exclusive) # SPDX-License-Identifier: GPL-2.0 +# Check Arm CoreSight disassembly script completes without errors (exclusive) # The disassembly script reconstructs ranges of instructions and gives these to objdump to # decode. objdump doesn't like ranges that go backwards, but these are a good indication @@ -20,11 +20,23 @@ skip_if_no_cs_etm_event || exit 2 set -e glb_err=1 +# Relative path works whether it's installed or running from repo +if [ -n "$PERF_EXEC_PATH" ] && [ -e "$PERF_EXEC_PATH/python/arm-cs-trace-disasm.py" ]; then + script_path="$PERF_EXEC_PATH/python/arm-cs-trace-disasm.py" +else + script_path=$(dirname "$0")/../../../python/arm-cs-trace-disasm.py +fi + +# shellcheck source=lib/setup_python.sh +. "$(dirname "$0")"/../lib/setup_python.sh +$PYTHON -c "import perf" 2>/dev/null || { + echo "Skipping test, perf python module not found" + exit 2 +} + perfdata_dir=$(mktemp -d /tmp/__perf_test.perf.data.XXXXX) perfdata=${perfdata_dir}/perf.data file=$(mktemp /tmp/temporary_file.XXXXX) -# Relative path works whether it's installed or running from repo -script_path=$(dirname "$0")/../../../scripts/python/arm-cs-trace-disasm.py cleanup_files() { @@ -44,8 +56,8 @@ branch_search='[[:space:]](bl|b(\.(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al) if [ "$(id -u)" == 0 ] && [ -e /proc/kcore ]; then echo "Testing kernel disassembly" perf record -o ${perfdata} -e cs_etm//k --kcore -Se -m,64K -- touch $file > /dev/null 2>&1 - perf script -i ${perfdata} --itrace=b -s python:${script_path} -- \ - -d --stop-sample=2 -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${file} + $PYTHON ${script_path} -i ${perfdata} -d --stop-sample=2 \ + -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${file} grep -q -E ${branch_search} ${file} echo "Found kernel branches" else @@ -56,8 +68,7 @@ fi ## Test user ## echo "Testing userspace disassembly" perf record -o ${perfdata} -e cs_etm//u -Se -m,64K -- touch $file > /dev/null 2>&1 -perf script -i ${perfdata} --itrace=b -s python:${script_path} -- \ - -d --stop-sample=2 2> /dev/null > ${file} +$PYTHON ${script_path} -i ${perfdata} -d --stop-sample=2 2> /dev/null > ${file} grep -q -E ${branch_search} ${file} echo "Found userspace branches" |
