Skip to content

Commit 6a2ecce

Browse files
authored
Evaluate arguments passed to vmmap (#1085)
## Description Attempts to parse and eval an argument passed to `vmmap`. This makes `vmmap $rip`, for example, work. This is useful as it is easier to look up the memory section a pointer contained in a register/variable points to. It's also more consistent with commands like `dereference`
1 parent 399f457 commit 6a2ecce

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

docs/commands/vmmap.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@ determine which section it belongs to.
1515
![vmmap-grep](https://i.imgur.com/ZFF4QVf.png)
1616

1717
![vmmap-address](https://i.imgur.com/hfcs1jH.png)
18+
19+
The address can be also be given in the form of a register or variable.
20+
21+
![vmmap-register](https://i.imgur.com/RlZA6NU.png)

gef.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8711,6 +8711,10 @@ def do_invoke(self, argv: List[str]) -> None:
87118711
addr = int(argv[0], 0)
87128712
if addr >= entry.page_start and addr < entry.page_end:
87138713
self.print_entry(entry)
8714+
else:
8715+
addr = safe_parse_and_eval(argv[0])
8716+
if addr is not None and addr >= entry.page_start and addr < entry.page_end:
8717+
self.print_entry(entry)
87148718
return
87158719

87168720
def print_entry(self, entry: Section) -> None:

tests/commands/vmmap.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ def test_cmd_vmmap(self):
2121

2222
res = gdb.execute("vmmap stack", to_string=True)
2323
self.assertGreater(len(res.splitlines()), 1)
24+
25+
res = gdb.execute("vmmap $rip", to_string=True)
26+
self.assertEqual(len(res.splitlines()), 2)

0 commit comments

Comments
 (0)