2 # test perf probe of function from different CU
3 # SPDX-License-Identifier: GPL-2.0
7 # Skip if there's no probe command.
10 echo "Skip: probe command isn't present"
14 # skip if there's no gcc
15 if ! [ -x "$(command -v gcc)" ]; then
16 echo "failed: no gcc compiler"
20 temp_dir
=$
(mktemp
-d /tmp
/perf-uprobe-different-cu-sh.XXXXXXXXXX
)
25 if [[ "${temp_dir}" =~ ^
/tmp
/perf-uprobe-different-cu-sh.
*$
]]; then
26 echo "--- Cleaning up ---"
27 perf probe
-x ${temp_dir}/testfile
-d foo || true
39 trap trap_cleanup EXIT TERM INT
41 cat > ${temp_dir}/testfile-foo.h
<< EOF
48 extern int foo (int i, struct t *t);
51 cat > ${temp_dir}/testfile-foo.c
<< EOF
52 #include "testfile-foo.h"
55 foo (int i, struct t *t)
58 for (j = 0; j < i && j < t->c; j++)
65 cat > ${temp_dir}/testfile-main.c
<< EOF
66 #include "testfile-foo.h"
71 main (int argc, char **argv)
77 for (i = 0; i < argc; i++)
78 j[i] = (int) argv[i][0];
83 gcc
-g -Og -flto -c ${temp_dir}/testfile-foo.c
-o ${temp_dir}/testfile-foo.o
84 gcc
-g -Og -c ${temp_dir}/testfile-main.c
-o ${temp_dir}/testfile-main.o
85 gcc
-g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
87 perf probe
-x ${temp_dir}/testfile
--funcs foo |
grep "foo"
88 perf probe
-x ${temp_dir}/testfile foo