Add special handling for `version` in LLDB Pwndbg (#2804)

* Fix `version` in LLDB Pwndbg
pull/2810/head
Matt. 9 months ago committed by GitHub
parent d1b754dbb8
commit 2d6f67150f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -93,13 +93,22 @@ def get_terminal_size():
return f"Terminal width: {width_info}, height: {height_info}\n"
@pwndbg.commands.ArgparsedCommand(
"Displays Pwndbg and its important deps versions.", category=CommandCategory.PWNDBG
)
def version() -> None:
def version_impl() -> None:
"""
Implementation of the `version` command.
"""
print("\n".join(map(message.system, all_versions())))
if pwndbg.dbg.name() != "lldb":
# In LLDB, this command is implemented as part of the Pwndbg CLI.
@pwndbg.commands.ArgparsedCommand(
"Displays Pwndbg and its important deps versions.", category=CommandCategory.PWNDBG
)
def version() -> None:
version_impl()
bugreport_parser = argparse.ArgumentParser(description="Generate a bug report.")
bugreport_group = bugreport_parser.add_mutually_exclusive_group()
bugreport_group.add_argument(

@ -1134,6 +1134,12 @@ class Debugger:
# removed or replaced as the porting work continues.
#
def name(self) -> Literal["lldb", "gdb"]:
"""
The name of the current debugger.
"""
raise NotImplementedError()
# We'd like to be able to gate some imports off during porting. This aids in
# that.
def is_gdblib_available(self) -> bool:

@ -1549,6 +1549,10 @@ class GDB(pwndbg.dbg_mod.Debugger):
def supports_breakpoint_creation_during_stop_handler(self) -> bool:
return False
@override
def name(self) -> Literal["gdb", "lldb"]:
return "gdb"
@override
def x86_disassembly_flavor(self) -> Literal["att", "intel"]:
try:

@ -2029,6 +2029,10 @@ class LLDB(pwndbg.dbg_mod.Debugger):
def supports_breakpoint_creation_during_stop_handler(self) -> bool:
return True
@override
def name(self) -> Literal["lldb", "gdb"]:
return "lldb"
@override
def x86_disassembly_flavor(self) -> Literal["att", "intel"]:
# Example:

@ -366,11 +366,17 @@ def exec_repl_command(
)
return True
# Not allowed to have this be a regular command, because of LLDB.
if "version".startswith(line) and line.startswith("ve"):
pwndbg.commands.version.version_impl()
print()
# Don't return. We want the LLDB command to also run.
# There are interactive commands that `SBDebugger.HandleCommand` will
# silently ignore. We have to implement them manually, here.
if "quit".startswith(line) and line.startswith("quit"):
if "quit".startswith(line) and line.startswith("q"):
return False
if "exit".startswith(line) and line.startswith("exit"):
if "exit".startswith(line) and line.startswith("exi"):
return False
# `script` is a little weird. Unlike with the other commands we're

Loading…
Cancel
Save