[DTrace-devel] [PATCH 1/2] fbt: Populate just once

eugene.loh at oracle.com eugene.loh at oracle.com
Tue Jan 13 21:42:04 UTC 2026


From: Eugene Loh <eugene.loh at oracle.com>

In commit 0b7c5a632 ("fbt, rawfbt: consolidate code to avoid duplication"),
the populate() functions for fbt and rawfbt were combined, populating both
providers, but the function was still called twice.  That is, dt_open.c
tries to insert each provider twice.

One solution would be to have a different populate() function for each
provider.

Here, we employ another solution:  in dt_provider_create(), check to see
if a specified provider has already been inserted.

This also requires a corresponding change in dt_provider_lookup(), so
that it will work even if no providers have yet been inserted.

Also, fix a minor comment in the fbt provider.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_prov_fbt.c | 2 +-
 libdtrace/dt_provider.c | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libdtrace/dt_prov_fbt.c b/libdtrace/dt_prov_fbt.c
index bbe44a842..3feac56ea 100644
--- a/libdtrace/dt_prov_fbt.c
+++ b/libdtrace/dt_prov_fbt.c
@@ -228,7 +228,7 @@ static int provide(dtrace_hdl_t *dtp, const dtrace_probedesc_t *pdp)
 		if (!dt_symbol_traceable(sym))
 			continue;
 
-		/* Function name cannot be synthetic and must match. */
+		/* Function name cannot be synthetic (unless rawfbt) and must match. */
 		fun = dt_symbol_name(sym);
 		if ((!rawfbt && strchr(fun, '.')) || !dt_gmatch(fun, pdp->fun))
 			continue;
diff --git a/libdtrace/dt_provider.c b/libdtrace/dt_provider.c
index 848fdc132..9d75225fa 100644
--- a/libdtrace/dt_provider.c
+++ b/libdtrace/dt_provider.c
@@ -114,6 +114,8 @@ dt_provider_lookup(dtrace_hdl_t *dtp, const char *name)
 		return NULL;
 
 	strcpy(tmpl.desc.dtvd_name, name);
+	if (dtp->dt_provs == NULL)
+		return NULL;
 	return dt_htab_lookup(dtp->dt_provs, &tmpl);
 }
 
@@ -124,6 +126,10 @@ dt_provider_create(dtrace_hdl_t *dtp, const char *name,
 {
 	dt_provider_t *pvp;
 
+	pvp = dt_provider_lookup(dtp, name);
+	if (pvp)
+		return pvp;
+
 	if ((pvp = dt_zalloc(dtp, sizeof(dt_provider_t))) == NULL)
 		goto nomem;
 
-- 
2.47.3




More information about the DTrace-devel mailing list