[DTrace-devel] [PATCH] bpf: be less picky about the content of bpf_helper_defs.h
Kris Van Hees
kris.van.hees at oracle.com
Mon May 6 20:33:33 UTC 2024
On Mon, May 06, 2024 at 03:43:19PM -0400, Eugene Loh wrote:
> Reviewed-by: Eugene Loh <eugene.loh at 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 at 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 {
More information about the DTrace-devel
mailing list