[DTrace-devel] [PATCH 3/7] Make dt_cg_ctf_offsetof() search across all modules, not just shared dict
Kris Van Hees
kris.van.hees at oracle.com
Mon Sep 25 18:18:09 UTC 2023
On Tue, Aug 22, 2023 at 05:51:10PM -0400, eugene.loh--- via DTrace-devel wrote:
> From: Eugene Loh <eugene.loh at oracle.com>
>
> The function dt_cg_ctf_offsetof() was searching just in the shared
> dict. Have it look for types across all modules.
>
> Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Kris Van Hees <kris.van.hees at oracle.com>
... with the inclusion of making dt_cg_ctf_offsetof() non-static and adding
an extern declaration to dt_cg.h without adding a dtrace_hdl_t *dtp argument.
... with changing cfp to be ctfp, which is more consistent with the rest of the
compiler code.
I am adding a version of this patch with those changing to my
kvh/2.0-branch-stage branch. Let me know if it looks OK.
> ---
> libdtrace/dt_cg.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> index ea7fb6d5..35feb887 100644
> --- a/libdtrace/dt_cg.c
> +++ b/libdtrace/dt_cg.c
> @@ -4190,19 +4190,22 @@ dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
> int
> dt_cg_ctf_offsetof(dtrace_hdl_t *dtp, const char *structname, const char *membername, size_t *sizep)
> {
> - ctf_file_t *cfp = dtp->dt_shared_ctf;
> - ctf_id_t type;
> + dtrace_typeinfo_t sym;
> + ctf_file_t *cfp;
> ctf_membinfo_t ctm;
>
> - if (!cfp)
> +// FIXME: add diagnostic info to the longjump paths?
> + if (dtrace_lookup_by_type(dtp, DTRACE_OBJ_EVERY, structname, &sym))
> longjmp(yypcb->pcb_jmpbuf, EDT_NOCTF);
> - type = ctf_lookup_by_name(cfp, structname);
> - if (type == CTF_ERR)
> +
> + cfp = sym.dtt_ctfp;
> + if (!cfp) // FIXME is this needed?
> longjmp(yypcb->pcb_jmpbuf, EDT_NOCTF);
> - if (ctf_member_info(cfp, type, membername, &ctm) == CTF_ERR)
> + if (ctf_member_info(cfp, sym.dtt_type, membername, &ctm) == CTF_ERR)
> longjmp(yypcb->pcb_jmpbuf, EDT_NOCTF);
> if (sizep)
> *sizep = ctf_type_size(cfp, ctm.ctm_type);
> +
> return (ctm.ctm_offset / NBBY);
> }
>
> --
> 2.18.4
>
>
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel at oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel
More information about the DTrace-devel
mailing list