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

Warn if attaching a kprobe to a non-traceable function #1835

Merged
merged 1 commit into from
May 15, 2021

Conversation

viktormalik
Copy link
Contributor

@viktormalik viktormalik commented May 10, 2021

Currently, when trying to attach a kprobe a non-traceable function, bpf_attach_kprobe will fail and we're relying on libbpf to print an error message. This error messgage may be confusing (see example in #1818) though, so it's better if we print our own warning to the user.

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

@viktormalik viktormalik force-pushed the warn-notrace-functions branch from 7a55ac7 to abdb0fb Compare May 10, 2021 12:33
Currently, bpf_attach_kprobe will fail and we are relying on libbpf to
provide an error message. This one may be confusing, though, so it is
better if we print our own warning to the user.

A similar check is already done for kfuncs, so this commit moves the
appropriate code from BTF to the BPFtrace class to unify it.
@viktormalik viktormalik force-pushed the warn-notrace-functions branch from abdb0fb to a8b2d1c Compare May 10, 2021 12:52
Copy link
Member

@danobi danobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall

@@ -24,6 +26,10 @@ class BTF

public:
BTF();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other callers of this? I'd rather BTF() only have one constructor so nobody forgets to pass BPFtrace*

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately yes, it's called from BPFfeature which doesn't have access to BPFtrace (bpffeature.cpp:199)

@fbs fbs merged commit 9734668 into bpftrace:master May 15, 2021
@viktormalik viktormalik deleted the warn-notrace-functions branch May 18, 2021 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants