Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion pwnlib/gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def _get_runner(ssh=None):
else: return tubes.process.process

@LocalContext
def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, port=0, gdbserver_args=None, sysroot=None, api=False, **kwargs):
def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, port=0, gdbserver_args=None, sysroot=None, api=False, gdbserver_only=False, **kwargs):
r"""
Launch a GDB server with the specified command line,
and launches GDB to attach to it.
Expand All @@ -440,6 +440,8 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por
gdb to load a local version of binaries/libraries instead of downloading
them from the gdbserver, which is faster
api(bool): Enable access to GDB Python API.
gdbserver_only(bool): Only start gdbserver without attaching GDB client.
Useful for external debugger integration.

Returns:
:class:`.process` or :class:`.ssh_channel`: A tube connected to the target process.
Expand Down Expand Up @@ -705,6 +707,12 @@ def debug(args, gdbscript=None, gdb_args=None, exe=None, ssh=None, env=None, por
if not ssh and context.os == 'android':
host = context.adb_host

# GDB Server Only Mode: Return without starting GDB client
if gdbserver_only:
log.info("GDB server started on %s:%d (pid=%d)", host, port, gdbserver.pid)
log.info("You can now attach with: gdb %s -ex 'target remote %s:%d'", exe, host, port)
return gdbserver

tmp = attach((host, port), exe=exe, gdbscript=gdbscript, gdb_args=gdb_args, ssh=ssh, sysroot=sysroot, api=api)
if api:
_, gdb = tmp
Expand Down
Loading