Skip to content
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 malloc_chunk command tests for heuristic heap #1234

Merged
merged 4 commits into from
Oct 6, 2022
Merged

Add malloc_chunk command tests for heuristic heap #1234

merged 4 commits into from
Oct 6, 2022

Conversation

CptGibbon
Copy link
Contributor

The same tests applied to the malloc_chunk command, but with set resolve-heap-via-heuristic on.

Personally I don't like how Black has broken the visual flow here for the sake of a couple of characters.

@codecov-commenter
Copy link

codecov-commenter commented Oct 6, 2022

Codecov Report

Merging #1234 (2c95f0d) into dev (0237c1d) will increase coverage by 1.00%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev    #1234      +/-   ##
==========================================
+ Coverage   53.72%   54.72%   +1.00%     
==========================================
  Files         179      179              
  Lines       20131    20172      +41     
  Branches     1836     1848      +12     
==========================================
+ Hits        10815    11040     +225     
+ Misses       8901     8687     -214     
- Partials      415      445      +30     
Impacted Files Coverage Δ
tests/test_heap.py 95.83% <100.00%> (+2.50%) ⬆️
pwndbg/commands/misc.py 79.72% <0.00%> (-8.41%) ⬇️
tests/utils.py 92.59% <0.00%> (ø)
tests/test_misc.py 100.00% <0.00%> (ø)
pwndbg/commands/__init__.py 67.71% <0.00%> (+0.14%) ⬆️
pwndbg/commands/heap.py 65.50% <0.00%> (+0.27%) ⬆️
pwndbg/disasm/__init__.py 59.58% <0.00%> (+0.68%) ⬆️
pwndbg/symbol.py 44.13% <0.00%> (+1.11%) ⬆️
pwndbg/gdblib/regs.py 65.78% <0.00%> (+1.31%) ⬆️
pwndbg/gdblib/prompt.py 53.06% <0.00%> (+1.99%) ⬆️
... and 7 more

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

@gsingh93
Copy link
Member

gsingh93 commented Oct 6, 2022

I think it would be better to pull out the common code from test_malloc_chunk_command and test_malloc_chunk_command_heuristic into another function, and then in both we can just set the necessary config options and call that common function.

@gsingh93
Copy link
Member

gsingh93 commented Oct 6, 2022

Another way to simplify both tests:

    chunks = {}
    results = {}
    for name in ['allocated', 'tcache', 'fast', 'small', 'large', 'unsorted']:
        chunks[name] = pwndbg.heap.current.malloc_chunk(
            gdb.lookup_symbol("%s_chunk" % name)[0].value()
        )

        results[name] = gdb.execute("malloc_chunk %s_chunk" % name, to_string=True).splitlines()

@gsingh93
Copy link
Member

gsingh93 commented Oct 6, 2022

Looks much better, thanks!

@gsingh93 gsingh93 merged commit 91505a4 into pwndbg:dev Oct 6, 2022
@CptGibbon CptGibbon deleted the malloc-chunk-heuristic-tests branch October 6, 2022 17:57
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.

None yet

3 participants