-
Notifications
You must be signed in to change notification settings - Fork 48
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
feat(crit): add SearchPattern method on MemoryReader #163
feat(crit): add SearchPattern method on MemoryReader #163
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #163 +/- ##
==========================================
+ Coverage 48.13% 50.82% +2.68%
==========================================
Files 21 21
Lines 2279 1948 -331
==========================================
- Hits 1097 990 -107
+ Misses 1050 819 -231
- Partials 132 139 +7 ☔ View full report in Codecov by Sentry. |
That would kind of match the behaviour of grep. That is also what I would expect when searching for a pattern.
Maybe not as default, but with an additional option. Maybe like the context option from grep. Where you can say how many lines before and after the match. A whole page on the terminal sounds a lot, so if you let the user select how many bytes to show, that sounds like a useful option to me. |
2ae58cb
to
bdf1795
Compare
3fac1c7
to
4fc6dbc
Compare
I have updated the cc: @adrianreber , @rst0git , @snprajwal |
4fc6dbc
to
f5bc2dc
Compare
f5bc2dc
to
2a6f42a
Compare
@behouba dropping a note to check if you're still working on this :) |
Hi @snprajwal! Yes, I am still working on it :) |
2fcb3e8
to
5e500dd
Compare
6b29382
to
fdc9e7d
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.
LGTM
fdc9e7d
to
948b0c4
Compare
@behouba Thank you for working on this feature and updating the pull request! |
This commit adds a new method `SearchPattern` to `MemoryReader` to search for patterns inside the process memory pages. This method accept regular expressions for flexible pattern matching, a context (number of bytes before and after the pattern match), and a size of memory chunk to be read at a time. Signed-off-by: Kouame Behouba Manasse <[email protected]>
Signed-off-by: Kouame Behouba Manasse <[email protected]>
948b0c4
to
20dfec8
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.
LGTM
I am currently working on a feature to allow users to search for a pattern within process memory pages, as suggested by @rst0git last year. This could be used to extend
checkpointctl memparse
with search capability.Currently, the method
SearchPattern(pattern string) (uint64, error)
takes the pattern to search as an argument and returns the address of the first match along with an error if the pattern is not found. I am not sure about the implementation yet, and I'm considering alternative approaches:Instead of providing just the address of the first match, should we consider returning the entire memory pages where the pattern is found?
Another consideration is whether to return not just the first match but all occurrences of the pattern.
@rst0git, @adrianreber , @snprajwal PTAL.