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

Drop support for GDB < 9.2 #1854

Closed
8 tasks done
disconnect3d opened this issue Aug 1, 2023 · 5 comments
Closed
8 tasks done

Drop support for GDB < 9.2 #1854

disconnect3d opened this issue Aug 1, 2023 · 5 comments

Comments

@disconnect3d
Copy link
Member

disconnect3d commented Aug 1, 2023

We do have this in README:

Pwndbg is supported on Ubuntu 20.04, and 22.04 with GDB 9.2 and later.

So we should remove all the old workaround code we used for old GDBs < 9.2. This issue is there to track those efforts: feel free to send a PR fixing just one thing, or a PR fixing many or all of those.

Those are:

  • gdb77_get_register and the relevant "if hasattr" code:
    @pwndbg.gdblib.proc.OnlyWhenRunning
    def gdb77_get_register(name: str):
    return gdb.parse_and_eval("$" + name)
    @pwndbg.gdblib.proc.OnlyWhenRunning
    def gdb79_get_register(name: str):
    return gdb.selected_frame().read_register(name)
    if hasattr(gdb.Frame, "read_register"):
    get_register = gdb79_get_register
    else:
    get_register = gdb77_get_register
  • _fs_gs_helper - we don't need to use ptrace anymore iiuc:
    @pwndbg.lib.cache.cache_until("stop")
    def _fs_gs_helper(self, regname: str, which):
    """Supports fetching based on segmented addressing, a la fs:[0x30].
    Requires ptrace'ing the child directly for GDB < 8."""
  • We probably don't need to try/except this anymore:
    # GDB 7.9 and above only
    try:
    registered[gdb.events.memory_changed] = []
    registered[gdb.events.register_changed] = []
    except (NameError, AttributeError):
    pass
  • The description for entry command mentions GDB 8.1 - we can probably drop the parentheses here:
    Note that the entrypoint may not be the first instruction executed
    by the program. If you want to stop on the first executed instruction,
    use the GDB's `starti` command (added in GDB 8.1).
  • There was some weird GDB 8.2 case in check_repeated, a functionality for "repeating commands execution" - the except can probably be removed, but I recommend investigating the linked issue there:
    try:
    number = int(number_str)
    except ValueError:
    # Workaround for a GDB 8.2 bug when show commands return error value
    # See issue #523
    return False
  • Handling version:
commands/version.py
29:        return gdb.VERSION  # GDB >= 8.1 (or earlier?)
188:    # 8. showing width
  • Some heap cases:
heap/structs.py
40:    # alignof doesn't available in GDB < 8.2 (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=gdb/NEWS;hb=gdb-8.2-release)

heap/ptmalloc.py
974:            # alignof doesn't available in GDB < 8.2 (https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob_plain;f=gdb/NEWS;hb=gdb-8.2-release)
977:            # TODO: We can remove this when we drop supports for GDB < 8.2
  • Handling symbols:
gdblib/symbol.py
167:            # GDB < 9.x does not have `gdb.lookup_static_symbol`
170:            # TODO/FIXME: Find a way to get the static linkage symbol's address in GDB < 9.x
@dmur1
Copy link
Contributor

dmur1 commented Aug 3, 2023

i'll take a look at this one

@dmur1
Copy link
Contributor

dmur1 commented Aug 3, 2023

_fs_gs_helper - we don't need to use ptrace anymore iiuc:

in trying to remove this the tests break - specifically tls command test - doing ptrace when pwndbg.gdblib.arch.current != "x86-64" seems to fix the issue which suggests that ptrace may be required in some cases even if read register is supported @disconnect3d

@disconnect3d
Copy link
Member Author

@dmur1 seems that GDB doesnt allow to read fs/gs on x86 (i386) via read register and that's why we need to use ptrace there.

@disconnect3d
Copy link
Member Author

Also: would be nice to investigate this:

class EventWrapper:
"""
Wrapper for GDB events which may not exist on older GDB versions but we still can
fire them manually (to invoke them you have to call `invoke_callbacks`).
"""

We may be able to remove that abstraction nowadays? I am not sure! :P

@disconnect3d
Copy link
Member Author

disconnect3d commented Aug 23, 2023

I'm moving the remaining thing to issue #1887. I believe that we finally dropped support for <9.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants