diff --git a/pwndbg/commands/start.py b/pwndbg/commands/start.py index 7788be3d0..fd3d4a559 100644 --- a/pwndbg/commands/start.py +++ b/pwndbg/commands/start.py @@ -134,11 +134,18 @@ def entry(args=None) -> None: args = [] if pwndbg.dbg.is_gdblib_available(): + # If this is GDB, just start the process ourselves. run = "starti " + " ".join(map(quote, args)) gdb.execute(run, from_tty=False) else: - # TODO: LLDB, In the future, we should handle `run -s` here to automate setup. - # For now, we only support stopping at the entry breakpoint. + # For now, there is no debugger-agnostic way to start a process from + # inside a command, so the best we can do is expect that the back-end + # picks up that this command is being called, and starts the process on + # our behalf, and error out if it does not. + # + # `pwndbg-lldb` implements starting as a partial command override in the CLI. + # + # TODO: In the future, we should handle starts using an in-command mechanism. if not pwndbg.aglib.proc.alive: print( M.error( diff --git a/pwndbg/dbg/lldb/repl/__init__.py b/pwndbg/dbg/lldb/repl/__init__.py index 61c5db76e..84a168894 100644 --- a/pwndbg/dbg/lldb/repl/__init__.py +++ b/pwndbg/dbg/lldb/repl/__init__.py @@ -569,6 +569,26 @@ def exec_repl_command( run_ipython_shell() return True + if ( + bits[0] == pwndbg.commands.start.entry.command_name + or bits[0] in pwndbg.commands.start.entry.aliases + ): + # 'entry' is actually a Pwndbg command. For convenience, we launch the + # process on its behalf, before letting it run. + # + # In the LLDB back-end, there is no proper mechanism to make a process + # start from inside of a command, as there is in GDB. Ideally, we'd + # rework `ProcessDriver` so that it lets us do that with an execution + # controller, but that is quite a bit of work to fix a single command, + # when using an override is enough to achieve the same goal. + # + # In any case, we should consider doing it if this proves to be too janky. + if not driver.has_process(): + process_launch(driver, relay, ["-s"], dbg) + + # This intentionally falls through. We want LLDB to do the rest of the + # work of processing 'entry'. + # The command hasn't matched any of our filtered commands, just let LLDB # handle it normally. Either in the context of the process, if we have # one, or just in a general context.