if (!ASSERT_OK(err, "kallsyms_find"))
goto cleanup;
- err = kallsyms_find_next("bpf_testmod_loop_test", &skel->bss->address_high);
- if (!ASSERT_OK(err, "kallsyms_find_next"))
- goto cleanup;
+ /* Just a guess for the end of this function, as module functions
+ * in /proc/kallsyms could come in any order.
+ */
+ skel->bss->address_high = skel->bss->address_low + 128;
err = get_branch_snapshot__attach(skel);
if (!ASSERT_OK(err, "get_branch_snapshot__attach"))
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;
/* open kallsyms and find addresses on the fly, faster than load + search. */
int kallsyms_find(const char *sym, unsigned long long *addr);
-/* find the address of the next symbol, this can be used to determine the
- * end of a function
- */
-int kallsyms_find_next(const char *sym, unsigned long long *addr);
-
void read_trace_pipe(void);
ssize_t get_uprobe_offset(const void *addr, ssize_t base);