Skip to content

Commit 56cbeac

Browse files
georgmuacmel
authored andcommitted
perf probe: Add test for regression introduced by switch to die_get_decl_file()
This patch adds a test to validate that 'perf probe' works for binaries where DWARF info is split into multiple CUs Signed-off-by: Georg Müller <[email protected]> Acked-by: Masami Hiramatsu (Google) <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: [email protected] Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 3f01e9f commit 56cbeac

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#!/bin/bash
2+
# test perf probe of function from different CU
3+
# SPDX-License-Identifier: GPL-2.0
4+
5+
set -e
6+
7+
temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
8+
9+
cleanup()
10+
{
11+
trap - EXIT TERM INT
12+
if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
13+
echo "--- Cleaning up ---"
14+
perf probe -x ${temp_dir}/testfile -d foo
15+
rm -f "${temp_dir}/"*
16+
rmdir "${temp_dir}"
17+
fi
18+
}
19+
20+
trap_cleanup()
21+
{
22+
cleanup
23+
exit 1
24+
}
25+
26+
trap trap_cleanup EXIT TERM INT
27+
28+
cat > ${temp_dir}/testfile-foo.h << EOF
29+
struct t
30+
{
31+
int *p;
32+
int c;
33+
};
34+
35+
extern int foo (int i, struct t *t);
36+
EOF
37+
38+
cat > ${temp_dir}/testfile-foo.c << EOF
39+
#include "testfile-foo.h"
40+
41+
int
42+
foo (int i, struct t *t)
43+
{
44+
int j, res = 0;
45+
for (j = 0; j < i && j < t->c; j++)
46+
res += t->p[j];
47+
48+
return res;
49+
}
50+
EOF
51+
52+
cat > ${temp_dir}/testfile-main.c << EOF
53+
#include "testfile-foo.h"
54+
55+
static struct t g;
56+
57+
int
58+
main (int argc, char **argv)
59+
{
60+
int i;
61+
int j[argc];
62+
g.c = argc;
63+
g.p = j;
64+
for (i = 0; i < argc; i++)
65+
j[i] = (int) argv[i][0];
66+
return foo (3, &g);
67+
}
68+
EOF
69+
70+
gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o
71+
gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
72+
gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
73+
74+
perf probe -x ${temp_dir}/testfile --funcs foo
75+
perf probe -x ${temp_dir}/testfile foo
76+
77+
cleanup

0 commit comments

Comments
 (0)