On 02/24/2015 04:31 PM, Yao Qi wrote: > Pedro Alves writes: > > Hi Pedro, > >> + # GDBserver doesn't do inferior I/O through GDB. But we can >> + # talk to the program using GDBserver's tty instead. >> + global inferior_spawn_id >> + set inferior_spawn_id $server_spawn_id > > Does it still work well if GDBserver is started without tty? In my > remote testing, gdbserver is started without tty, > > spawn /usr/bin/ssh -l yao junor1 /gdbserver/aarch64/gdbserver --once :2346 aarch64-linux-gnu/gdb/testsuite/gdb.base/interrupt > > I see the following timeouts: > > Continuing.^M > Remote debugging from host 10.2.206.34^M > FAIL: gdb.base/interrupt.exp: process is alive (timeout) > a^M > a^M > FAIL: gdb.base/interrupt.exp: child process ate our char (timeout) I tried it now, and the problem is that when the gdbserver/inferior is started without a tty, then stdout is put in unbuffered mode, so the printf calls don't flush... Adding: setvbuf (stdout, NULL, _IONBF, BUFSIZ); to interrupt.c fixes it. This is the same problem we see when testing with Windows (native or remote) from Cygwin, given in that case stdin/stdout is connected to a pipe. Long ago I added the set_unbuffered_mode.c hack to for this. So enabling that hack fixes this too then. See patch below. (I also hacked native-gdbserver.exp locally to use ssh with no -t to test it). That would require boards to set that gdb,force_unbuffered_mode flag if they need it. But I'm not sure we want to expose that to boards. We could also always enable the hack for gdbserver in gdbserver-support.exp. Or we could fix the tests themselves to explicitly call setvbuf if needed and not bother boards at all. I count only around 20 tests that check gdb,noinferiorio, or use gdb_skip_stdio_test, and we could fix them incrementally, as they're converted to use $inferior_spawn_id. Maybe that's the cleanest. We can e.g., add: #include "lib/set_unbuffered_mode.c" at the top of such files, which avoids an explicit call in "main". That relies on __attribute__ ((constructor)), but we could also call an helper shared function that does the setvbuf from the tests' "main" if we don't want to rely on that attribute. Options, options... > > We need to override ${board}_spawn and pass "-t" to ssh. After this change, > all interrupt.exp tests pass. Since the test harness assumes GDBserver > has tty, probably we should document such requirement somewhere. That's an option too, but it makes me a bit nervous. I'm not sure if we can assume that. > > However, I don't run the whole testsuite with the updated board file > (with -t option to ssh). >