]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
ac282bd26345242a16d566d1fb18e1e4c4681b2a
[thirdparty/kernel/stable-queue.git] /
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()
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 From: Georg Müller <georgmueller@gmx.net>
10
11 commit 56cbeacf143530576905623ac72ae0964f3293a6 upstream.
12
13 This patch adds a test to validate that 'perf probe' works for binaries
14 where DWARF info is split into multiple CUs
15
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>
31 ---
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
35
36 --- /dev/null
37 +++ b/tools/perf/tests/shell/test_uprobe_from_different_cu.sh
38 @@ -0,0 +1,77 @@
39 +#!/bin/bash
40 +# test perf probe of function from different CU
41 +# SPDX-License-Identifier: GPL-2.0
42 +
43 +set -e
44 +
45 +temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
46 +
47 +cleanup()
48 +{
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}/"*
54 + rmdir "${temp_dir}"
55 + fi
56 +}
57 +
58 +trap_cleanup()
59 +{
60 + cleanup
61 + exit 1
62 +}
63 +
64 +trap trap_cleanup EXIT TERM INT
65 +
66 +cat > ${temp_dir}/testfile-foo.h << EOF
67 +struct t
68 +{
69 + int *p;
70 + int c;
71 +};
72 +
73 +extern int foo (int i, struct t *t);
74 +EOF
75 +
76 +cat > ${temp_dir}/testfile-foo.c << EOF
77 +#include "testfile-foo.h"
78 +
79 +int
80 +foo (int i, struct t *t)
81 +{
82 + int j, res = 0;
83 + for (j = 0; j < i && j < t->c; j++)
84 + res += t->p[j];
85 +
86 + return res;
87 +}
88 +EOF
89 +
90 +cat > ${temp_dir}/testfile-main.c << EOF
91 +#include "testfile-foo.h"
92 +
93 +static struct t g;
94 +
95 +int
96 +main (int argc, char **argv)
97 +{
98 + int i;
99 + int j[argc];
100 + g.c = argc;
101 + g.p = j;
102 + for (i = 0; i < argc; i++)
103 + j[i] = (int) argv[i][0];
104 + return foo (3, &g);
105 +}
106 +EOF
107 +
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
111 +
112 +perf probe -x ${temp_dir}/testfile --funcs foo
113 +perf probe -x ${temp_dir}/testfile foo
114 +
115 +cleanup