Skip to content

Commit

Permalink
perf bpf: Provide a weak btf__load_from_kernel_by_id() for older libb…
Browse files Browse the repository at this point in the history
…pf versions

The btf__get_from_id() function was deprecated in favour of
btf__load_from_kernel_by_id(), but it is still avaiable, so use it to
provide a weak function btf__load_from_kernel_by_id() for older libbpf
when building perf with LIBBPF_DYNAMIC=1, i.e. using the system's libbpf
package.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
acmel committed Sep 10, 2021
1 parent 37ce9e4 commit 218e7b7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tools/perf/util/bpf-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
#include "record.h"
#include "util/synthetic-events.h"

struct btf * __weak btf__load_from_kernel_by_id(__u32 id)
{
struct btf *btf;
int err = btf__get_from_id(id, &btf);

return err ? ERR_PTR(err) : btf;
}

#define ptr_to_u64(ptr) ((__u64)(unsigned long)(ptr))

static int snprintf_hex(char *buf, size_t size, unsigned char *data, size_t len)
Expand Down

0 comments on commit 218e7b7

Please sign in to comment.