2 # test perf probe of function from different CU
3 # SPDX-License-Identifier: GPL-2.0
7 # skip if there's no gcc
8 if ! [ -x "$(command -v gcc)" ]; then
9 echo "failed: no gcc compiler"
13 temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
18 if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
19 echo "--- Cleaning up ---"
20 perf probe -x ${temp_dir}/testfile -d foo || true
32 trap trap_cleanup EXIT TERM INT
34 cat > ${temp_dir}/testfile-foo.h << EOF
41 extern int foo (int i, struct t *t);
44 cat > ${temp_dir}/testfile-foo.c << EOF
45 #include "testfile-foo.h"
48 foo (int i, struct t *t)
51 for (j = 0; j < i && j < t->c; j++)
58 cat > ${temp_dir}/testfile-main.c << EOF
59 #include "testfile-foo.h"
64 main (int argc, char **argv)
70 for (i = 0; i < argc; i++)
71 j[i] = (int) argv[i][0];
76 gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o
77 gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
78 gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
80 perf probe -x ${temp_dir}/testfile --funcs foo
81 perf probe -x ${temp_dir}/testfile foo