[DTrace-devel] [PATCH 12/15] dlib: Ensure dt_dlib_add_sym_id() does not add duplicates

Kris Van Hees kris.van.hees at oracle.com
Thu Feb 23 07:24:14 UTC 2023


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

diff --git a/libdtrace/dt_dlibs.c b/libdtrace/dt_dlibs.c
index e3196b63..eea45d8b 100644
--- a/libdtrace/dt_dlibs.c
+++ b/libdtrace/dt_dlibs.c
@@ -152,6 +152,7 @@ dt_dlib_get_xsym(dtrace_hdl_t *dtp, const char *name, int kind)
 
 /*
  * Add a BPF identifier of a given kind with given id.
+ * If the identifier already exists (with the proper id, if any), return it.
  */
 static dt_ident_t *
 dt_dlib_add_sym_id(dtrace_hdl_t *dtp, const char *name, int kind, uint_t id)
@@ -159,6 +160,10 @@ dt_dlib_add_sym_id(dtrace_hdl_t *dtp, const char *name, int kind, uint_t id)
 	dt_idhash_t	*dhp = dtp->dt_bpfsyms;
 	dt_ident_t	*idp;
 
+	idp = dt_dlib_get_xsym(dtp, name, kind);
+	if (idp != NULL && id != DT_IDENT_UNDEF && idp->di_id == id)
+		return idp;
+
 	idp = dt_idhash_insert(dhp, name, kind, DT_IDFLG_BPF, id,
 			       dt_bpf_attr, DT_VERS_2_0,
 			       kind == DT_IDENT_SYMBOL ? &dt_idops_difo : NULL,
-- 
2.39.1




More information about the DTrace-devel mailing list