[DTrace-devel] [PATCH v4 08/25] providers: allow providers with no trampoline

Nick Alcock nick.alcock at oracle.com
Fri Oct 7 10:25:07 UTC 2022


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

Meant for use by providers like pid which have some probes without
trampolines (but which enable other probes which do contain trampolines
that execute on their behalf).  Both such probes need enabling because
we want to ensure their names are interned, etc: we only want to avoid
trying to execute their trampoline when there is none.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees 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.35.1




More information about the DTrace-devel mailing list