Skip to content

Commit

Permalink
libbpf-tools: funcinterval: add ensure_core_btf and cleanup_core_btf
Browse files Browse the repository at this point in the history
Signed-off-by: Feng Yang <[email protected]>
  • Loading branch information
kknjh authored and unknown committed Sep 7, 2024
1 parent a902ec9 commit d370c42
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libbpf-tools/funcinterval.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "funcinterval.h"
#include "trace_helpers.h"
#include "uprobe_helpers.h"
#include "btf_helpers.h"

static volatile sig_atomic_t exiting;
const char *attach_type[] = {"KPROBE", "UPROBE", "TRACEPOINT"};
Expand Down Expand Up @@ -281,6 +282,7 @@ static int attach_tracepoint(struct funcinterval_bpf *obj, const char *library,

int main(int argc, char *argv[])
{
LIBBPF_OPTS(bpf_object_open_opts, open_opts);
static const struct argp argp = {
.options = opts,
.parser = parse_arg,
Expand All @@ -297,7 +299,13 @@ int main(int argc, char *argv[])

libbpf_set_print(libbpf_print_fn);

obj = funcinterval_bpf__open();
err = ensure_core_btf(&open_opts);
if (err) {
fprintf(stderr, "failed to fetch necessary BTF for CO-RE: %s\n", strerror(-err));
return 1;
}

obj = funcinterval_bpf__open_opts(&open_opts);
if (!obj) {
fprintf(stderr, "Failed to open BPF object\n");
return 1;
Expand Down Expand Up @@ -386,6 +394,7 @@ int main(int argc, char *argv[])

cleanup:
funcinterval_bpf__destroy(obj);
cleanup_core_btf(&open_opts);

return err != 0;
}

0 comments on commit d370c42

Please sign in to comment.