mirror of https://github.com/pwndbg/pwndbg
feat: Move gdb version to gdblib, do not depend on file exec feature in vmmap
This commit is contained in:
parent
15a0cb0a65
commit
d497bac847
|
@ -35,6 +35,7 @@ import pwndbg.ui
|
|||
__version__ = pwndbg.lib.version.__version__
|
||||
version = __version__
|
||||
|
||||
from pwndbg.gdblib import gdb_version
|
||||
from pwndbg.gdblib import prompt
|
||||
|
||||
prompt.set_prompt()
|
||||
|
@ -59,7 +60,6 @@ handle SIGSEGV stop print nopass
|
|||
)
|
||||
|
||||
# See https://github.com/pwndbg/pwndbg/issues/808
|
||||
gdb_version = tuple(map(int, re.search(r"(\d+)[^\d]+(\d+)", gdb.VERSION).groups()))
|
||||
if gdb_version[0] <= 9:
|
||||
pre_commands += "\nset remote search-memory-packet off"
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ Command to print the virtual memory map a la /proc/self/maps.
|
|||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import re
|
||||
|
||||
import gdb
|
||||
from elftools.elf.constants import SH_FLAGS
|
||||
|
@ -15,6 +14,7 @@ import pwndbg.commands
|
|||
import pwndbg.gdblib.elf
|
||||
import pwndbg.gdblib.vmmap
|
||||
from pwndbg.commands import CommandCategory
|
||||
from pwndbg.gdblib import gdb_version
|
||||
|
||||
integer_types = (int, gdb.Value)
|
||||
|
||||
|
@ -155,8 +155,6 @@ def vmmap(
|
|||
if pwndbg.gdblib.qemu.is_qemu() and not pwndbg.gdblib.qemu.exec_file_supported():
|
||||
print("\n[QEMU target detected - vmmap result might not be accurate; see `help vmmap`]")
|
||||
|
||||
gdb_version = tuple(map(int, re.search(r"(\d+)[^\d]+(\d+)", gdb.VERSION).groups()))
|
||||
|
||||
# Only GDB versions >=12 report permission info in info proc mappings. On older versions, we fallback on "rwx".
|
||||
# See https://github.com/bminor/binutils-gdb/commit/29ef4c0699e1b46d41ade00ae07a54f979ea21cc
|
||||
if pwndbg.gdblib.qemu.is_qemu_usermode() and gdb_version[0] < 12:
|
||||
|
|
|
@ -3,6 +3,10 @@
|
|||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
|
||||
import gdb
|
||||
|
||||
from pwndbg.gdblib import arch as arch_mod
|
||||
from pwndbg.gdblib import config as config_mod
|
||||
from pwndbg.gdblib.arch import arch
|
||||
|
@ -12,6 +16,9 @@ regs = None
|
|||
|
||||
__all__ = ["ctypes", "memory", "typeinfo"]
|
||||
|
||||
# Export parsed GDB version
|
||||
gdb_version = tuple(map(int, re.search(r"(\d+)[^\d]+(\d+)", gdb.VERSION).groups()))
|
||||
|
||||
|
||||
# TODO: should the imports above be moved here?
|
||||
def load_gdblib() -> None:
|
||||
|
|
|
@ -60,8 +60,8 @@ def is_qemu_kernel() -> bool:
|
|||
|
||||
@pwndbg.lib.cache.cache_until("stop")
|
||||
def exec_file_supported() -> bool:
|
||||
"""Returns ``True`` if the qemu target supports exec file feature.
|
||||
Used in `vmmap` to determine whether qemu supports `info proc mappings`
|
||||
"""Returns ``True`` if the remote target understands the 'qXfer:exec-file:read' packet.
|
||||
A check for this feature is done in vmmap code, to warn against running legacy Qemu versions.
|
||||
"""
|
||||
response = gdb.execute("maintenance packet qSupported", to_string=True, from_tty=False)
|
||||
|
||||
|
|
|
@ -91,9 +91,12 @@ def get() -> tuple[pwndbg.lib.memory.Page, ...]:
|
|||
if is_corefile():
|
||||
return tuple(coredump_maps())
|
||||
|
||||
if pwndbg.gdblib.qemu.is_qemu_usermode() and pwndbg.gdblib.qemu.exec_file_supported():
|
||||
proc_maps = None
|
||||
if pwndbg.gdblib.qemu.is_qemu_usermode():
|
||||
# On Qemu < 8.1 info proc maps are not supported. In that case we callback on proc_pid_maps
|
||||
proc_maps = info_proc_maps()
|
||||
else:
|
||||
|
||||
if not proc_maps:
|
||||
proc_maps = proc_pid_maps()
|
||||
|
||||
# The `proc_maps` is usually a tuple of Page objects but it can also be:
|
||||
|
|
Loading…
Reference in New Issue