[DTrace-devel] [PATCH 03/16] Split out tp_probe_t allocation and initialization
Kris Van Hees
kris.van.hees at oracle.com
Thu Mar 18 21:54:16 PDT 2021
The tp_probe_t structure was being allocated and initialized in the
tp_probe_insert() function, but we will be needing that allocation
and initialization outside of that specific case as well.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_prov_sdt.c | 23 +++++++++++++++++++----
libdtrace/dt_provider.h | 1 +
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/libdtrace/dt_prov_sdt.c b/libdtrace/dt_prov_sdt.c
index 7e4a3e4a..88df4f9f 100644
--- a/libdtrace/dt_prov_sdt.c
+++ b/libdtrace/dt_prov_sdt.c
@@ -96,6 +96,24 @@ int tp_attach(dtrace_hdl_t *dtp, const dt_probe_t *prp, int bpf_fd)
return 0;
}
+/*
+ * Create tracepoint-specific probe data.
+ */
+tp_probe_t *
+tp_probe_create(dtrace_hdl_t *dtp)
+{
+ tp_probe_t *datap;
+
+ datap = dt_zalloc(dtp, sizeof(tp_probe_t));
+ if (datap == NULL)
+ return NULL;
+
+ datap->event_fd = -1;
+ datap->event_id = -1;
+
+ return datap;
+}
+
/*
* Create a tracepoint-based probe. This function is called from any provider
* that handled tracepoint-based probes. It sets up the provider-specific
@@ -108,13 +126,10 @@ dt_probe_t *tp_probe_insert(dtrace_hdl_t *dtp, dt_provider_t *prov,
{
tp_probe_t *datap;
- datap = dt_zalloc(dtp, sizeof(tp_probe_t));
+ datap = tp_probe_create(dtp);
if (datap == NULL)
return NULL;
- datap->event_id = -1;
- datap->event_fd = -1;
-
return dt_probe_insert(dtp, prov, prv, mod, fun, prb, datap);
}
diff --git a/libdtrace/dt_provider.h b/libdtrace/dt_provider.h
index 65829aed..e84707d0 100644
--- a/libdtrace/dt_provider.h
+++ b/libdtrace/dt_provider.h
@@ -99,6 +99,7 @@ typedef struct tp_probe {
} tp_probe_t;
extern int tp_attach(dtrace_hdl_t *dtp, const struct dt_probe *prp, int bpf_fd);
+extern tp_probe_t *tp_probe_create(dtrace_hdl_t *dtp);
extern struct dt_probe *tp_probe_insert(dtrace_hdl_t *dtp, dt_provider_t *prov,
const char *prv, const char *mod,
const char *fun, const char *prb);
--
2.28.0
More information about the DTrace-devel
mailing list