|
|
|
|
@ -28,3 +28,43 @@ def test_symbol_get(start_binary):
|
|
|
|
|
assert get_next_ptr() == "A::foo(int, int)"
|
|
|
|
|
|
|
|
|
|
assert get_next_ptr() == "A::call_foo()"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_symbol_duplicated_symbols_issue_1610():
|
|
|
|
|
"""
|
|
|
|
|
Test for the bug from https://github.com/pwndbg/pwndbg/issues/1610
|
|
|
|
|
"""
|
|
|
|
|
gdb.execute(f"file {MANGLING_BINARY}")
|
|
|
|
|
|
|
|
|
|
main_addr = int(gdb.parse_and_eval("(unsigned long long)main"))
|
|
|
|
|
|
|
|
|
|
# Sanity checks
|
|
|
|
|
assert gdb.execute("info symbol main", to_string=True) == "main in section .text\n"
|
|
|
|
|
assert pwndbg.gdblib.symbol.get(main_addr) == "main"
|
|
|
|
|
|
|
|
|
|
# This causes some confusion, see below :)
|
|
|
|
|
# Note: {addr} argument is needed for old GDB (e.g. on Ubuntu 18.04)
|
|
|
|
|
addr = _get_section_addr(".text")
|
|
|
|
|
gdb.execute(f"add-symbol-file {MANGLING_BINARY} {addr}")
|
|
|
|
|
|
|
|
|
|
# Sanity check - yeah, there are two symbols
|
|
|
|
|
out = gdb.execute("info symbol main", to_string=True).split("\n")
|
|
|
|
|
|
|
|
|
|
assert len(out) == 3
|
|
|
|
|
|
|
|
|
|
assert out[0] == out[1]
|
|
|
|
|
assert out[0].startswith("main in section .text of ")
|
|
|
|
|
|
|
|
|
|
assert out[2] == ""
|
|
|
|
|
|
|
|
|
|
# Make sure to clear cache!
|
|
|
|
|
pwndbg.gdblib.symbol.get.clear()
|
|
|
|
|
|
|
|
|
|
# Real test assert - this should not crash!
|
|
|
|
|
assert pwndbg.gdblib.symbol.get(main_addr) == "main"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _get_section_addr(sect):
|
|
|
|
|
result = gdb.execute("maintenance info sections", to_string=True).split("\n")
|
|
|
|
|
text_line = next(line for line in result if f": {sect} " in line)
|
|
|
|
|
return int(text_line.split(" at ")[1].split(":")[0], 16)
|
|
|
|
|
|