[DTrace-devel] [PATCH 1/3] parser: add dt_node_is_tstring()

Kris Van Hees kris.van.hees at oracle.com
Tue Jul 15 19:50:47 UTC 2025


Returns 1 if the given node has a tstring associated with it.  Internal
change to make implementing optimized tstring-handling easier.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libdtrace/dt_parser.c | 15 +++++++++++++++
 libdtrace/dt_parser.h |  1 +
 2 files changed, 16 insertions(+)

diff --git a/libdtrace/dt_parser.c b/libdtrace/dt_parser.c
index eefe8341..f777a910 100644
--- a/libdtrace/dt_parser.c
+++ b/libdtrace/dt_parser.c
@@ -1227,6 +1227,21 @@ dt_node_is_actfunc(const dt_node_t *dnp)
 	    dnp->dn_ident->di_kind == DT_IDENT_ACTFUNC;
 }
 
+int
+dt_node_is_tstring(const dt_node_t *dnp)
+{
+	switch (dnp->dn_kind) {
+	default:
+		return 0;
+	case DT_NODE_FUNC:
+	case DT_NODE_OP1:
+	case DT_NODE_OP2:
+	case DT_NODE_OP3:
+	case DT_NODE_DEXPR:
+		return dnp->dn_tstring != NULL;
+	}
+}
+
 /*
  * The original rules for integer constant typing are described in K&R[A2.5.1].
  * However, since we support long long, we instead use the rules from ISO C99
diff --git a/libdtrace/dt_parser.h b/libdtrace/dt_parser.h
index 13f3cc99..ff32a84a 100644
--- a/libdtrace/dt_parser.h
+++ b/libdtrace/dt_parser.h
@@ -182,6 +182,7 @@ extern int dt_node_is_ptrcompat(const dt_node_t *, const dt_node_t *,
 extern int dt_node_is_argcompat(const dt_node_t *, const dt_node_t *);
 extern int dt_node_is_posconst(const dt_node_t *);
 extern int dt_node_is_actfunc(const dt_node_t *);
+extern int dt_node_is_tstring(const dt_node_t *);
 
 extern dt_node_t *dt_node_int(uintmax_t);
 extern dt_node_t *dt_node_string(char *);
-- 
2.45.2




More information about the DTrace-devel mailing list