[DTrace-devel] [PATCH 6/7] Populate sdt probe argument data based on argument types
Kris Van Hees
kris.van.hees at oracle.com
Fri May 27 19:21:11 UTC 2022
On Fri, May 27, 2022 at 10:43:46AM -0700, Eugene Loh via DTrace-devel wrote:
> Reviewed-by: Eugene Loh <eugene.loh at oracle.com>
> with earlier comments about renaming dt_cg_load() and moving
> tst.args-match-argN.d to patch 5 adding a trigger.
> I am curious about one thing...
>
> On 5/26/22 11:24, Kris Van Hees via DTrace-devel wrote:
> > diff --git a/libdtrace/dt_prov_sdt.c b/libdtrace/dt_prov_sdt.c
> > @@ -143,17 +145,41 @@ static void trampoline(dt_pcb_t *pcb)
> > dt_cg_tramp_clear_regs(pcb);
> > /*
> > - * for (i = 0; i < argc; i++)
> > - * dctx->mst->argv[i] = ((uint64_t *)ctx)[i + 1];
> > - * // (first value is private)
> > - * // lddw %r0, [%r8 + (i + 1) * 8]
> > - * // stdw [%r7 + DMST_ARG(i)], 0
> > + * Decode the arguments of the underlying tracepoint (from the context)
> > + * and store them in the cached argument list in the mstate.
> > + *
> > + * Skip the first argument (a private pointer that we are not allowed
> > + * to access from BPF).
> What is being skipped? The loop starts at i=0.
See below...
> > */
> > - for (i = 0; i < pcb->pcb_pinfo.dtp_argc; i++) {
> > - emit(dlp, BPF_LOAD(BPF_DW, BPF_REG_0, BPF_REG_8, (i + 1) * 8));
> > - emit(dlp, BPF_STORE(BPF_DW, BPF_REG_7, DMST_ARG(i), BPF_REG_0));
> > + off = sizeof(uint64_t);
... this skips the first argument that we get from the tracepoint.
> > + for (i = 0; i < prp->argc; i++) {
> > + dt_node_t *anp = prp->xargv[i];
> > + ssize_t size = ctf_type_size(anp->dn_ctfp,
> > + anp->dn_type);
> > + ssize_t align = ctf_type_align(anp->dn_ctfp,
> > + anp->dn_type);
> > +
> > + off = P2ROUNDUP(off, align);
> > + if (dt_node_is_scalar(anp)) {
> > + uint_t ldsz = dt_cg_load(anp, anp->dn_ctfp,
> > + anp->dn_type, NULL);
> > +
> > + emit(dlp, BPF_LOAD(ldsz, BPF_REG_0, BPF_REG_8, off));
> > + emit(dlp, BPF_STORE(BPF_DW, BPF_REG_7, DMST_ARG(i), BPF_REG_0));
> > + } else {
> > + emit(dlp, BPF_MOV_REG(BPF_REG_0, BPF_REG_8));
> > + emit(dlp, BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, off));
> > + emit(dlp, BPF_STORE(BPF_DW, BPF_REG_7, DMST_ARG(i), BPF_REG_0));
> > + }
> > + off += size;
> > }
> > + */
> > +
> > +#pragma D option quiet
> > +
> > +write:entry {
> > + printf("%x vs %x\n", args[0], arg0);
> > + printf("%x vs %x\n", (uint64_t)args[1], arg1);
> > + printf("%x vs %x\n", args[2], arg2);
> > + exit(args[0] == arg0 && (uint64_t)args[1] == arg1 && args[2] == arg2 ? 0 : 1);
> > +}
> > +
> > +ERROR {
> > + exit(1);
> > +}
>
> _______________________________________________
> 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