This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Handling binary stdin/stdout on DJGPP
- To: gdb-patches@sourceware.cygnus.com
- Subject: Handling binary stdin/stdout on DJGPP
- From: Robert Hoehne <robert.hoehne@gmx.net>
- Date: Mon, 17 May 1999 20:42:03 +0200
- CC: DJ Delorie <dj@delorie.com>, Eli Zaretskii <eliz@is.elta.co.il>
- Organization: none provided
The following patch saves/restores the inferior filemodes
for stdin/stdout. This is needed, since gdb and the inferior
share the same file handles and if the inferior switches for
instance stdin to binary mode, gdb will not work anymore when
it prompts for input.
Changelog entry:
Mon May 17 1999 Robert Hoehne <robert.hoehne@gmx.net>
* go32-nat.c: go32_terminal_init, go32_terminal_inferior and
go32_terminal_ours are new functions to save/restore the inferior`s
stdin/stdout filemodes
--- gnu/gdb-4.18/gdb/go32-nat.c~ Tue May 11 22:17:48 1999
+++ gnu/gdb-4.18/gdb/go32-nat.c Sun May 16 23:14:50 1999
@@ -166,6 +166,12 @@
CORE_ADDR addr, int len, int rw);
static struct target_ops go32_ops;
+static void
+go32_terminal_init (void);
+static void
+go32_terminal_inferior (void);
+static void
+go32_terminal_ours (void);
static void
print_387_status (unsigned short status, struct env387 *ep)
@@ -817,6 +823,41 @@
return 0;
}
+static int inf_flags_valid = 0;
+static int inf_in_flag;
+static int inf_out_flag;
+
+static void
+go32_terminal_init (void)
+{
+ /* Save the filemodes for stdin/stout */
+ inf_in_flag = setmode(0, 0);
+ setmode(0, inf_in_flag);
+ inf_out_flag = setmode(1, 0);
+ setmode(1, inf_out_flag);
+ inf_flags_valid = 1;
+}
+
+static void
+go32_terminal_inferior (void)
+{
+ /* set the filemodes for stdin/stdout of the inferior */
+ if (inf_flags_valid)
+ {
+ setmode(0, inf_in_flag);
+ setmode(1, inf_out_flag);
+ }
+}
+
+static void
+go32_terminal_ours (void)
+{
+ /* Switch to text mode on stdin/stdout always on the gdb terminal and
+ save the inferior modes to be restored later */
+ inf_in_flag = setmode(0, O_TEXT);
+ inf_out_flag = setmode(1, O_TEXT);
+}
+
static void
init_go32_ops (void)
{
@@ -836,10 +877,10 @@
go32_ops.to_files_info = go32_files_info;
go32_ops.to_insert_breakpoint = memory_insert_breakpoint;
go32_ops.to_remove_breakpoint = memory_remove_breakpoint;
- go32_ops.to_terminal_init = ignore;
- go32_ops.to_terminal_inferior = ignore;
+ go32_ops.to_terminal_init = go32_terminal_init;
+ go32_ops.to_terminal_inferior = go32_terminal_inferior;
go32_ops.to_terminal_ours_for_output = ignore;
- go32_ops.to_terminal_ours = ignore;
+ go32_ops.to_terminal_ours = go32_terminal_ours;
go32_ops.to_terminal_info = ignore2;
go32_ops.to_kill = go32_kill_inferior;
go32_ops.to_create_inferior = go32_create_inferior;
******************************************************
* email: Robert Hoehne <robert.hoehne@gmx.net> *
* Post: Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW: http://www.tu-chemnitz.de/~sho/rho *
******************************************************