diff options
author | Vladimir Prus <vladimir@codesourcery.com> | 2007-04-08 15:20:07 +0000 |
---|---|---|
committer | Vladimir Prus <vladimir@codesourcery.com> | 2007-04-08 15:20:07 +0000 |
commit | 65cc4390f1aea99f342f461aa6cbd7236d09552b (patch) | |
tree | 64b20483dd682fe8219f738d6e4b7d23df50747e /gdb/ser-pipe.c | |
parent | 1edf24da1a27e3c20350e37d3be8516b3a37f1e5 (diff) | |
download | gdb-65cc4390f1aea99f342f461aa6cbd7236d09552b.zip gdb-65cc4390f1aea99f342f461aa6cbd7236d09552b.tar.gz gdb-65cc4390f1aea99f342f461aa6cbd7236d09552b.tar.bz2 |
Pass stderr of program run with "target remote |"
via gdb_stderr.
* serial.c (serial_open): Set error_fd to -1.
* serial.h (struct serial): New field error_fd.
(struct serial_opts): New field avail.
* ser-pipe.c (pipe_open): Create another pair
of sockets. Pass stderr to gdb.
* ser-mingw.c (pipe_windows_open): Pass
PEX_STDERR_TO_PIPE to pex_run. Initialize
sd->error_fd.
(pipe_avail): New.
(_initialize_ser_windows): Hook pipe_avail.
* ser-base.c (generic_readchar): Check if there's
anything in stderr channel and route that to gdb_stderr.
Diffstat (limited to 'gdb/ser-pipe.c')
-rw-r--r-- | gdb/ser-pipe.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gdb/ser-pipe.c b/gdb/ser-pipe.c index 6b1cb52..f4b11b9 100644 --- a/gdb/ser-pipe.c +++ b/gdb/ser-pipe.c @@ -62,9 +62,12 @@ pipe_open (struct serial *scb, const char *name) * published in UNIX Review, Vol. 6, No. 8. */ int pdes[2]; + int err_pdes[2]; int pid; if (socketpair (AF_UNIX, SOCK_STREAM, 0, pdes) < 0) return -1; + if (socketpair (AF_UNIX, SOCK_STREAM, 0, err_pdes) < 0) + return -1; /* Create the child process to run the command in. Note that the apparent call to vfork() below *might* actually be a call to @@ -77,9 +80,18 @@ pipe_open (struct serial *scb, const char *name) { close (pdes[0]); close (pdes[1]); + close (err_pdes[0]); + close (err_pdes[1]); return -1; } + if (fcntl (err_pdes[0], F_SETFL, O_NONBLOCK) == -1) + { + close (err_pdes[0]); + close (err_pdes[1]); + err_pdes[0] = err_pdes[1] = -1; + } + /* Child. */ if (pid == 0) { @@ -91,6 +103,13 @@ pipe_open (struct serial *scb, const char *name) close (pdes[1]); } dup2 (STDOUT_FILENO, STDIN_FILENO); + + if (err_pdes[0] != -1) + { + close (err_pdes[0]); + dup2 (err_pdes[1], STDERR_FILENO); + close (err_pdes[1]); + } #if 0 /* close any stray FD's - FIXME - how? */ /* POSIX.2 B.3.2.2 "popen() shall ensure that any streams @@ -109,6 +128,7 @@ pipe_open (struct serial *scb, const char *name) state = XMALLOC (struct pipe_state); state->pid = pid; scb->fd = pdes[0]; + scb->error_fd = err_pdes[0]; scb->state = state; /* If we don't do this, GDB simply exits when the remote side dies. */ |