1 From 56cbeacf143530576905623ac72ae0964f3293a6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Georg=20M=C3=BCller?= <georgmueller@gmx.net>
3 Date: Wed, 28 Jun 2023 10:45:50 +0200
4 Subject: perf probe: Add test for regression introduced by switch to die_get_decl_file()
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Georg Müller <georgmueller@gmx.net>
11 commit 56cbeacf143530576905623ac72ae0964f3293a6 upstream.
13 This patch adds a test to validate that 'perf probe' works for binaries
14 where DWARF info is split into multiple CUs
16 Signed-off-by: Georg Müller <georgmueller@gmx.net>
17 Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
18 Cc: Adrian Hunter <adrian.hunter@intel.com>
19 Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
20 Cc: Ian Rogers <irogers@google.com>
21 Cc: Ingo Molnar <mingo@redhat.com>
22 Cc: Jiri Olsa <jolsa@kernel.org>
23 Cc: Mark Rutland <mark.rutland@arm.com>
24 Cc: Namhyung Kim <namhyung@kernel.org>
25 Cc: Peter Zijlstra <peterz@infradead.org>
26 Cc: regressions@lists.linux.dev
27 Cc: stable@vger.kernel.org
28 Link: https://lore.kernel.org/r/20230628084551.1860532-5-georgmueller@gmx.net
29 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
30 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32 tools/perf/tests/shell/test_uprobe_from_different_cu.sh | 77 ++++++++++++++++
33 1 file changed, 77 insertions(+)
34 create mode 100755 tools/perf/tests/shell/test_uprobe_from_different_cu.sh
37 +++ b/tools/perf/tests/shell/test_uprobe_from_different_cu.sh
40 +# test perf probe of function from different CU
41 +# SPDX-License-Identifier: GPL-2.0
45 +temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
49 + trap - EXIT TERM INT
50 + if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
51 + echo "--- Cleaning up ---"
52 + perf probe -x ${temp_dir}/testfile -d foo
53 + rm -f "${temp_dir}/"*
64 +trap trap_cleanup EXIT TERM INT
66 +cat > ${temp_dir}/testfile-foo.h << EOF
73 +extern int foo (int i, struct t *t);
76 +cat > ${temp_dir}/testfile-foo.c << EOF
77 +#include "testfile-foo.h"
80 +foo (int i, struct t *t)
83 + for (j = 0; j < i && j < t->c; j++)
90 +cat > ${temp_dir}/testfile-main.c << EOF
91 +#include "testfile-foo.h"
96 +main (int argc, char **argv)
102 + for (i = 0; i < argc; i++)
103 + j[i] = (int) argv[i][0];
104 + return foo (3, &g);
108 +gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o
109 +gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
110 +gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
112 +perf probe -x ${temp_dir}/testfile --funcs foo
113 +perf probe -x ${temp_dir}/testfile foo