Skip to content

Add $heap_base variable after running the heap command - #1051

Merged
disconnect3d merged 1 commit into
pwndbg:devfrom
gsingh93:heap-base
Aug 10, 2022
Merged

Add $heap_base variable after running the heap command#1051
disconnect3d merged 1 commit into
pwndbg:devfrom
gsingh93:heap-base

Conversation

@gsingh93

Copy link
Copy Markdown
Member

This PR sets the $heap_base GDB variable once the heap command is run for the first time, allowing it to be used in later GDB commands or in GDB scripts.

Fixes #1049

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #1051 (4d6eb0c) into dev (5e78222) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

@@            Coverage Diff             @@
##              dev    #1051      +/-   ##
==========================================
- Coverage   49.77%   49.77%   -0.01%     
==========================================
  Files         159      159              
  Lines       18653    18654       +1     
  Branches     1519     1519              
==========================================
  Hits         9285     9285              
- Misses       9068     9069       +1     
  Partials      300      300              
Impacted Files Coverage Δ
pwndbg/commands/heap.py 45.46% <0.00%> (-0.07%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@disconnect3d
disconnect3d merged commit 9f5c514 into pwndbg:dev Aug 10, 2022
@disconnect3d

disconnect3d commented Aug 10, 2022

Copy link
Copy Markdown
Member

@gsingh93 We should probably add a tip on that and document it somehow e.g. in FEATURES.md :P

@CptGibbon

Copy link
Copy Markdown
Contributor

I really like this feature and will be using it a lot ❤️
I think it could be improved with a couple of small changes:

  • Check if the user has already set a convenience variable of the same name, either with init-if-undefined or gdb.convenience_variable("heap_base"). This way we won't break user scripts.
  • Consider using gdb.set_convenience_variable("heap_base", <value>) in place of gdb.execute()
  • Perhaps $heap_base could be populated on heap initialization, rather than after running one specific heap command

Thanks for this PR!

@gsingh93

Copy link
Copy Markdown
Member Author

Thanks for the feedback @CptGibbon. Those are all great suggestions, but I'm not sure when I'll get time to make those changes. For now I've filed these suggestions as a new issue so they don't get lost: #1060

@gsingh93
gsingh93 deleted the heap-base branch September 9, 2022 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Define $heap_base variable once the heap has been initialized

4 participants