public inbox for dtrace@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 2/3] usdt parser: handle encoded hyphens
@ 2025-06-24 21:40 Kris Van Hees
  2025-06-30 21:53 ` [DTrace-devel] " Eugene Loh
  2025-07-15 14:21 ` Nick Alcock
  0 siblings, 2 replies; 4+ messages in thread
From: Kris Van Hees @ 2025-06-24 21:40 UTC (permalink / raw)
  To: dtrace, dtrace-devel

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
 libcommon/usdt_parser_notes.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libcommon/usdt_parser_notes.c b/libcommon/usdt_parser_notes.c
index fb57f119..d3d744fb 100644
--- a/libcommon/usdt_parser_notes.c
+++ b/libcommon/usdt_parser_notes.c
@@ -471,6 +471,23 @@ parse_usdt_note(int out, dof_helper_t *dhp, usdt_data_t *data,
 	}
 	prbt.off = off;
 
+	/*
+	 * If the probe name has encoded hyphens, perform in-place changing
+	 * from "__" into "-".
+	 */
+	if (strstr(prbt.prb, "__") != NULL) {
+		char		*q;
+		const char	*s = prbt.prb, *e = p;
+
+		for (q = (char *)s; s < e; s++, q++) {
+			if (s[0] == '_' && s[1] == '_') {
+				*q = '-';
+				s++;
+			} else if (s > q)
+				*q = *s;
+		}
+	}
+
 	if ((prp = dt_htab_lookup(prbmap, &prbt)) == NULL) {
 		if ((prp = malloc(sizeof(dt_probe_t))) == NULL) {
 			usdt_error(out, ENOMEM, "Failed to allocate probe");
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [DTrace-devel] [PATCH 2/3] usdt parser: handle encoded hyphens
  2025-06-24 21:40 [PATCH 2/3] usdt parser: handle encoded hyphens Kris Van Hees
@ 2025-06-30 21:53 ` Eugene Loh
  2025-06-30 23:07   ` Kris Van Hees
  2025-07-15 14:21 ` Nick Alcock
  1 sibling, 1 reply; 4+ messages in thread
From: Eugene Loh @ 2025-06-30 21:53 UTC (permalink / raw)
  To: dtrace, dtrace-devel

I would expect a patch like this to have a test to checks the behavior.

On 6/24/25 17:40, Kris Van Hees via DTrace-devel wrote:
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
>   libcommon/usdt_parser_notes.c | 17 +++++++++++++++++
>   1 file changed, 17 insertions(+)
>
> diff --git a/libcommon/usdt_parser_notes.c b/libcommon/usdt_parser_notes.c
> index fb57f119..d3d744fb 100644
> --- a/libcommon/usdt_parser_notes.c
> +++ b/libcommon/usdt_parser_notes.c
> @@ -471,6 +471,23 @@ parse_usdt_note(int out, dof_helper_t *dhp, usdt_data_t *data,
>   	}
>   	prbt.off = off;
>   
> +	/*
> +	 * If the probe name has encoded hyphens, perform in-place changing
> +	 * from "__" into "-".
> +	 */
> +	if (strstr(prbt.prb, "__") != NULL) {
> +		char		*q;
> +		const char	*s = prbt.prb, *e = p;
> +
> +		for (q = (char *)s; s < e; s++, q++) {
> +			if (s[0] == '_' && s[1] == '_') {
> +				*q = '-';
> +				s++;
> +			} else if (s > q)
> +				*q = *s;
> +		}
> +	}
> +
>   	if ((prp = dt_htab_lookup(prbmap, &prbt)) == NULL) {
>   		if ((prp = malloc(sizeof(dt_probe_t))) == NULL) {
>   			usdt_error(out, ENOMEM, "Failed to allocate probe");

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [DTrace-devel] [PATCH 2/3] usdt parser: handle encoded hyphens
  2025-06-30 21:53 ` [DTrace-devel] " Eugene Loh
@ 2025-06-30 23:07   ` Kris Van Hees
  0 siblings, 0 replies; 4+ messages in thread
From: Kris Van Hees @ 2025-06-30 23:07 UTC (permalink / raw)
  To: Eugene Loh; +Cc: dtrace, dtrace-devel

On Mon, Jun 30, 2025 at 05:53:04PM -0400, Eugene Loh via DTrace-devel wrote:
> I would expect a patch like this to have a test to checks the behavior.

It does not need one because we already have one:

test/unittest/usdt/tst.entryreturn.sh

thoug that test does not quite pass yet due to other issues (still xfail).

But that test no longer causes the parser to complain that it cannot find
the probe (and abort).  If you prefer I can certainly add a test for this
bug explicitly, though it essentially be quite similar to this case, but
it would be able to capture whether we encounter the parsing error or not
I think, so possible if preferred.  But the test mentioned above certainly
cannot ever pass without this patch.

> On 6/24/25 17:40, Kris Van Hees via DTrace-devel wrote:
> > Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> > ---
> >   libcommon/usdt_parser_notes.c | 17 +++++++++++++++++
> >   1 file changed, 17 insertions(+)
> > 
> > diff --git a/libcommon/usdt_parser_notes.c b/libcommon/usdt_parser_notes.c
> > index fb57f119..d3d744fb 100644
> > --- a/libcommon/usdt_parser_notes.c
> > +++ b/libcommon/usdt_parser_notes.c
> > @@ -471,6 +471,23 @@ parse_usdt_note(int out, dof_helper_t *dhp, usdt_data_t *data,
> >   	}
> >   	prbt.off = off;
> > +	/*
> > +	 * If the probe name has encoded hyphens, perform in-place changing
> > +	 * from "__" into "-".
> > +	 */
> > +	if (strstr(prbt.prb, "__") != NULL) {
> > +		char		*q;
> > +		const char	*s = prbt.prb, *e = p;
> > +
> > +		for (q = (char *)s; s < e; s++, q++) {
> > +			if (s[0] == '_' && s[1] == '_') {
> > +				*q = '-';
> > +				s++;
> > +			} else if (s > q)
> > +				*q = *s;
> > +		}
> > +	}
> > +
> >   	if ((prp = dt_htab_lookup(prbmap, &prbt)) == NULL) {
> >   		if ((prp = malloc(sizeof(dt_probe_t))) == NULL) {
> >   			usdt_error(out, ENOMEM, "Failed to allocate probe");
> 
> _______________________________________________
> DTrace-devel mailing list
> DTrace-devel@oss.oracle.com
> https://oss.oracle.com/mailman/listinfo/dtrace-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [DTrace-devel] [PATCH 2/3] usdt parser: handle encoded hyphens
  2025-06-24 21:40 [PATCH 2/3] usdt parser: handle encoded hyphens Kris Van Hees
  2025-06-30 21:53 ` [DTrace-devel] " Eugene Loh
@ 2025-07-15 14:21 ` Nick Alcock
  1 sibling, 0 replies; 4+ messages in thread
From: Nick Alcock @ 2025-07-15 14:21 UTC (permalink / raw)
  To: Kris Van Hees via DTrace-devel; +Cc: dtrace, Kris Van Hees

On 24 Jun 2025, Kris Van Hees via DTrace-devel outgrape:

> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>

How did I miss this case? And yes, no probe with embedded hyphens will
work without this (such as foo-entry above): they'll show up, but as
e.g. foo__entry instead.

You could probably make the test fail by explicitly naming one of those
hyphenated probes in the D script: right now, the script just uses
wildcards, which will catch everything whether the de-double-underscore
code kicks in or not.

> ---
>  libcommon/usdt_parser_notes.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
>
> diff --git a/libcommon/usdt_parser_notes.c b/libcommon/usdt_parser_notes.c
> index fb57f119..d3d744fb 100644
> --- a/libcommon/usdt_parser_notes.c
> +++ b/libcommon/usdt_parser_notes.c
> @@ -471,6 +471,23 @@ parse_usdt_note(int out, dof_helper_t *dhp, usdt_data_t *data,
>  	}
>  	prbt.off = off;
>  
> +	/*
> +	 * If the probe name has encoded hyphens, perform in-place changing
> +	 * from "__" into "-".
> +	 */
> +	if (strstr(prbt.prb, "__") != NULL) {
> +		char		*q;
> +		const char	*s = prbt.prb, *e = p;
> +
> +		for (q = (char *)s; s < e; s++, q++) {
> +			if (s[0] == '_' && s[1] == '_') {
> +				*q = '-';
> +				s++;
> +			} else if (s > q)
> +				*q = *s;
> +		}
> +	}
> +

This seems OK to me. I mean, fairly horrible, but C string handling *is*
fairly horrible. :)

-- 
NULL && (void)

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-07-15 14:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24 21:40 [PATCH 2/3] usdt parser: handle encoded hyphens Kris Van Hees
2025-06-30 21:53 ` [DTrace-devel] " Eugene Loh
2025-06-30 23:07   ` Kris Van Hees
2025-07-15 14:21 ` Nick Alcock

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox