-
-
Notifications
You must be signed in to change notification settings - Fork 741
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
[cmd] Allow for filtering about maps permissions in vmmap
#1111
base: main
Are you sure you want to change the base?
Conversation
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 be useful. We might want to add this as a flag argument though, e.g. vmmap --perms rwx
.
Maybe we could even support a 'don't care' e.g. r??
vs r--
, the former allowing rw-
, r-x
, etc. Maybe a good idea for a followup.
I think if we put this behind a flag, we should do it for the other filters too? But I think the idea of |
I'm marking this as draft until #1120 is merged |
9394ed1
to
10cb8fa
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.
I love this filter!
Just some minor changes (mostly docs & tests)
@@ -665,6 +665,30 @@ def from_info_mem(cls, perm_str: str) -> "Permission": | |||
if "x" in perm_str: perm |= Permission.EXECUTE | |||
return perm | |||
|
|||
@classmethod | |||
def from_filter_repr(cls, filter_str: str) -> List["Permission"]: |
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 be worth adding unit test for this function alone.
@@ -10,7 +10,7 @@ place). For example, you can learn that ELF running on SPARC architectures alway | |||
and `heap` sections set as Read/Write/Execute. | |||
|
|||
`vmmap` can accept multiple arguments, either patterns to match again mapping names, or addresses | |||
to determine which section it belongs to: | |||
to determine which section it belongs to, or the permissions of the sections to match: |
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.
Some examples of --perms
would be nice too
res = gdb.execute("vmmap -p r?-", to_string=True) | ||
self.assertGreater(len(res.splitlines()), 5) | ||
|
||
res = gdb.execute("vmmap --perms r?-", to_string=True) | ||
self.assertGreater(len(res.splitlines()), 5) |
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.
You can go further in checking the output, this doesn't really check the output is as intended. Also those tests being equivalent, you can thoroughly check the strings in the 1st assert, then check that the 1st result equals the 2nd.
res = gdb.execute("vmmap -p r?-", to_string=True) | |
self.assertGreater(len(res.splitlines()), 5) | |
res = gdb.execute("vmmap --perms r?-", to_string=True) | |
self.assertGreater(len(res.splitlines()), 5) | |
res1 = gdb.execute("vmmap -p r?-", to_string=True) | |
lines1 = res.splitlines() | |
self.assertGreater(len(lines), 5) | |
for line in lines1: | |
perm_str = line.split()[3] | |
assert perm_str[0] == 'r' | |
assert perm_str[1] in ('w', '-') | |
assert perm_str[2] == '-' | |
res2 = gdb.execute("vmmap --perms r?-", to_string=True) | |
assert res1 == res2 |
This CL allows for searching sections by their permissions. For instance, you could search for all rwx sections by typing
vmmap rwx
.