Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apparser: Improve error messages when APs are missing commas #2781

Merged
merged 3 commits into from
Oct 2, 2023

Conversation

danobi
Copy link
Member

@danobi danobi commented Sep 30, 2023

See individual commits for more details.

Checklist
  • Language changes are updated in man/adoc/bpftrace.adoc and if needed in docs/reference_guide.md
  • User-visible and non-trivial changes updated in CHANGELOG.md
  • The new behaviour is covered by tests

Given the following script (that's missing a comma):

```
kfunc:xfrm4_esp_rcv
kfunc:xfrm4_rcv
{
    exit()
}
```

you get this error:

```
Attaching 1 probe...
ERROR: No BTF found for xfrm4_rcv
```

which is too vague.

This is b/c the parser effectively ignores spaces and combines the two
attachpoints into one string (sans space) when creating the
input to AttachPointParser. This is an unfortunate result of the
attachpoint parser design.

It's a bit too unwieldy to teach the parser about spaces (cuz we'd have
to sprinkle it everywhere), so opt to do the next best thing and have a
slightly more informative error instead.

With this commit, the error is now:

```
Attaching 1 probe...
ERROR: No BTF found for xfrm4_esp_rcvkfunc:xfrm4_rcv
```

which should provide a better hint to the user.
@danobi danobi added the do-not-squash Do not squash PR commits label Sep 30, 2023
Given the following script (that's missing a comma):

```
t:syscalls:sys_enter_openat
t:syscalls:sys_exit_openat
{
    exit();
}
```

you get this error:

```
repro.bt:1-2: ERROR: tracepoint probe type requires 2 arguments
```

This is too ambiguous.

The underlying reason is b/c the parser effectively ignores spaces and
combines the two attachpoints into one string (sans space) when creating
the input to AttachPointParser. This is an unfortunate result of the
attachpoint parser design.

It's a bit too unwieldy to teach the parser about spaces (cuz we'd have
to sprinkle it everywhere), so opt to do the next best thing and have a
slightly more informative error instead.

With this commit, the error is now:

```
repro.bt:1-2: ERROR: tracepoint probe type requires 2 arguments, found 4
```

which should provide a better hint to the user.
@viktormalik viktormalik merged commit 313eef9 into bpftrace:master Oct 2, 2023
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-squash Do not squash PR commits
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants