Bug fix for error handling of the heap commands (#1543)

Fix the bug by adding the missing attribute `symbol` to `SymbolUnresolvableError`, and add the test for it to avoid it happening again
pull/1552/head
Alan Li 3 years ago committed by GitHub
parent 9522a94baa
commit 0f67d08acb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1252,6 +1252,7 @@ class DebugSymsHeap(GlibcMemoryAllocator):
class SymbolUnresolvableError(Exception):
def __init__(self, symbol) -> None:
super().__init__(f"`{symbol}` can not be resolved via heuristic")
self.symbol = symbol
class HeuristicHeap(GlibcMemoryAllocator):

@ -429,9 +429,9 @@ def test_heuristic_fail_gracefully(start_binary, is_multi_threaded):
"The heuristic for pwndbg.heap.current.%s should fail with SymbolUnresolvableError"
% name
)
except SymbolUnresolvableError:
except SymbolUnresolvableError as e:
# That's the only exception we expect
pass
assert e.symbol # we should show what symbol we failed to resolve
# Mock all address and mess up the memory
with mock_for_heuristic(mock_all=True, mess_up_memory=True):

Loading…
Cancel
Save