[DTrace-devel] [PATCH 1/4] cg, providers: refactor clearing probe arguments

Eugene Loh eugene.loh at oracle.com
Thu Dec 18 19:12:01 UTC 2025


Two things...

On 12/17/25 00:09, Kris Van Hees via DTrace-devel wrote:

> Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
> ---
>   libdtrace/dt_cg.c           | 34 +++++++++++++++++++++++++++++++---
>   libdtrace/dt_cg.h           |  1 +
>   libdtrace/dt_prov_cpc.c     | 17 -----------------
>   libdtrace/dt_prov_dtrace.c  |  8 ++------
>   libdtrace/dt_prov_profile.c | 23 +----------------------
>   libdtrace/dt_prov_syscall.c | 10 ++--------

Is there also another clean-up site in dt_prov_sdt.c in trampoline()?

> diff --git a/libdtrace/dt_cg.c b/libdtrace/dt_cg.c
> @@ -454,6 +454,32 @@ dt_cg_tramp_copy_regs(dt_pcb_t *pcb)
>   	}
>   }
>   
> +/*
> + * Clear the content of the 'argv' member of the machine state, from the given
> + * index (idx).
> + *
> + * The caller must ensure that %r7 contains the value set by the
> + * dt_cg_tramp_prologue*() functions.
> + */
> +void
> +dt_cg_tramp_clear_argv(dt_pcb_t *pcb, int idx)
> +{
> +	dt_irlist_t	*dlp = &pcb->pcb_ir;
> +	int		i, argc = ARRAY_SIZE(((dt_mstate_t *)0)->argv);
> +
> +	if (idx >= argc)
> +		return;
> +
> +	/*
> +	 *	memset(&dctx->mst->argv[idx], 0, sizeof(dt_pt_regs);
> +	 *				// stdw [%7 + DMST_ARG(idx)], 0
> +	 *				// stdw [%7 + DMST_ARG(idx + 1)], 0
> +	 *				//     (...)
> +	 */

Actually, the code is clearer and more concise than the comment. Plus, 
the comment is wrong?  What's sizeof(dt_pt_regs) doing in there?  Just 
drop the "memset" comment block.  The two lines of code speak for 
themselves.

> +	for (i = idx; i < argc; i++)
> +		emit(dlp, BPF_STORE_IMM(BPF_DW, BPF_REG_7, DMST_ARG(i), 0));
> +}



More information about the DTrace-devel mailing list