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

telescope -r should always display the input address #1240

Closed
gsingh93 opened this issue Oct 7, 2022 · 2 comments · Fixed by #1779
Closed

telescope -r should always display the input address #1240

gsingh93 opened this issue Oct 7, 2022 · 2 comments · Fixed by #1779

Comments

@gsingh93
Copy link
Member

gsingh93 commented Oct 7, 2022

telescope -r addr will skip displaying addr if the value at that address is equal to the previous few values:

pwndbg> p &target_address
$1 = (unsigned long *) 0x5555555582a0 <target_address>
pwndbg> telescope -r &target_address
00:0000│     0x555555558208 (buf+360) ◂— 0x0
... ↓        4 skipped
05:0028│ rax 0x555555558230 (buf+400) ◂— 0x80
06:0030│     0x555555558238 (buf+408) ◂— 0x0
... ↓        13 skipped

We should make this command always display the address that the user asked for:

pwndbg> telescope -r &target_address
00:0000│     0x555555558208 (buf+360) ◂— 0x0
... ↓        4 skipped
05:0028│ rax 0x555555558230 (buf+400) ◂— 0x80
06:0030│     0x555555558238 (buf+408) ◂— 0x0
... ↓        12 skipped
13:0098│     0x5555555582a0 (target_address) ◂— 0x0
@lonnywong
Copy link
Contributor

I found that telescope behaves strangely if set history remove-duplicates unlimited.

The check_repeated depends on the history of gdb.

def check_repeated(self, argument, from_tty):
"""Keep a record of all commands which come from the TTY.
Returns:
True if this command was executed by the user just hitting "enter".
"""
# Don't care unless it's interactive use
if not from_tty:
return False
lines = gdb.execute("show commands", from_tty=False, to_string=True)
lines = lines.splitlines()
# No history
if not lines:
return False
last_line = lines[-1]
number, command = last_line.split(None, 1)
try:
number = int(number)
except ValueError:
# Workaround for a GDB 8.2 bug when show commands return error value
# See issue #523
return False
# A new command was entered by the user
if number not in Command.history:
Command.history[number] = command
return False
# Somehow the command is different than we got before?
if not command.endswith(argument):
return False
return True

If remove-duplicates is set, the check_repeated is not working normally. That's what I mentioned in #1072 (comment)

I can't find another way to implement the check_repeated. I'm removing the set history remove-duplicates unlimited from my ~/.gdbinit.

@gsingh93 gsingh93 added this to the Sprint 2 milestone Oct 16, 2022
@gsingh93 gsingh93 modified the milestones: March 2023, Future Dec 23, 2022
@disconnect3d
Copy link
Member

I'd say we should handle the two cases as separate bugs:

  1. The telescope -r should always include/display the input address (and not collapse it if its value is the same as previous few ones)
  2. The telescope behavior when set history remove-duplicates unlimited is on should be investigated further I guess.

@gsingh93 gsingh93 modified the milestones: 2023.06, Future May 17, 2023
disconnect3d added a commit that referenced this issue Jul 4, 2023
* 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>
@gsingh93 gsingh93 modified the milestones: 2023.09, 2023.06 Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants