This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFA]: New function terminal_save_ours()


> Hi!
> 
> When using gdb-tui and switching to or leaving the TUI mode, the terminal
> settings are changed.  This is part of the curses management (endwin).
> 
> Gdb keeps in a static variable in inflow.c for the tty setting of himself.
> It switches it with the inferior terminal (terminal_inferior, terminal_ours).
> The gdb terminal settings are fetched only once, the first time it is
> used/checked (so we don't know when).
> 
> For the TUI to work correctly, it needs to update the gdb knowledge of
> its terminal.  The patch below proposes a new function `terminal_save_ours'
> which is called by TUI each time the TUI changes from mode;  that is
> after we enter in TUI mode (curses), and after we left the TUI mode.
> 
> Can you approve this patch ?


I wish it were this simple.

target_terminal_ours(), target_terminal_inferior() and 
target_terminal_ours_for_output() all go through the target vector.  The 
, er, obvious (?) thing to do would be to add 
target_terminal_save_our_tty_state(), or what ever, to that target 
vector.  I'm, to be honest, not sure if it is ``obvious'' or not.

Think about a remote target that has implemented console I/O.

When GDB hands off to the target it calls target_terminal_inferior(), 
that in turn causes remote.c to steal the input from GDB so that it can 
funnel all console input down to the remote target.  When the inferior 
stops, GDB calls target_terminal_ours(), and the target relinquishes 
that control.  At present, remote.c (and possibly all other remote 
targets) assumes that this operation doesn't require any get/set tty 
state manipulation.  I don't think the patch, as it currently stands 
addresses this.

How to best address it is where things get tricky.  I'm not sure if the 
targets should all be updated to do the set/get tty tweeking or if the 
set/get tty stuff should be brought closer to GDB and always done.

	Andrew


> Index: inflow.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/inflow.c,v
> retrieving revision 1.11
> diff -u -p -r1.11 inflow.c
> --- inflow.c	2001/07/15 20:34:13	1.11
> +++ inflow.c	2001/07/19 22:48:49
> @@ -200,6 +200,23 @@ terminal_init_inferior_with_pgrp (int pg
>      }
>  }
>  
> +/* Save the terminal settings again.  This is necessary for the TUI
> +   when it switches to TUI or non-TUI mode;  curses changes the terminal
> +   and gdb must be able to restore it correctly.  */
> +
> +void
> +terminal_save_ours ()


I'd recommend a more explicit name - ..._save_our_state?

> +{
> +  if (gdb_has_a_terminal ())
> +    {
> +      /* We could just as well copy our_ttystate (if we felt like adding
> +         a new function serial_copy_tty_state).  */
> +      if (our_ttystate)
> +	xfree (our_ttystate);
> +      our_ttystate = serial_get_tty_state (stdin_serial);
> +    }
> +}


Should all existing ``our_ttystate = serial_get_tty_state()'' calls be 
replaced with calls to this function?

	Andrew


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]