[DTrace-devel] [PATCH v2 08/20] providers: allow providers with no trampoline

Nick Alcock nick.alcock at oracle.com
Wed Sep 7 12:59:56 UTC 2022


Such providers can be enabled just like any other, but generate no code.

Meant for use by things like the pid provider which have two probes
associated with each system-side probe, one of which gets fired and
generates code for the others in its trampoline method. Right now, both
probes get the same trampoline, but only one probe's trampoline is
necessary. Doing this lets us drop the unnecessary ones in a future
commit.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
 libdtrace/dt_bpf.c | 7 +++++++
 libdtrace/dt_cg.c  | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
index 5ff348ca6370..42b4b80c0a68 100644
--- a/libdtrace/dt_bpf.c
+++ b/libdtrace/dt_bpf.c
@@ -719,6 +719,13 @@ dt_bpf_load_progs(dtrace_hdl_t *dtp, uint_t cflags)
 		if (prp == dtp->dt_error)
 			continue;
 
+		/*
+		 * Enabled probes with no trampoline act like they exist but
+		 * no code is generated for them.
+		 */
+		if (prp->prov->impl->trampoline == NULL)
+			continue;
+
 		dp = dt_program_construct(dtp, prp, cflags, NULL);
 		if (dp == NULL)
 			return -1;
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index ebd4190698f7..9f9d0fb03028 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -6846,7 +6846,8 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
 	} else if (dnp->dn_kind == DT_NODE_TRAMPOLINE) {
 		assert(pcb->pcb_probe != NULL);
 
-		pcb->pcb_probe->prov->impl->trampoline(pcb);
+		if (pcb->pcb_probe->prov->impl->trampoline != NULL)
+			pcb->pcb_probe->prov->impl->trampoline(pcb);
 	} else
 		dt_cg_node(dnp, &pcb->pcb_ir, pcb->pcb_regs);
 
-- 
2.37.1.265.g363c192786.dirty




More information about the DTrace-devel mailing list