[DTrace-devel] [PATCH 06/14] Add clauses to per-uprobe list
eugene.loh at oracle.com
eugene.loh at oracle.com
Tue Jun 4 18:11:05 UTC 2024
From: Eugene Loh <eugene.loh at oracle.com>
Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
libdtrace/dt_prov_uprobe.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/libdtrace/dt_prov_uprobe.c b/libdtrace/dt_prov_uprobe.c
index cace406d..34906aa0 100644
--- a/libdtrace/dt_prov_uprobe.c
+++ b/libdtrace/dt_prov_uprobe.c
@@ -62,6 +62,7 @@ typedef struct dt_uprobe {
int flags;
tp_probe_t *tp;
dt_list_t probes; /* pid/USDT probes triggered by it */
+ dt_list_t clauses; /* clauses possibly called by this uprobe */
} dt_uprobe_t;
typedef struct list_probe {
@@ -69,6 +70,11 @@ typedef struct list_probe {
dt_probe_t *probe;
} list_probe_t;
+typedef struct list_clause {
+ dt_list_t list;
+ uint_t clause;
+} list_clause_t;
+
static const dtrace_pattr_t pattr = {
{ DTRACE_STABILITY_EVOLVING, DTRACE_STABILITY_EVOLVING, DTRACE_CLASS_ISA },
{ DTRACE_STABILITY_PRIVATE, DTRACE_STABILITY_PRIVATE, DTRACE_CLASS_UNKNOWN },
@@ -243,6 +249,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
dt_uprobe_t *upp;
dt_probe_t *prp, *uprp;
list_probe_t *pop, *pup;
+ list_clause_t *cl;
snprintf(prv, sizeof(prv), "%s%d", psp->pps_prv, psp->pps_pid);
@@ -263,6 +270,7 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
/* Mark the provider as a PID-based provider. */
pvp->pv_flags |= DT_PROVIDER_PID;
+ /* Look up or create the underlying probe. */
uprp = create_underlying(dtp, psp);
if (uprp == NULL)
return -1;
@@ -270,6 +278,17 @@ static int provide_probe(dtrace_hdl_t *dtp, const pid_probespec_t *psp,
upp = uprp->prv_data;
upp->flags |= flags;
+ /* Add to this uprobe an index for the next clause to be assigned. */
+ cl = dt_list_prev(&upp->clauses);
+ if (cl == NULL || cl->clause != dtp->dt_clause_nextid) {
+ cl = dt_zalloc(dtp, sizeof(list_clause_t));
+ if (cl == NULL)
+ return -1;
+ cl->clause = dtp->dt_clause_nextid;
+ dt_list_append(&upp->clauses, cl);
+ }
+
+ /* Look up the overlying probe. */
prp = dt_probe_lookup(dtp, &pd);
if (prp != NULL) {
/*
--
2.18.4
More information about the DTrace-devel
mailing list