* gdb-4.17 patch to fix filehandle-mode for DJGPP
1999-04-01 0:00 gdb-4.17 patch to fix filehandle-mode for DJGPP Robert Hoehne
@ 1999-01-17 11:36 ` Robert Hoehne
1999-04-01 0:00 ` Stu Grossman
1 sibling, 0 replies; 6+ messages in thread
From: Robert Hoehne @ 1999-01-17 11:36 UTC (permalink / raw)
To: GDB PATCH
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 *
******************************************************
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gdb-4.17 patch to fix filehandle-mode for DJGPP
1999-04-01 0:00 ` Stu Grossman
@ 1999-01-18 9:02 ` Stu Grossman
0 siblings, 0 replies; 6+ messages in thread
From: Stu Grossman @ 1999-01-18 9:02 UTC (permalink / raw)
To: gdb-patches
Robert Hoehne writes:
> 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.
The same situation exists for Unix, and GDB handles that correctly. There are
several target vectore entries which are used to save and restore the console's
state between GDB and the target program. Your fixes need to be applied there,
not in GDB's generic console I/O code. See the following macros in target.h
for details:
/* Initialize the terminal settings we record for the inferior,
before we actually run the inferior. */
#define target_terminal_init() \
(*current_target.to_terminal_init) ()
/* Put the inferior's terminal settings into effect.
This is preparation for starting or resuming the inferior. */
#define target_terminal_inferior() \
(*current_target.to_terminal_inferior) ()
/* Put some of our terminal settings into effect,
enough to get proper results from our output,
but do not change into or out of RAW mode
so that no input is discarded.
After doing this, either terminal_ours or terminal_inferior
should be called to get back to a normal state of affairs. */
#define target_terminal_ours_for_output() \
(*current_target.to_terminal_ours_for_output) ()
/* Put our terminal settings into effect.
First record the inferior's terminal settings
so they can be restored properly later. */
#define target_terminal_ours() \
(*current_target.to_terminal_ours) ()
/* Print useful information about our terminal status, if such a thing
exists. */
#define target_terminal_info(arg, from_tty) \
(*current_target.to_terminal_info) (arg, from_tty)
^ permalink raw reply [flat|nested] 6+ messages in thread
* gdb-4.17 patch to fix filehandle-mode for DJGPP
@ 1999-04-01 0:00 Robert Hoehne
1999-01-17 11:36 ` Robert Hoehne
1999-04-01 0:00 ` Stu Grossman
0 siblings, 2 replies; 6+ messages in thread
From: Robert Hoehne @ 1999-04-01 0:00 UTC (permalink / raw)
To: GDB PATCH
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 *
******************************************************
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gdb-4.17 patch to fix filehandle-mode for DJGPP
1999-04-01 0:00 gdb-4.17 patch to fix filehandle-mode for DJGPP Robert Hoehne
1999-01-17 11:36 ` Robert Hoehne
@ 1999-04-01 0:00 ` Stu Grossman
1999-01-18 9:02 ` Stu Grossman
1 sibling, 1 reply; 6+ messages in thread
From: Stu Grossman @ 1999-04-01 0:00 UTC (permalink / raw)
To: gdb-patches
Robert Hoehne writes:
> 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.
The same situation exists for Unix, and GDB handles that correctly. There are
several target vectore entries which are used to save and restore the console's
state between GDB and the target program. Your fixes need to be applied there,
not in GDB's generic console I/O code. See the following macros in target.h
for details:
/* Initialize the terminal settings we record for the inferior,
before we actually run the inferior. */
#define target_terminal_init() \
(*current_target.to_terminal_init) ()
/* Put the inferior's terminal settings into effect.
This is preparation for starting or resuming the inferior. */
#define target_terminal_inferior() \
(*current_target.to_terminal_inferior) ()
/* Put some of our terminal settings into effect,
enough to get proper results from our output,
but do not change into or out of RAW mode
so that no input is discarded.
After doing this, either terminal_ours or terminal_inferior
should be called to get back to a normal state of affairs. */
#define target_terminal_ours_for_output() \
(*current_target.to_terminal_ours_for_output) ()
/* Put our terminal settings into effect.
First record the inferior's terminal settings
so they can be restored properly later. */
#define target_terminal_ours() \
(*current_target.to_terminal_ours) ()
/* Print useful information about our terminal status, if such a thing
exists. */
#define target_terminal_info(arg, from_tty) \
(*current_target.to_terminal_info) (arg, from_tty)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gdb-4.17 patch to fix filehandle-mode for DJGPP
1999-01-20 10:06 Robert Hoehne
@ 1999-04-01 0:00 ` Robert Hoehne
0 siblings, 0 replies; 6+ messages in thread
From: Robert Hoehne @ 1999-04-01 0:00 UTC (permalink / raw)
To: GDB PATCH
> The same situation exists for Unix, and GDB handles that correctly. There are
> several target vectore entries which are used to save and restore the console's
> state between GDB and the target program. Your fixes need to be applied there,
> not in GDB's generic console I/O code. See the following macros in target.h
> for details:
Thanks for the hint. This seems indeed the right place. I'll try to make
the patches now at those places.
Robert
******************************************************
* email: Robert Hoehne <robert.hoehne@gmx.net> *
* Post: Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW: http://www.tu-chemnitz.de/~sho/rho *
******************************************************
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: gdb-4.17 patch to fix filehandle-mode for DJGPP
@ 1999-01-20 10:06 Robert Hoehne
1999-04-01 0:00 ` Robert Hoehne
0 siblings, 1 reply; 6+ messages in thread
From: Robert Hoehne @ 1999-01-20 10:06 UTC (permalink / raw)
To: GDB PATCH
> The same situation exists for Unix, and GDB handles that correctly. There are
> several target vectore entries which are used to save and restore the console's
> state between GDB and the target program. Your fixes need to be applied there,
> not in GDB's generic console I/O code. See the following macros in target.h
> for details:
Thanks for the hint. This seems indeed the right place. I'll try to make
the patches now at those places.
Robert
******************************************************
* email: Robert Hoehne <robert.hoehne@gmx.net> *
* Post: Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW: http://www.tu-chemnitz.de/~sho/rho *
******************************************************
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~1999-04-01 0:00 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-04-01 0:00 gdb-4.17 patch to fix filehandle-mode for DJGPP Robert Hoehne
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox