` telescope -r` should always display the input address #1240 (#1779)

* Added input address to telescope reverse output with skipped records

* Added test to telescope reverse that checks input address

* Fixed linters

* Update tests/gdb-tests/tests/test_command_telescope.py

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>

* Fixed tests

---------

Co-authored-by: Disconnect3d <dominik.b.czarnota@gmail.com>
pull/1782/head
NT Sleep 2 years ago committed by GitHub
parent fc083b9865
commit 89b1f437fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,6 +81,7 @@ def telescope(address=None, count=telescope_lines, to_string=False, reverse=Fals
telescope.offset = 0
address = int(address if address else pwndbg.gdblib.regs.sp) & pwndbg.gdblib.arch.ptrmask
input_address = address
count = max(int(count), 1) & pwndbg.gdblib.arch.ptrmask
delimiter = T.delimiter(offset_delimiter)
separator = T.separator(offset_separator)
@ -179,7 +180,7 @@ def telescope(address=None, count=telescope_lines, to_string=False, reverse=Fals
# Buffer repeating values.
if skip_repeating_values:
value = pwndbg.gdblib.memory.pvoid(addr)
if last == value:
if last == value and addr != input_address:
collapse_buffer.append(line)
continue
collapse_repeating_values()

@ -82,3 +82,21 @@ def test_telescope_command_with_address_as_count_and_reversed_flag(start_binary)
rsp = pwndbg.gdblib.regs.rsp
assert out == ["00:0000│ %#x ◂— 0x0" % (rsp - 8), "01:0008│ rsp %#x ◂— 0x1" % rsp]
def test_command_telescope_reverse_skipped_records_shows_input_address(start_binary):
"""
Tests reversed telescope with skipped records shows input address
"""
start_binary(TELESCOPE_BINARY)
gdb.execute("break break_here")
gdb.execute("run")
gdb.execute("up")
pwndbg.gdblib.memory.write(pwndbg.gdblib.regs.rsp - 8 * 3, b"\x00" * 8 * 4)
expected_value = hex(pwndbg.gdblib.regs.rsp)
result_str = gdb.execute("telescope -r $rsp", to_string=True)
result_lines = result_str.strip("\n").split("\n")
assert expected_value in result_lines[-1]

Loading…
Cancel
Save