-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add BPFTRACE_STACK_MODE env variable #2586
Conversation
Not sure where to add unit tests for this. |
I think that runtime tests (e.g. in |
@@ -553,6 +554,11 @@ Default: `..` | |||
|
|||
Trailer to add to strings that were truncated. Set to empty string to disable truncation trailers. | |||
|
|||
### 9.11 `BPFTRACE_STACK_MODE` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also update bpftrace.adoc . (We really have to unify it one of these days)
|
||
Default: bpftrace | ||
|
||
Output format for ustack and kstack builtins. Available modes/formats: `bpftrace`, `perf`, and `raw`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps also mention that it's still override-able at call sites?
I don't see a way to verify the ustack or kstack output easily. The current ustack test just checks that the probe is attached. I could add something like this just to ensure bpftrace doesn't vomit but I don't know how useful it is:
|
Could you verify that any kstack/ustack was printed in the correct format?
|
I worry that the output might change slightly and then the regex would fail e.g. here is the output for this:
|
But you're using the |
I was just using that as an example of the output. As the regexes for all would need to start with something that looked like this
Feels fragile |
I don't think so, the regex should be matched against every line of the output. |
Well, I don't quite understand HOW it passes but it does :) E.g. why doesn't the check fail for the line "Attaching 1 probe..." against this regex |
fe7c0bd
to
cf31b7d
Compare
I think the regex only has to match a single line: https://github.com/iovisor/bpftrace/blob/8e9853fb015e62968cde853dc8c1cdca8c68fec8/tests/runtime/engine/runner.py#L251 which would match my experience (IIRC) So I’m not sure having perf/raw/bpftrace regex is correct. |
I guess it depends how much extra noise we get outside of the single stack trace that we think might pollute the results. The tests I added seem to do the right thing and fail if we change the StackMode... |
Agreed with @jordalgo, the added regexes are specific enough to avoid matching anything outside of the expected stack trace. |
Summary: This is so users can more easily set the global output for their stacks rather than repeating the same string for every invocation of ustack or kstack Test Plan: Tested locally. ``` BPFTRACE_STACK_MODE=tomato sudo ./src/bpftrace -e 'kprobe:do_nanosleep { printf("Jordan\n%s\n", ustack()); }' ERROR: Env var 'BPFTRACE_STACK_MODE' did not contain a valid StackMode: tomato ``` ``` BPFTRACE_STACK_MODE=perf sudo ./src/bpftrace -e 'kprobe:do_nanosleep { printf("Jordan\n%s\n", ustack()); }' Attaching 1 probe... Jordan 7f088cae85b3 __clock_nanosleep+99 (/usr/local/fbcode/platform010-compat/lib/libc.so.6) 7f088caed253 __nanosleep+19 (/usr/local/fbcode/platform010-compat/lib/libc.so.6) 1f3418b scribe::common::sink::QueueSink::sendLoop(scribe::common::sink::detail::BatchQueue*, int)+2971 (/usr/local/fbprojects/scribe/bin/scribed) 6187e12 folly::ThreadedExecutor::work(folly::Function<void ()>&)+82 (/usr/local/fbprojects/scribe/bin/scribed) 7f088cedf2e5 execute_native_thread_routine+21 (/usr/local/fbcode/platform010-compat/lib/libstdc++.so.6.0.29) 7f088ca979bf start_thread+559 (/usr/local/fbcode/platform010-compat/lib/libc.so.6) 7f088cb288ac __GI___clone3+44 (/usr/local/fbcode/platform010-compat/lib/libc.so.6) ``` Reviewers: Subscribers: Tasks: Tags:
Summary:
This is so users can more easily set the global output for their stacks rather than repeating the same string for every invocation of ustack or kstack
Test Plan:
Tested locally.
Reviewers:
Subscribers:
Tasks:
Tags:
Checklist
man/adoc/bpftrace.adoc
and if needed indocs/reference_guide.md
CHANGELOG.md