-
-
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
Implement strstr #2393
Implement strstr #2393
Conversation
Pr was here before ( add strstr() by liutingjieni · Pull Request #2344 · iovisor/bpftrace ). Because of the conflict with master, so based on the latest master commit changes |
I see a check error, but I don't quite understand。what do I need to do now? |
In future, please keep updating the same PR (by force-push into the branch), opening a new one after each rebase is not a good idea.
Your new test is failing with segmentation fault, so you'll have to debug. If you want to reproduce the CI environment, you can build and use the prepared Docker images. Check |
I found that the error is build_test (LLVM 15 Release). I tried to remove the commit about it( Latest Commit) and I found that it works. |
Which could mean that your code doesn't work with LLVM 15 (very likely it doesn't work with opaque pointers). Please check and fix that. |
cdd20ae
to
b3298fa
Compare
all checks have passed. what else do I need to do now? |
This is a terrible solution. You can't just arbitrarily revert a commit from master if it doesn't suit you. You have to make your code work with opaque pointers. Once you do that, the checks will pass. |
I have changed my code with opaque pointers. The check for llvm15 has passed. The last two commit hashes from master have changed due to cherry-pick, but the code content has not changed. |
b3298fa
to
f226e1a
Compare
This branch is 1 commit ahead of iovisor:master. |
I want the code to be reviewed |
Ah, right, sorry. I'll review when I have time. |
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.
This looks fine for what it is but I have a meta question - why are we unrolling the loop?
For a char[32] vs char[32] call, this emits ~500 instructions.
> src/bpftrace -vv -e 't:mac80211:wake_queue {if (strstr(ar
gs->wiphy_name, args->wiphy_name)) {exit()}}'
INFO: node count: 13
Attaching 1 probe...
Program ID: 1422
The verifier log:
processed 522 insns (limit 1000000) max_states_per_insn 0 total_states 32 peak_states 32 mark_read 24
Given that bpf has had backward branches for ages, why don't we just emit this as an actual loop with known bounds and let the verifier do the hard work? It would dramatically improve complexity while potentially also allowing probed strings to work (by emitting the loop against the probe size limit or even against the runtime string length, assuming we can satisfy the verifier).
Agree but maybe we shouldn't block on it. For a future improvement it would also be nice if we compare more bytes at once |
4043278
to
c8a5028
Compare
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.
Could you also merge the two commits and cleanup the commit message?
Thanks!
11de8cc
to
1f29ecc
Compare
859936b
to
403b52f
Compare
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.
Since there has been a lot of work, I'd like to have one more review before merging this.
Since this is similar to #2387, I guess you may need to add the codegen tests and change the |
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.
looks good! Just a few suggestions on the testing side
a7984af
to
4b8b614
Compare
4b8b614
to
7baf8f9
Compare
This function compares whether the string val1 contains the string val2. It returns true if val2 is contained by val1, false if not contained.
7baf8f9
to
f710fd8
Compare
Add a new built-in func like strstr()
Add the strstr () function to make fuzzy comparisons when there is no way to confirm the absolute path of the file or the full name of the process or
usage:
sudo bpftrace -e 't:syscalls:sys_enter_execve /strstr(comm,"sh") == 0/ { printf("%s called %s\n", comm, str(args->filename));}'
Problem background: #2306
Checklist
man/adoc/bpftrace.adoc
and if needed indocs/reference_guide.md
CHANGELOG.md