[DTrace-devel] [PATCH 13/16] Remove probes for providers that need to be destroyed during compilation

Kris Van Hees kris.van.hees at oracle.com
Thu Mar 18 21:54:55 PDT 2021


When something goes wrong during a compilation, dynamically created
providers need to be cleaed up.  This also requires that the probes
that are associated with them are cleaned up (otherwise they will
cause an issue when they get cleaned up later than their provider is
gone already).

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libdtrace/dt_pcb.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/libdtrace/dt_pcb.c b/libdtrace/dt_pcb.c
index db12d011..d2e8c3a7 100644
--- a/libdtrace/dt_pcb.c
+++ b/libdtrace/dt_pcb.c
@@ -29,6 +29,7 @@
 #include <dt_impl.h>
 #include <dt_program.h>
 #include <dt_provider.h>
+#include <dt_probe.h>
 #include <dt_pcb.h>
 
 /*
@@ -79,6 +80,13 @@ dt_pcb_pop_ident(dt_idhash_t *dhp, dt_ident_t *idp, void *arg)
 	return 0;
 }
 
+static int
+dt_pcb_destroy_probe(dtrace_hdl_t *dtp, dt_probe_t *prp, void *dummy)
+{
+	dt_probe_destroy(prp);
+	return 0;
+}
+
 /*
  * Pop the topmost PCB from the PCB stack and destroy any data structures that
  * are associated with it.  If 'err' is non-zero, destroy any intermediate
@@ -121,8 +129,20 @@ dt_pcb_pop(dtrace_hdl_t *dtp, int err)
 
 		for (pvp = dt_list_next(&dtp->dt_provlist); pvp; pvp = nvp) {
 			nvp = dt_list_next(pvp);
-			if (pvp->pv_gen == dtp->dt_gen)
+			if (pvp->pv_gen == dtp->dt_gen) {
+				dtrace_probedesc_t	pdp;
+
+				/* Destroy all probes for this provider. */
+				pdp.id = DTRACE_IDNONE;
+				pdp.prv = pvp->desc.dtvd_name;
+				pdp.mod = "";
+				pdp.fun = "";
+				pdp.prb = "";
+				dt_probe_iter(dtp, &pdp, dt_pcb_destroy_probe,
+					      NULL, NULL);
+
 				dt_provider_destroy(dtp, pvp);
+			}
 		}
 
 		dt_idhash_iter(dtp->dt_aggs, dt_pcb_pop_ident, dtp);
-- 
2.28.0




More information about the DTrace-devel mailing list