mirror of https://github.com/pwndbg/pwndbg.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.5 KiB
Python
60 lines
1.5 KiB
Python
import gdb
|
|
|
|
import tests
|
|
|
|
TELESCOPE_BINARY = tests.binaries.get("telescope_binary.out")
|
|
|
|
|
|
def test_command_telescope(start_binary):
|
|
"""
|
|
Tests simple telescope
|
|
"""
|
|
start_binary(TELESCOPE_BINARY)
|
|
|
|
gdb.execute("break break_here")
|
|
gdb.execute("run")
|
|
gdb.execute("up")
|
|
|
|
expected_str = gdb.execute("print a", to_string=True)
|
|
expected_lines = expected_str.split("\n")
|
|
|
|
result_str = gdb.execute("telescope &a", to_string=True)
|
|
result_lines = result_str.split("\n")
|
|
|
|
for i in range(4):
|
|
expected_addr = expected_lines[i + 1].split(" ")[4].strip(',"')
|
|
assert expected_addr in result_lines[i]
|
|
|
|
|
|
def test_command_telescope_reverse(start_binary):
|
|
"""
|
|
Tests reversed telescope
|
|
"""
|
|
start_binary(TELESCOPE_BINARY)
|
|
|
|
gdb.execute("break break_here")
|
|
gdb.execute("run")
|
|
gdb.execute("up")
|
|
|
|
expected_str = gdb.execute("print a", to_string=True)
|
|
expected_lines = expected_str.split("\n")
|
|
|
|
result_str = gdb.execute("telescope ((uint8_t*)&a)+0x38 -r", to_string=True)
|
|
result_lines = result_str.split("\n")
|
|
|
|
for i in range(4):
|
|
expected_addr = expected_lines[i + 1].split(" ")[4].strip(',"')
|
|
assert expected_addr in result_lines[i]
|
|
|
|
|
|
def test_command_telescope_n_records(start_binary):
|
|
"""
|
|
Tests telescope defined number of records
|
|
"""
|
|
start_binary(TELESCOPE_BINARY)
|
|
|
|
n = 3
|
|
gdb.execute("entry")
|
|
result_str = gdb.execute("telescope $rsp {}".format(n), to_string=True)
|
|
assert len(result_str.strip("\n").split("\n")) == n
|