aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/trace_helpers.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2021-10-22 16:48:14 -0700
committerAndrii Nakryiko <andrii@kernel.org>2021-10-25 21:43:05 -0700
commit20d1b54a52bd9a1d5d23a45dab75993ce2f1d617 (patch)
treec9e04e910758f076c94c445121a09df0da51c3cb /tools/testing/selftests/bpf/trace_helpers.c
parentselftests/bpf: Skip all serial_test_get_branch_snapshot in vm (diff)
downloadlinux-dev-20d1b54a52bd9a1d5d23a45dab75993ce2f1d617.tar.xz
linux-dev-20d1b54a52bd9a1d5d23a45dab75993ce2f1d617.zip
selftests/bpf: Guess function end for test_get_branch_snapshot
Function in modules could appear in /proc/kallsyms in random order. ffffffffa02608a0 t bpf_testmod_loop_test ffffffffa02600c0 t __traceiter_bpf_testmod_test_writable_bare ffffffffa0263b60 d __tracepoint_bpf_testmod_test_write_bare ffffffffa02608c0 T bpf_testmod_test_read ffffffffa0260d08 t __SCT__tp_func_bpf_testmod_test_writable_bare ffffffffa0263300 d __SCK__tp_func_bpf_testmod_test_read ffffffffa0260680 T bpf_testmod_test_write ffffffffa0260860 t bpf_testmod_test_mod_kfunc Therefore, we cannot reliably use kallsyms_find_next() to find the end of a function. Replace it with a simple guess (start + 128). This is good enough for this test. Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211022234814.318457-1-songliubraving@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/trace_helpers.c')
-rw-r--r--tools/testing/selftests/bpf/trace_helpers.c36
1 files changed, 0 insertions, 36 deletions
diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
index 5100a169b72b..7b7f918eda77 100644
--- a/tools/testing/selftests/bpf/trace_helpers.c
+++ b/tools/testing/selftests/bpf/trace_helpers.c
@@ -118,42 +118,6 @@ out:
return err;
}
-/* find the address of the next symbol of the same type, this can be used
- * to determine the end of a function.
- */
-int kallsyms_find_next(const char *sym, unsigned long long *addr)
-{
- char type, found_type, name[500];
- unsigned long long value;
- bool found = false;
- int err = 0;
- FILE *f;
-
- f = fopen("/proc/kallsyms", "r");
- if (!f)
- return -EINVAL;
-
- while (fscanf(f, "%llx %c %499s%*[^\n]\n", &value, &type, name) > 0) {
- /* Different types of symbols in kernel modules are mixed
- * in /proc/kallsyms. Only return the next matching type.
- * Use tolower() for type so that 'T' matches 't'.
- */
- if (found && found_type == tolower(type)) {
- *addr = value;
- goto out;
- }
- if (strcmp(name, sym) == 0) {
- found = true;
- found_type = tolower(type);
- }
- }
- err = -ENOENT;
-
-out:
- fclose(f);
- return err;
-}
-
void read_trace_pipe(void)
{
int trace_fd;