-
Notifications
You must be signed in to change notification settings - Fork 874
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 Chunk class & template_heap_command #1159
Conversation
Codecov Report
@@ Coverage Diff @@
## dev #1159 +/- ##
==========================================
+ Coverage 51.45% 52.59% +1.13%
==========================================
Files 176 178 +2
Lines 19997 20118 +121
Branches 1833 1851 +18
==========================================
+ Hits 10290 10581 +291
+ Misses 9325 9129 -196
- Partials 382 408 +26
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
pwndbg/commands/heap.py
Outdated
# The `Chunk` class abstracts away many heap & gdb module internals. | ||
chunk = pwndbg.heap.ptmalloc.Chunk(addr) | ||
|
||
print(f"chunk.address: 0x{chunk.address:02x}") |
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 think this PR is great, the only tiny potential issue I can find is: should we use f-strings
syntax?
I like f-strings
and it's convenient, but for the compatibility, maybe we should not use it until we fully deprecate Python<3.6 support I guess?
(I saw the comment from @disconnect3d about the Python version we want to support here: #1063 (comment))
We had a discussion on Discord after that comment, I remember the general consensus was we should support distros that are not EOL yet, which would include Ubuntu 18.04, 20.04 and 22.04, and we now run the CI on all three. Ubuntu 18.04 uses Python 3.6.9, so personally I think it's OK to drop support for versions older than 3.6, but I know we always have the issue of someone wanting to use it on those older versions. |
So far the consensus seems to be:
@gsingh93 are you happy to postpone the unit testing stuff? |
Yup, feel free to hold off on the unit testing stuff, we can revisit it later. |
Yeah, I am fine with that. So what with the |
Exactly. Right now contributors must manually find many heap values in their commands: pwndbg/pwndbg/commands/heap.py Lines 672 to 674 in 1ca4d2d
Hopefully we can avoid this (and benefit from the built-in efficiency the gdb module gives us) by introducing these classes to pwndbg's heap inspection engine. |
The Chunk class abstracts developers from some heap & gdb internals and makes use of the gdb module's lazy fetching.
The
template_heap_command
command serves as an example of how to use the Chunk class (and hopefully future classes).