All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: Re: [PATCH v5 1/6] usdt: have copy_args() count args while parsing them
Date: Fri, 25 Jul 2025 11:57:24 -0400	[thread overview]
Message-ID: <aIOpZMcLIE14zBzs@oracle.com> (raw)
In-Reply-To: <20250710215930.82067-2-alan.maguire@oracle.com>

On Thu, Jul 10, 2025 at 10:59:25PM +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.

I am looking at reworking this a bit.  The main challenge I see is that
it makes the overall copy_args() loop slower for *all* cases, not just
stapsdt.  At a minimum, replacing the strlen(p) with a check for *p != '\0'
might be better.

But there is also the issue that given how late copy_args() is executed,
setting sargc become a moot point.  It is not used after copy_args() is
called, so setting upp->sargc becomes pointless.

On the other hand, what we do want to know is how many arguments the probe
provides *before* we compile clauses, though in the adsence of real type
info, we could get away with not doing that.  Having the number of args
allows the use of args[n].

> Signed-off-by: Alan Maguire <alan.maguire@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 cf5cfd43..2cbd8910 100644
> --- a/libdtrace/dt_prov_uprobe.c
> +++ b/libdtrace/dt_prov_uprobe.c
> @@ -1145,9 +1145,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;
> @@ -1158,7 +1158,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; strlen(p) > 0; i++) {
>  		int	ssize, disp, len;
>  		char	*reg = NULL;
>  		int64_t	val = 0;
> @@ -1425,6 +1425,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;
>  }
>  
>  /*
> @@ -1445,7 +1446,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");
> @@ -1519,7 +1520,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
> 

  reply	other threads:[~2025-07-25 15:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-10 21:59 [PATCH v5 0/6] add support for stapsdt probes Alan Maguire
2025-07-10 21:59 ` [PATCH v5 1/6] usdt: have copy_args() count args while parsing them Alan Maguire
2025-07-25 15:57   ` Kris Van Hees [this message]
2025-07-10 21:59 ` [PATCH v5 2/6] support stapsdt ELF-note-defined static probes Alan Maguire
2025-07-26  4:04   ` Kris Van Hees
2025-07-10 21:59 ` [PATCH v5 3/6] selftests/usdt: add test for stapsdt note-defined probe firing, args Alan Maguire
2025-07-10 21:59 ` [PATCH v5 4/6] selftests/usdt: add test for stapsdt notes in shared library Alan Maguire
2025-07-10 21:59 ` [PATCH v5 5/6] selftests/usdt: add test covering different forms of stapsdt note args Alan Maguire
2025-07-10 21:59 ` [PATCH v5 6/6] selftests/usdt: add test for stapsdt note-defined probe firing in -fPIE binary Alan Maguire

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aIOpZMcLIE14zBzs@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=alan.maguire@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.