* [PATCH] bpf: be less picky about the content of bpf_helper_defs.h
@ 2024-05-06 19:05 Kris Van Hees
2024-05-06 19:10 ` Nick Alcock
2024-05-06 19:43 ` Eugene Loh
0 siblings, 2 replies; 4+ messages in thread
From: Kris Van Hees @ 2024-05-06 19:05 UTC (permalink / raw)
To: dtrace, dtrace-devel
There are small differences in the format of the BPF helper definitions
in bpf_helper_defs.h in libbpf headers. This patch allows mkHelpers to
be more accepting of these differences.
Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
include/mkHelpers | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/include/mkHelpers b/include/mkHelpers
index 1a7537ca..dc5e62c8 100755
--- a/include/mkHelpers
+++ b/include/mkHelpers
@@ -8,14 +8,15 @@ BEGIN {
}
$1 == "static" && /=/ && /[ \t]+[1-9][0-9]*[ \t]*;/ {
- match($0, /[ \t]+[1-9][0-9]*[ \t]*;/);
- id = substr($0, RSTART, RLENGTH - 1);
- gsub(/[ \t]+/,"", id);
- match($0, /\([ \t]*\*[ \t]*bpf_[_A-Za-z0-9]+/);
- fn = substr($0, RSTART + 1, RLENGTH - 1);
- sub(/[ \t]*\*[ \t]*bpf_/, "", fn);
+ if (match($0, /[ \t\*]bpf_[_A-Za-z0-9]+/) > 0) {
+ fn = substr($0, RSTART + 5, RLENGTH - 5);
- print "#define BPF_FUNC_"fn " " id;
+ match($0, /[ \t]+[1-9][0-9]*[ \t]*;/);
+ id = substr($0, RSTART, RLENGTH - 1);
+ gsub(/[ \t]+/,"", id);
+
+ print "#define BPF_FUNC_"fn " " id;
+ }
}
END {
--
2.42.0
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] bpf: be less picky about the content of bpf_helper_defs.h
2024-05-06 19:05 [PATCH] bpf: be less picky about the content of bpf_helper_defs.h Kris Van Hees
@ 2024-05-06 19:10 ` Nick Alcock
2024-05-06 19:43 ` Eugene Loh
1 sibling, 0 replies; 4+ messages in thread
From: Nick Alcock @ 2024-05-06 19:10 UTC (permalink / raw)
To: Kris Van Hees; +Cc: dtrace, dtrace-devel
On 6 May 2024, Kris Van Hees verbalised:
> There are small differences in the format of the BPF helper definitions
> in bpf_helper_defs.h in libbpf headers. This patch allows mkHelpers to
> be more accepting of these differences.
... looks like it does that to me, and just as importantly doesn't emit
rubbish if the match fails.
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
Reviewed-by: Nick Alcock <nick.alcock@oracle.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] bpf: be less picky about the content of bpf_helper_defs.h
2024-05-06 19:05 [PATCH] bpf: be less picky about the content of bpf_helper_defs.h Kris Van Hees
2024-05-06 19:10 ` Nick Alcock
@ 2024-05-06 19:43 ` Eugene Loh
2024-05-06 20:33 ` Kris Van Hees
1 sibling, 1 reply; 4+ messages in thread
From: Eugene Loh @ 2024-05-06 19:43 UTC (permalink / raw)
To: dtrace, dtrace-devel
Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
One possibility, however, is to regularize the input line with regards
to spaces and tabs. E.g., start with
{ gsub("[ \t]+", " ") }
Then, subsequent string processing can forget about that \t stuff and
will presumably be that much more simple and readable.
On 5/6/24 15:05, Kris Van Hees wrote:
> There are small differences in the format of the BPF helper definitions
> in bpf_helper_defs.h in libbpf headers. This patch allows mkHelpers to
> be more accepting of these differences.
>
> Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
> include/mkHelpers | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/include/mkHelpers b/include/mkHelpers
> index 1a7537ca..dc5e62c8 100755
> --- a/include/mkHelpers
> +++ b/include/mkHelpers
> @@ -8,14 +8,15 @@ BEGIN {
> }
>
> $1 == "static" && /=/ && /[ \t]+[1-9][0-9]*[ \t]*;/ {
> - match($0, /[ \t]+[1-9][0-9]*[ \t]*;/);
> - id = substr($0, RSTART, RLENGTH - 1);
> - gsub(/[ \t]+/,"", id);
> - match($0, /\([ \t]*\*[ \t]*bpf_[_A-Za-z0-9]+/);
> - fn = substr($0, RSTART + 1, RLENGTH - 1);
> - sub(/[ \t]*\*[ \t]*bpf_/, "", fn);
> + if (match($0, /[ \t\*]bpf_[_A-Za-z0-9]+/) > 0) {
> + fn = substr($0, RSTART + 5, RLENGTH - 5);
>
> - print "#define BPF_FUNC_"fn " " id;
> + match($0, /[ \t]+[1-9][0-9]*[ \t]*;/);
> + id = substr($0, RSTART, RLENGTH - 1);
> + gsub(/[ \t]+/,"", id);
> +
> + print "#define BPF_FUNC_"fn " " id;
> + }
> }
>
> END {
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] bpf: be less picky about the content of bpf_helper_defs.h
2024-05-06 19:43 ` Eugene Loh
@ 2024-05-06 20:33 ` Kris Van Hees
0 siblings, 0 replies; 4+ messages in thread
From: Kris Van Hees @ 2024-05-06 20:33 UTC (permalink / raw)
To: Eugene Loh; +Cc: dtrace, dtrace-devel
On Mon, May 06, 2024 at 03:43:19PM -0400, Eugene Loh wrote:
> Reviewed-by: Eugene Loh <eugene.loh@oracle.com>
>
> One possibility, however, is to regularize the input line with regards to
> spaces and tabs. E.g., start with
>
> { gsub("[ \t]+", " ") }
>
> Then, subsequent string processing can forget about that \t stuff and will
> presumably be that much more simple and readable.
Yes, but means we modify every line, which we do not really need to do. I
guess it's one trade-off vs another. The gsub you mention only really helps
drop \t becauxe you still need to account for places where whitespace is
optional.
> On 5/6/24 15:05, Kris Van Hees wrote:
> > There are small differences in the format of the BPF helper definitions
> > in bpf_helper_defs.h in libbpf headers. This patch allows mkHelpers to
> > be more accepting of these differences.
> >
> > Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
> > ---
> > include/mkHelpers | 15 ++++++++-------
> > 1 file changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/include/mkHelpers b/include/mkHelpers
> > index 1a7537ca..dc5e62c8 100755
> > --- a/include/mkHelpers
> > +++ b/include/mkHelpers
> > @@ -8,14 +8,15 @@ BEGIN {
> > }
> > $1 == "static" && /=/ && /[ \t]+[1-9][0-9]*[ \t]*;/ {
> > - match($0, /[ \t]+[1-9][0-9]*[ \t]*;/);
> > - id = substr($0, RSTART, RLENGTH - 1);
> > - gsub(/[ \t]+/,"", id);
> > - match($0, /\([ \t]*\*[ \t]*bpf_[_A-Za-z0-9]+/);
> > - fn = substr($0, RSTART + 1, RLENGTH - 1);
> > - sub(/[ \t]*\*[ \t]*bpf_/, "", fn);
> > + if (match($0, /[ \t\*]bpf_[_A-Za-z0-9]+/) > 0) {
> > + fn = substr($0, RSTART + 5, RLENGTH - 5);
> > - print "#define BPF_FUNC_"fn " " id;
> > + match($0, /[ \t]+[1-9][0-9]*[ \t]*;/);
> > + id = substr($0, RSTART, RLENGTH - 1);
> > + gsub(/[ \t]+/,"", id);
> > +
> > + print "#define BPF_FUNC_"fn " " id;
> > + }
> > }
> > END {
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-06 20:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-06 19:05 [PATCH] bpf: be less picky about the content of bpf_helper_defs.h Kris Van Hees
2024-05-06 19:10 ` Nick Alcock
2024-05-06 19:43 ` Eugene Loh
2024-05-06 20:33 ` Kris Van Hees
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox