Commit 56cbeacf authored by Georg Müller's avatar Georg Müller Committed by Arnaldo Carvalho de Melo

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: default avatarGeorg Müller <georgmueller@gmx.net>
Acked-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: regressions@lists.linux.dev
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20230628084551.1860532-5-georgmueller@gmx.netSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3f01e9fe
#!/bin/bash
# test perf probe of function from different CU
# SPDX-License-Identifier: GPL-2.0
set -e
temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX)
cleanup()
{
trap - EXIT TERM INT
if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then
echo "--- Cleaning up ---"
perf probe -x ${temp_dir}/testfile -d foo
rm -f "${temp_dir}/"*
rmdir "${temp_dir}"
fi
}
trap_cleanup()
{
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
cat > ${temp_dir}/testfile-foo.h << EOF
struct t
{
int *p;
int c;
};
extern int foo (int i, struct t *t);
EOF
cat > ${temp_dir}/testfile-foo.c << EOF
#include "testfile-foo.h"
int
foo (int i, struct t *t)
{
int j, res = 0;
for (j = 0; j < i && j < t->c; j++)
res += t->p[j];
return res;
}
EOF
cat > ${temp_dir}/testfile-main.c << EOF
#include "testfile-foo.h"
static struct t g;
int
main (int argc, char **argv)
{
int i;
int j[argc];
g.c = argc;
g.p = j;
for (i = 0; i < argc; i++)
j[i] = (int) argv[i][0];
return foo (3, &g);
}
EOF
gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o
gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o
gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o
perf probe -x ${temp_dir}/testfile --funcs foo
perf probe -x ${temp_dir}/testfile foo
cleanup
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment