This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
Re: sim/1538: Gdb does not honor -tty option for built in simulator
- From: Fred Fish <fnf at ninemoons dot com>
- To: nobody at sources dot redhat dot com
- Cc: gdb-prs at sources dot redhat dot com,
- Date: 30 Jan 2004 18:08:01 -0000
- Subject: Re: sim/1538: Gdb does not honor -tty option for built in simulator
- Reply-to: Fred Fish <fnf at ninemoons dot com>
The following reply was made to PR sim/1538; it has been noted by GNATS.
From: Fred Fish <fnf@ninemoons.com>
To: gdb-gnats@sources.redhat.com
Cc:
Subject: Re: sim/1538: Gdb does not honor -tty option for built in simulator
Date: Fri, 30 Jan 2004 11:03:54 -0700
This is a multi-part message in MIME format.
--------------020603050302060606050703
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Here is a patch that works but is probably not the best solution.
--------------020603050302060606050703
Content-Type: text/plain;
name="p"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="p"
(part of this patch was already submitted to the gdb-patches list)
2004-01-29 Fred Fish <fnf@redhat.com>
* main.c (gdb_stdtarg): Move definition to group with other
gdb_stdtarg definitions.
* remote-sim.c (gdb_os_write_stderr): Write output to
gdb_stdtargerr stream instead of gdb_stdtarg stream.
(gdb_os_flush_stderr): Flush gdb_stdtargerr steam instead of
gdb_stderr stream.
* infcmd.c (fcntl.h): Include for tty_command use.
(tty_command): Initialize gdb_stdtarg and gdb_stdtargerr streams
as set by "-tty" command line option or "tty" command.
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.104
diff -c -p -r1.104 infcmd.c
*** infcmd.c 26 Jan 2004 20:52:10 -0000 1.104
--- infcmd.c 30 Jan 2004 17:19:33 -0000
***************
*** 45,50 ****
--- 45,51 ----
#include "block.h"
#include <ctype.h>
#include "gdb_assert.h"
+ #include <fcntl.h> /* Part of gdb_stdtarg/gdb_stdtargerr hack */
/* Functions exported for general use, in inferior.h: */
*************** tty_command (char *file, int from_tty)
*** 377,382 ****
--- 378,404 ----
error_no_arg ("terminal name for running target process");
inferior_io_terminal = savestring (file, strlen (file));
+
+ {
+ /* Hack to make sure target stdio and stderr streams go where
+ directed by the "-tty" command line option or the "tty"
+ command. */
+ int tty;
+ FILE *fp;
+ #ifdef USE_O_NOCTTY
+ tty = open (inferior_io_terminal, O_RDWR | O_NOCTTY);
+ #else
+ tty = open (inferior_io_terminal, O_RDWR);
+ #endif
+ if (tty == -1)
+ {
+ print_sys_errmsg (inferior_io_terminal, errno);
+ return;
+ }
+ fp = fdopen (tty, "r+");
+ gdb_stdtarg = stdio_fileopen (fp);
+ gdb_stdtargerr = stdio_fileopen (fp);
+ }
}
static void
Index: main.c
===================================================================
RCS file: /cvs/src/src/gdb/main.c,v
retrieving revision 1.37
diff -c -p -r1.37 main.c
*** main.c 19 Jan 2004 19:56:01 -0000 1.37
--- main.c 30 Jan 2004 17:19:35 -0000
*************** char *gdb_sysroot = 0;
*** 72,81 ****
struct ui_file *gdb_stdout;
struct ui_file *gdb_stderr;
struct ui_file *gdb_stdlog;
- struct ui_file *gdb_stdtarg;
struct ui_file *gdb_stdin;
/* target IO streams */
struct ui_file *gdb_stdtargin;
struct ui_file *gdb_stdtargerr;
/* Whether to enable writing into executable and core files */
--- 72,81 ----
struct ui_file *gdb_stdout;
struct ui_file *gdb_stderr;
struct ui_file *gdb_stdlog;
struct ui_file *gdb_stdin;
/* target IO streams */
struct ui_file *gdb_stdtargin;
+ struct ui_file *gdb_stdtarg;
struct ui_file *gdb_stdtargerr;
/* Whether to enable writing into executable and core files */
Index: remote-sim.c
===================================================================
RCS file: /cvs/src/src/gdb/remote-sim.c,v
retrieving revision 1.33
diff -c -p -r1.33 remote-sim.c
*** remote-sim.c 13 Nov 2003 19:06:26 -0000 1.33
--- remote-sim.c 30 Jan 2004 17:19:36 -0000
*************** gdb_os_write_stderr (host_callback *p, c
*** 221,227 ****
{
b[0] = buf[i];
b[1] = 0;
! fputs_unfiltered (b, gdb_stdtarg);
}
return len;
}
--- 221,227 ----
{
b[0] = buf[i];
b[1] = 0;
! fputs_unfiltered (b, gdb_stdtargerr);
}
return len;
}
*************** gdb_os_write_stderr (host_callback *p, c
*** 231,237 ****
static void
gdb_os_flush_stderr (host_callback *p)
{
! gdb_flush (gdb_stderr);
}
/* GDB version of printf_filtered callback. */
--- 231,237 ----
static void
gdb_os_flush_stderr (host_callback *p)
{
! gdb_flush (gdb_stdtargerr);
}
/* GDB version of printf_filtered callback. */
--------------020603050302060606050703--