[DTrace-devel] [PATCH v2 17/17] strings: handle null strings in the ternary conditional op
Nick Alcock
nick.alcock at oracle.com
Mon Mar 14 21:30:25 UTC 2022
This will fault if the result is a null string now that dt_cg_memcpy is
error-checked. (It is not enough to make strings work: dt_cg_store_var
is doing the same thing, preventing you even *assigning* NULL to a
string. Not sure how to fix that.)
Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
libdtrace/dt_cg.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
index c940ce7b8bc6..0084798bcde6 100644
--- a/libdtrace/dt_cg.c
+++ b/libdtrace/dt_cg.c
@@ -3478,6 +3478,10 @@ dt_cg_ternary_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
* dn_right).
*/
if (dt_node_is_string(dnp)) {
+ uint_t lbl_null = dt_irlist_label(dlp);
+
+ emit(dlp, BPF_BRANCH_IMM(BPF_JEQ, dnp->dn_reg, 0, lbl_null));
+
/*
* At this point, dnp->dn_reg holds a pointer to the string we
* need to copy. But we want to copy it into a tstring which
@@ -3494,6 +3498,8 @@ dt_cg_ternary_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
dt_cg_memcpy(dlp, drp, dnp->dn_reg, BPF_REG_0,
yypcb->pcb_hdl->dt_options[DTRACEOPT_STRSIZE]);
+ emitl(dlp, lbl_null,
+ BPF_NOP());
dt_cg_tstring_free(yypcb, dnp->dn_left);
dt_cg_tstring_free(yypcb, dnp->dn_right);
}
--
2.35.1.261.g8402f930ba.dirty
More information about the DTrace-devel
mailing list