[DTrace-devel] [PATCH] Allow tstrings to persist across clause boundaries within a program
Kris Van Hees
kris.van.hees at oracle.com
Tue Nov 2 05:35:23 UTC 2021
The upcoming strtok() implementation has a need to store the string to
be tokenized in a temporary string (tstring). The strtok() semantics
require that source string to persist across clause boundaries within
a given probe firing. That means the tstrings needs to persist for
the duration of the probe program.
Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
libdtrace/dt_cc.c | 2 ++
libdtrace/dt_cg.c | 3 +--
libdtrace/dt_impl.h | 2 ++
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/libdtrace/dt_cc.c b/libdtrace/dt_cc.c
index a25f3548..08bc9438 100644
--- a/libdtrace/dt_cc.c
+++ b/libdtrace/dt_cc.c
@@ -1996,6 +1996,8 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg,
"not referenced)\n", yypcb->pcb_sargv[argc - 1], argc - 1);
}
+ dt_cg_tstring_reset(dtp);
+
/*
* If we have successfully created a parse tree for a D program, loop
* over the clauses and actions and instantiate the corresponding
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index 0196b114..6a4500a5 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -801,7 +801,7 @@ dt_cg_spill_load(int reg)
/*
* Initialize the temporary string offsets and mark all not in use.
*/
-static void
+void
dt_cg_tstring_reset(dtrace_hdl_t *dtp)
{
int i;
@@ -5654,7 +5654,6 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
}
dt_regset_reset(pcb->pcb_regs);
- dt_cg_tstring_reset(pcb->pcb_hdl);
dt_irlist_destroy(&pcb->pcb_ir);
dt_irlist_create(&pcb->pcb_ir);
diff --git a/libdtrace/dt_impl.h b/libdtrace/dt_impl.h
index b461d73d..3be62657 100644
--- a/libdtrace/dt_impl.h
+++ b/libdtrace/dt_impl.h
@@ -760,6 +760,8 @@ extern dtrace_difo_t *dt_dlib_get_func_difo(dtrace_hdl_t *, const dt_ident_t *);
extern void dt_dlib_reset(dtrace_hdl_t *dtp, boolean_t);
extern int dt_load_libs(dtrace_hdl_t *dtp);
+extern void dt_cg_tstring_reset(dtrace_hdl_t *dtp);
+
extern void *dt_compile(dtrace_hdl_t *dtp, int context,
dtrace_probespec_t pspec, void *arg, uint_t cflags,
int argc, char *const argv[], FILE *fp, const char *s);
--
2.33.0
More information about the DTrace-devel
mailing list