[DTrace-devel] [PATCH v7 1/7] usdt: have copy_args() count args while parsing them

Kris Van Hees kris.van.hees at oracle.com
Tue Aug 5 15:04:02 UTC 2025


This patch still does not address the fact that we would like to have probe
argument count and type (if possible) at the probe_info level, which is well
before the trmmpoline is generated.  I'm posting a proposal for an alternative
patch that accomplishes that in a few (still testing).

Also, even without the arg info at probe_info level, this patch still would
unnecessarily set upp->sargc.  Non-stapsdt probes already have that value, and
stapsdt probes do not need the value in your series.

On Wed, Jul 30, 2025 at 10:01:42AM +0100, Alan Maguire wrote:
> stapsdt probes do not include an argument count, so the only
> way to count them is to parse the parameter string.  Adjust
> copy_args() to set upp->sargc while parsing upp->sargv.
> 
> Signed-off-by: Alan Maguire <alan.maguire at oracle.com>
> ---
>  libdtrace/dt_prov_uprobe.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/libdtrace/dt_prov_uprobe.c b/libdtrace/dt_prov_uprobe.c
> index 8e7aa4b0..b974e94b 100644
> --- a/libdtrace/dt_prov_uprobe.c
> +++ b/libdtrace/dt_prov_uprobe.c
> @@ -1153,9 +1153,9 @@ static void enable_usdt(dtrace_hdl_t *dtp, dt_probe_t *prp)
>  }
>  
>  /*
> - * Generate code that populates the probe arguments.
> + * Generate code that populates, counts the probe arguments.
>   */
> -static void copy_args(dt_pcb_t *pcb, const dt_uprobe_t *upp)
> +static void copy_args(dt_pcb_t *pcb, dt_uprobe_t *upp)
>  {
>  	dtrace_hdl_t	*dtp = pcb->pcb_hdl;
>  	dt_irlist_t	*dlp = &pcb->pcb_ir;
> @@ -1166,7 +1166,7 @@ static void copy_args(dt_pcb_t *pcb, const dt_uprobe_t *upp)
>  
>  	assert(pvp != NULL);
>  
> -	for (i = 0; i < upp->sargc; i++) {
> +	for (i = 0; *p != '\0'; i++) {
>  		int	ssize, disp, len;
>  		char	*reg = NULL;
>  		int64_t	val = 0;
> @@ -1433,6 +1433,7 @@ static void copy_args(dt_pcb_t *pcb, const dt_uprobe_t *upp)
>  			usdt_error(pcb, "Unknown format in arg%d spec", i);
>  #endif
>  	}
> +	upp->sargc = i;
>  }
>  
>  /*
> @@ -1453,7 +1454,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>  	dtrace_hdl_t		*dtp = pcb->pcb_hdl;
>  	dt_irlist_t		*dlp = &pcb->pcb_ir;
>  	const dt_probe_t	*uprp = pcb->pcb_probe;
> -	const dt_uprobe_t	*upp = uprp->prv_data;
> +	dt_uprobe_t		*upp = uprp->prv_data;
>  	const list_probe_t	*pop;
>  	uint_t			lbl_exit = pcb->pcb_exitlbl;
>  	dt_ident_t		*usdt_prids = dt_dlib_get_map(dtp, "usdt_prids");
> @@ -1527,7 +1528,7 @@ static int trampoline(dt_pcb_t *pcb, uint_t exitlbl)
>  	if (upp->flags & PP_IS_RETURN)
>  		goto out;
>  
> -	if (upp->sargc)
> +	if (upp->sargv)
>  		copy_args(pcb, upp);
>  	else
>  		dt_cg_tramp_copy_args_from_regs(pcb, 0);
> -- 
> 2.43.5
> 



More information about the DTrace-devel mailing list