[DTrace-devel] [PATCH 14/16] cg: allow declaring variables from trampolines
Eugene Loh
eugene.loh at oracle.com
Thu Jan 18 20:43:23 UTC 2024
I do not really understand this stuff but...
Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
On 1/12/24 19:24, Kris Van Hees via DTrace-devel wrote:
> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
> libdtrace/dt_cg.c | 39 +++++++++++++++++++++++++++++++++++++++
> libdtrace/dt_cg.h | 1 +
> 2 files changed, 40 insertions(+)
>
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index 227b4b3c..b898cfaf 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -663,6 +663,45 @@ dt_cg_tramp_var(const char *name)
> return dnp;
> }
>
> +void
> +dt_cg_tramp_decl_var(dt_pcb_t *pcb, dt_ident_t *idp)
> +{
> + dtrace_hdl_t *dtp = pcb->pcb_hdl;
> + dt_idhash_t *dhp;
> + uint_t id;
> + dtrace_typeinfo_t dtt;
> +
> +
> + if (idp->di_flags & DT_IDFLG_LOCAL)
> + dhp = pcb->pcb_locals;
> + else if (idp->di_flags & DT_IDFLG_TLS)
> + dhp = dtp->dt_tls;
> + else
> + dhp = dtp->dt_globals;
> +
> + if (dt_idhash_lookup(dhp, idp->di_name))
> + return;
> +
> + if (dt_idhash_nextid(dhp, &id) == -1)
> + xyerror(D_ID_OFLOW, "cannot create %s: limit on number of "
> + "%s variables exceeded\n", idp->di_name,
> + dt_idhash_name(dhp));
> +
> + if (dt_idhash_insert(dhp, idp->di_name, idp->di_kind, idp->di_flags,
> + id, idp->di_attr, idp->di_vers,
> + idp->di_ops ? idp->di_ops : &dt_idops_thaw,
> + idp->di_iarg, 0) == NULL)
> + longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
> +
> + idp = dt_idhash_lookup(dhp, idp->di_name);
> + assert(idp != NULL);
> + if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_EVERY, idp->di_iarg,
> + &dtt) == -1)
> + longjmp(yypcb->pcb_jmpbuf, EDT_CTF);
> +
> + dt_ident_type_assign(idp, dtt.dtt_ctfp, dtt.dtt_type);
> +}
> +
> /*
> * Generate code to store the value (or address of the named variable in
> * register 'reg'.
> diff --git a/libdtrace/dt_cg.h b/libdtrace/dt_cg.h
> index 3d0f3618..6d895731 100644
> --- a/libdtrace/dt_cg.h
> +++ b/libdtrace/dt_cg.h
> @@ -27,6 +27,7 @@ extern void dt_cg_tramp_copy_regs(dt_pcb_t *pcb);
> extern void dt_cg_tramp_copy_args_from_regs(dt_pcb_t *pcb, int called);
> extern void dt_cg_tramp_copy_pc_from_regs(dt_pcb_t *pcb);
> extern void dt_cg_tramp_copy_rval_from_regs(dt_pcb_t *pcb);
> +extern void dt_cg_tramp_decl_var(dt_pcb_t *pcb, dt_ident_t *idp);
> extern void dt_cg_tramp_get_var(dt_pcb_t *pcb, const char *name, int isstore,
> int reg);
> extern void dt_cg_tramp_del_var(dt_pcb_t *pcb, const char *name);
More information about the DTrace-devel
mailing list