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: display ret address #1071

Open
disconnect3d opened this issue Aug 17, 2022 · 2 comments · May be fixed by #1889
Open

telescope: display ret address #1071

disconnect3d opened this issue Aug 17, 2022 · 2 comments · May be fixed by #1889

Comments

@disconnect3d
Copy link
Member

It would be great to display return addresses in the telescope, stack etc outputs.

I initially worked on it in #794 but the patch had some issues.

We should proceed with:

  1. Move the logic of finding return addresses to pwndbg.stack.yield_return_addresses, e.g.:
def yield_return_addresses():
    sp = pwndbg.regs.sp
    stack = pwndbg.vmmap.find(sp)

    # Enumerate all return addresses
    frame = gdb.newest_frame()
    addresses = []
    while frame:
        addresses.append(frame.pc())
        frame = frame.older()

    # Find all of them on the stack
    start = stack.vaddr
    stop = start + stack.memsz
    while addresses and start < sp < stop:
        value = pwndbg.memory.u(sp)

        if value in addresses:
            index = addresses.index(value)
            del addresses[:index]
            yield sp

        sp += pwndbg.arch.ptrsize
  • Question: shouldn't the first operator (between start and sp) here: start < sp < stop be <=? On a quick glance now I think so
  1. Rethink how to add it into telescope and other output
  • Shall we display it in all cases or only on demand?
  1. Rethink if we want to add GDB variables for return addresses. This is really neat, but if we do it, we probably need to do it on each GDB stop and then it may be hurt performance on tough targets when debugging via gdbserver...
@dmur1
Copy link
Contributor

dmur1 commented Aug 25, 2023

will take a look at this

@dmur1 dmur1 linked a pull request Aug 25, 2023 that will close this issue
@dmur1
Copy link
Contributor

dmur1 commented Feb 22, 2024

i'm going to look at this again

@gsingh93 gsingh93 modified the milestones: 2024.01, Future Apr 28, 2024
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