[DTrace-devel] [PATCH] Provide tstring alloc and free functions unrelated to dt_node_t variables

eugene.loh at oracle.com eugene.loh at oracle.com
Mon Sep 6 16:11:43 PDT 2021


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

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 libdtrace/dt_cg.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 5b295d94..e2696197 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -824,8 +824,8 @@ dt_cg_tstring_reset(dtrace_hdl_t *dtp)
 /*
  * Associate a temporary string with the given node.
  */
-static void
-dt_cg_tstring_alloc(dt_pcb_t *pcb, dt_node_t *dnp)
+static uint64_t
+dt_cg_tstring_alloc_offset(dt_pcb_t *pcb)
 {
 	int		i;
 	dt_tstring_t	*ts = pcb->pcb_hdl->dt_tstrings;
@@ -838,18 +838,23 @@ dt_cg_tstring_alloc(dt_pcb_t *pcb, dt_node_t *dnp)
 	assert(i < DT_TSTRING_SLOTS);
 	ts->in_use = 1;
 
-	dt_node_tstring(dnp, ts->offset);
+	return ts->offset;
+}
+
+static void
+dt_cg_tstring_alloc(dt_pcb_t *pcb, dt_node_t *dnp)
+{
+	dt_node_tstring(dnp, dt_cg_tstring_alloc_offset(pcb));
 }
 
 /*
  * Release the temporary string associated with the given node.
  */
 static void
-dt_cg_tstring_free(dt_pcb_t *pcb, dt_node_t *dnp)
+dt_cg_tstring_free_offset(dt_pcb_t *pcb, uint64_t offset)
 {
 	int		i;
 	dt_tstring_t	*ts = pcb->pcb_hdl->dt_tstrings;
-	uint64_t	offset = dnp->dn_tstring->dn_value;
 
 	for (i = 0; i < DT_TSTRING_SLOTS; i++, ts++) {
 		if (ts->offset == offset)
@@ -861,6 +866,12 @@ dt_cg_tstring_free(dt_pcb_t *pcb, dt_node_t *dnp)
 	ts->in_use = 0;
 }
 
+static void
+dt_cg_tstring_free(dt_pcb_t *pcb, dt_node_t *dnp)
+{
+	dt_cg_tstring_free_offset(pcb, dnp->dn_tstring->dn_value);
+}
+
 static const uint_t	ldstw[] = {
 					0,
 					BPF_B,	BPF_H,	0, BPF_W,
-- 
2.18.4




More information about the DTrace-devel mailing list