[DTrace-devel] [PATCH 15/20] Add support for string constants in compiled D programs
Eugene Loh
eugene.loh at oracle.com
Sat Jun 5 23:37:13 PDT 2021
Oops. Here's another one:
On 6/2/21 1:48 AM, Kris Van Hees wrote:
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> @@ -1935,8 +1927,27 @@ dt_cg_store_var(dt_node_t *src, dt_irlist_t *dlp, dt_regset_t *drp,
>
> /* store by value or by reference */
> if (src->dn_flags & DT_NF_REF) {
> + size_t size;
> +
> emit(dlp, BPF_ALU64_IMM(BPF_ADD, reg, idp->di_offset));
> - dt_cg_memcpy(dlp, drp, reg, src->dn_reg, idp->di_size);
> +
> + /*
> + * Determine the amount of data to be copied. It is
> + * usually the size of the identifier, except for
> + * string constants where it is the size of the string
> + * constant (adjusted for the variable-width length
> + * prefix). An assignment of a string constant is a
> + * store of type 'string' with a RHS of type
> + * DT_TOK_STRING.
> + */
> + if (dt_node_is_string(src) &&
> + src->dn_right->dn_op == DT_TOK_STRING) {
> + size = dt_node_type_size(src->dn_right);
> + size += dt_vint_size(size) + 1;
dt_node_type_size() already includes a byte for the terminating NULL.
So the size+= line should not include the +1.
> + } else
> + size = idp->di_size;
> +
> + dt_cg_memcpy(dlp, drp, reg, src->dn_reg, size);
> } else {
> size_t size = idp->di_size;
>
More information about the DTrace-devel
mailing list