From: Robert Hoehne <robert.hoehne@gmx.net>
To: GDB PATCH <gdb-patches@cygnus.com>
Subject: gdb-4.17 patch to fix filehandle-mode for DJGPP
Date: Sun, 17 Jan 1999 11:36:00 -0000 [thread overview]
Message-ID: <003701be4261$47f12700$19a46d86@robby.dittmannsdorf.de> (raw)
Message-ID: <19990117113600.zzAjTudo7VyaQSYO4bksaAnH-IVk3HWVS1oZRboBvwc@z> (raw)
On MSDOS, the debugger and the debuggee share file handles.
If the debuggee switches its stdin to binary mode, the same
happens to the debugger's stdin, and fgetc loses. We
need therefore to switch stdin to TEXT mode. When not longer
needed, the original mode of stdin is reset.
here now the Changelog entry for directory gdb-4.17/gdb:
Sun Jan 17 1999 Robert Hoehne (robert.hoehne@gmx.net)
* top.c(gdb_readline): switch stdin to TEXT mode and resetting it
* utils.c(query): likewise
Index: gdb-4.17/gdb/top.c
===================================================================
RCS file: Q:/gnu/gdb-4.17/gdb/top.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 top.c
- --- top.c 1998-10-06 09:16:33+00 1.1.1.1
+++ top.c 1998-10-06 10:23:34+00
@@ -50,6 +50,9 @@
#include "gdb_string.h"
#include "gdb_stat.h"
#include <ctype.h>
+#ifdef __DJGPP__
+#include <fcntl.h>
+#endif
extern void initialize_utils PARAMS ((void));
@@ -1397,6 +1400,14 @@
int input_index = 0;
int result_size = 80;
+#ifdef __DJGPP__
+ /* On MSDOS, the debugger and the debuggee share file handles.
+ If the debuggee switches its stdin to binary mode, the same
+ happens to the debugger's stdin, and fgetc below loses. We
+ need therefore to switch stdin to TEXT mode. */
+ int saved_mode = setmode (fileno (stdin), O_TEXT);
+#endif
+
if (prrompt)
{
/* Don't use a _filtered function here. It causes the assumed
@@ -1427,6 +1438,10 @@
we'll return NULL then. */
break;
free (result);
+#ifdef __DJGPP__
+ /* Restore the handle mode. */
+ setmode (fileno (stdin), saved_mode);
+#endif
return NULL;
}
@@ -1442,6 +1457,10 @@
}
result[input_index++] = '\0';
+#ifdef __DJGPP__
+ /* Restore the handle mode. */
+ setmode (fileno (stdin), saved_mode);
+#endif
return result;
}
Index: gdb-4.17/gdb/utils.c
===================================================================
RCS file: Q:/gnu/gdb-4.17/gdb/utils.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 utils.c
- --- utils.c 1998-10-06 09:16:34+00 1.1.1.1
+++ utils.c 1998-10-06 10:23:44+00
@@ -23,6 +23,9 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
+#ifdef __DJGPP__
+#include <fcntl.h>
+#endif
#include "signals.h"
#include "gdbcmd.h"
@@ -992,6 +995,10 @@
register int ans2;
int retval;
+#ifdef __DJGPP__
+ int saved_mode;
+#endif
+
#ifdef ANSI_PROTOTYPES
va_start (args, ctlstr);
#else
@@ -1014,6 +1021,14 @@
return 1;
#endif /* MPW */
+#ifdef __DJGPP__
+ /* On MSDOS, the debugger and the debuggee share file handles.
+ If the debuggee switches its stdin to binary mode, the same
+ happens to the debugger's stdin, and fgetc below loses. We
+ need therefore to make sure stdin is in TEXT mode. */
+ saved_mode = setmode (fileno (stdin), O_TEXT);
+#endif
+
while (1)
{
wrap_here (""); /* Flush any buffered output */
@@ -1067,6 +1082,10 @@
if (annotation_level > 1)
printf_filtered ("\n\032\032post-query\n");
+#ifdef __DJGPP__
+ /* Restore the handle mode. */
+ setmode (fileno (stdin), saved_mode);
+#endif
return retval;
}
- --
******************************************************
* email: Robert Hoehne <robert.hoehne@gmx.net> *
* Post: Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW: http://www.tu-chemnitz.de/~sho/rho *
******************************************************
next reply other threads:[~1999-01-17 11:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-04-01 0:00 Robert Hoehne [this message]
1999-01-17 11:36 ` Robert Hoehne
1999-04-01 0:00 ` Stu Grossman
1999-01-18 9:02 ` Stu Grossman
-- strict thread matches above, loose matches on Subject: below --
1999-01-20 10:06 Robert Hoehne
1999-04-01 0:00 ` Robert Hoehne
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='003701be4261$47f12700$19a46d86@robby.dittmannsdorf.de' \
--to=robert.hoehne@gmx.net \
--cc=gdb-patches@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox