2
votes

I am using GDB to debug a remote target: I start GDB then type target remote foo:1234. I also communicate with the target via a serial port (note: GDB is not connected over this serial port, but over a separate JTAG interface via OpenOCD). So I have two terminals open: one with Minicom and one with GDB.

When you debug a "normal" inferior in GDB, its stdin and stdout are on the same TTY as GDB (more info here).

Does anyone know if it's possible to achieve that for a remote target - that is have GDB connect to the serial port (as well as the GDB server) so I can do I/O with the target from within the GDB serssion?

1
It's probably possible (after all the components are open source and so open to modification) but are you sure it is advisable? This would seem to make a lot more sense with traditional line-mode blocking terminal I/O - and less sense in an embedded system if the port is handled more directly in application code. If you know your serial port access will go through a consistent API which provides line-at-a-time terminal-like functionality, then you could create some integration with that. In general unifying output is probably a lot simpler, but may not be pretty with synchronization.Chris Stratton
Chris: assuming that you only interact with GDB while the process is halted, I don't think it's necessary that the application only does line mode I/O. After all not all non-embedded applications do only line-mode I/O and GDB should be able to debug such systems. There may be some complications I haven't thought of though.Brendan
I've got onto the GDB mailing list about this question (sourceware.org/ml/gdb/2015-02/msg00032.html) and it seems like GDB doesn't currently have facilities to do this. I'm going to do some thinking and if I work out a general solution I'll be sure to share it.Brendan

1 Answers

0
votes

It doesn't look like there is currently a general solution to this problem. There was some discussion on the mailing list. Chris Stratton has suggested it might be a fundamentally bad idea anyway! I'll be sure to update here if I come up with anything that might be useful to others.