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]

Re: gdb-4.17 patch to fix filehandle-mode for DJGPP


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)