Skip to content

Commit

Permalink
provider: Add support for attaching to raw tracepoints
Browse files Browse the repository at this point in the history
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
  • Loading branch information
kvanhees committed Feb 27, 2023
1 parent 209ee79 commit 6a275a1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libdtrace/dt_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ extern struct dt_probe *dt_tp_probe_insert(dtrace_hdl_t *dtp,
const char *fun, const char *prb);
extern int dt_tp_probe_attach(dtrace_hdl_t *dtp, const struct dt_probe *prp,
int bpf_fd);
extern int dt_tp_probe_attach_raw(dtrace_hdl_t *dtp, const struct dt_probe *prp,
int bpf_fd);
extern void dt_tp_probe_detach(dtrace_hdl_t *dtp, const struct dt_probe *prp);
extern void dt_tp_probe_destroy(dtrace_hdl_t *dtp, void *datap);

Expand Down
23 changes: 23 additions & 0 deletions libdtrace/dt_provider_tp.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,29 @@ dt_tp_probe_attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
return dt_tp_attach(dtp, prp->prv_data, bpf_fd);
}

/*
* Convenience function for raw tracepoint-based probe attach.
*/
int
dt_tp_probe_attach_raw(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
{
tp_probe_t *tpp = prp->prv_data;

tpp->event_id = INT_MAX;

if (tpp->event_fd == -1) {
int fd;

fd = dt_bpf_raw_tracepoint_open(prp->desc->prb, bpf_fd);
if (fd < 0)
return -errno;

tpp->event_fd = fd;
}

return 0;
}

/*
* Convenience function for basic tracepoint-based probe detach.
*/
Expand Down

0 comments on commit 6a275a1

Please sign in to comment.