This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project. See the GDB home page for more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
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 * ******************************************************