Can gdbserver tunnel stdout/stdin to/from gdb ?

Andrew Burgess aburgess@redhat.com
Tue Feb 8 09:20:09 GMT 2022


William Tambe via Gdb-patches <gdb-patches@sourceware.org> writes:

> Can gdbserver tunnel stdout/stdin to/from gdb so as to debug an
> application as if it was executing on the machine running gdb ?

I don't believe gdbserver itself supports this feature.

The remote protocol doe have limited support for this using the File I/O
extensions:

  https://sourceware.org/gdb/onlinedocs/gdb/File_002dI_002fO-Remote-Protocol-Extension.html#File_002dI_002fO-Remote-Protocol-Extension

as far as I understand it though, this is mostly used when debugging
devices that don't have their own console, so we have some support for
allowing the target to print to gdb's console.  Though I don't see why a
bigger target couldn't make use of that extension - you'd just need a
mechanism to intercept the syscalls at the remote end and have gdbserver
forward them to gdb.

The final thing that might be relevant to this topic, though clearly not
what you're actually asking about, is the 'O' packet, which allows
gdbserver to write messages to gdb's console.  As I understand it, this
is often used to allow things like monitor commands to print diagnostic
output, but in general I think this is more for gdbserver itself (not
the thing running under gdbserver) to communicate with the gdb user.

Thanks,
Andrew



More information about the Gdb-patches mailing list