aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver/linux-low.c
diff options
context:
space:
mode:
authorDoug Evans <dje@google.com>2011-12-16 19:06:38 +0000
committerDoug Evans <dje@google.com>2011-12-16 19:06:38 +0000
commite0f9f062204827dd5f8a01ab9252ec29273cd3b0 (patch)
treeb59a5c9d50f4d48b63a75b4d1a63213eee7c7c1d /gdb/gdbserver/linux-low.c
parente77616d77a34e00c99d803b2324e17ece340ac5e (diff)
downloadgdb-e0f9f062204827dd5f8a01ab9252ec29273cd3b0.zip
gdb-e0f9f062204827dd5f8a01ab9252ec29273cd3b0.tar.gz
gdb-e0f9f062204827dd5f8a01ab9252ec29273cd3b0.tar.bz2
* NEWS: Add entry for stdio gdbserver.
gdbserver/ * linux-low.c (linux_create_inferior): If stdio connection, redirect stdin from /dev/null, stdout to stderr. * remote-utils.c (remote_is_stdio): New static global. (remote_connection_is_stdio): New function. (remote_prepare): Handle stdio connection. (remote_open): Ditto. (remote_close): Don't close stdin for stdio connections. (read_prim,write_prim): New functions. Replace all calls to read/write to these. * server.c (main): Watch for "-" argument. Move call to remote_prepare before start_inferior. * server.h (STDIO_CONNECTION_NAME): New macro. (remote_connection_is_stdio): Declare. doc/ * gdb.texinfo (Server): Document -/stdio argument to gdbserver. testsuite/ * lib/gdbserver-support.exp (gdb_target_cmd): Recognize stdio gdbserver output. (gdbserver_default_get_remote_address): New function. (gdbserver_start): Call gdb,get_remote_address to compute argument to "target remote" command.
Diffstat (limited to 'gdb/gdbserver/linux-low.c')
-rw-r--r--gdb/gdbserver/linux-low.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 43d88fa..a712b1f 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -569,6 +569,18 @@ linux_create_inferior (char *program, char **allargs)
setpgid (0, 0);
+ /* If gdbserver is connected to gdb via stdio, redirect the inferior's
+ stdout to stderr so that inferior i/o doesn't corrupt the connection.
+ Also, redirect stdin to /dev/null. */
+ if (remote_connection_is_stdio ())
+ {
+ close (0);
+ open ("/dev/null", O_RDONLY);
+ dup2 (2, 1);
+ write (2, "stdin/stdout redirected\n",
+ sizeof ("stdin/stdout redirected\n") - 1);
+ }
+
execv (program, allargs);
if (errno == ENOENT)
execvp (program, allargs);