From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Hoehne To: GDB PATCH Subject: gdb-4.17 patch to fix filehandle-mode for DJGPP Date: Thu, 01 Apr 1999 00:00:00 -0000 Message-id: <003701be4261$47f12700$19a46d86@robby.dittmannsdorf.de> X-SW-Source: 1999-q1/msg00014.html 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 +#ifdef __DJGPP__ +#include +#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 #endif +#ifdef __DJGPP__ +#include +#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 * * Post: Am Berg 3, D-09573 Dittmannsdorf, Germany * * WWW: http://www.tu-chemnitz.de/~sho/rho * ****************************************************** From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robert Hoehne To: GDB PATCH Subject: gdb-4.17 patch to fix filehandle-mode for DJGPP Date: Sun, 17 Jan 1999 11:36:00 -0000 Message-ID: <003701be4261$47f12700$19a46d86@robby.dittmannsdorf.de> X-SW-Source: 1999-01/msg00014.html Message-ID: <19990117113600.zzAjTudo7VyaQSYO4bksaAnH-IVk3HWVS1oZRboBvwc@z> 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 +#ifdef __DJGPP__ +#include +#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 #endif +#ifdef __DJGPP__ +#include +#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 * * Post: Am Berg 3, D-09573 Dittmannsdorf, Germany * * WWW: http://www.tu-chemnitz.de/~sho/rho * ******************************************************