This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA]: Fix PR 393 add target to_terminal_save_ours
- From: Stephane Carrez <stcarrez at nerim dot fr>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 24 Aug 2002 02:23:03 +0200
- Subject: [RFA]: Fix PR 393 add target to_terminal_save_ours
Hi!
The following patch fixes PR gdb/393 by adding a new member to target_ops
to save the terminal settings.
The problem (described in http://sources.redhat.com/ml/gdb-patches/2001-07/msg00497.html)
is that the TUI must update gdb's knowledge of its own terminal settings when
we enter or leave TUI (ie curses). The to_terminal_save_ours() is here for
that purpose.
The patch takes care of all targets that use the gdb's default terminal_xxx
functions). Targets that do not have terminal management (like remote*, ...)
don't need this and are unchanged (cause new entry will be and must be null).
Can you approve this patch?
Stephane
2002-08-24 Stephane Carrez <stcarrez@nerim.fr>
Fix PR gdb/393:
* inflow.c (terminal_save_ours): New function to save terminal
settings.
* inferior.h (terminal_save_ours): Declare.
* target.c (debug_to_terminal_save_ours): New function.
(cleanup_target): Defaults to_terminal_save_ours.
(update_current_target): Inherit to_terminal_save_ours.
(setup_target_debug): Set to_terminal_save_ours.
* target.h (target_terminal_save_ours): New to save terminal settings.
(target_ops): New member to_terminal_save_ours.
* gnu-nat.c (init_gnu_ops): Set to_terminal_save_ours.
* hpux-thread.c (init_hpux_thread_ops): Likewise.
* inftarg.c (init_child_ops): Likewise.
* m3-nat.c (init_m3_ops): Likewise.
* procfs.c (init_procfs_ops): Likewise.
* wince.c (init_child_ops): Likewise.
* win32-nat.c (init_child_ops): Likewise.
* sol-thread.c (init_sol_thread_ops): Likewise.
Index: gnu-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-nat.c,v
retrieving revision 1.22
diff -u -p -r1.22 gnu-nat.c
--- gnu-nat.c 30 Apr 2002 21:12:30 -0000 1.22
+++ gnu-nat.c 23 Aug 2002 21:57:40 -0000
@@ -2612,6 +2612,7 @@ init_gnu_ops (void)
gnu_ops.to_terminal_init = gnu_terminal_init_inferior;
gnu_ops.to_terminal_inferior = terminal_inferior;
gnu_ops.to_terminal_ours_for_output = terminal_ours_for_output;
+ gnu_ops.to_terminal_save_ours = terminal_save_ours;
gnu_ops.to_terminal_ours = terminal_ours;
gnu_ops.to_terminal_info = child_terminal_info;
gnu_ops.to_kill = gnu_kill_inferior; /* to_kill */
Index: hpux-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpux-thread.c,v
retrieving revision 1.11
diff -u -p -r1.11 hpux-thread.c
--- hpux-thread.c 8 Oct 2001 20:42:08 -0000 1.11
+++ hpux-thread.c 23 Aug 2002 21:57:43 -0000
@@ -554,6 +554,7 @@ init_hpux_thread_ops (void)
hpux_thread_ops.to_terminal_init = terminal_init_inferior;
hpux_thread_ops.to_terminal_inferior = terminal_inferior;
hpux_thread_ops.to_terminal_ours_for_output = terminal_ours_for_output;
+ hpux_thread_ops.to_terminal_save_ours = terminal_save_ours;
hpux_thread_ops.to_terminal_ours = terminal_ours;
hpux_thread_ops.to_terminal_info = child_terminal_info;
hpux_thread_ops.to_kill = hpux_thread_kill_inferior;
Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.30
diff -u -p -r1.30 inferior.h
--- inferior.h 21 Aug 2002 16:34:09 -0000 1.30
+++ inferior.h 23 Aug 2002 21:57:43 -0000
@@ -152,6 +152,8 @@ extern void kill_inferior (void);
extern void generic_mourn_inferior (void);
+extern void terminal_save_ours (void);
+
extern void terminal_ours (void);
extern int run_stack_dummy (CORE_ADDR , struct regcache *);
Index: inflow.c
===================================================================
RCS file: /cvs/src/src/gdb/inflow.c,v
retrieving revision 1.14
diff -u -p -r1.14 inflow.c
--- inflow.c 21 Apr 2002 20:23:33 -0000 1.14
+++ inflow.c 23 Aug 2002 21:57:44 -0000
@@ -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 ()
+{
+ 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);
+ }
+}
+
void
terminal_init_inferior (void)
{
Index: inftarg.c
===================================================================
RCS file: /cvs/src/src/gdb/inftarg.c,v
retrieving revision 1.8
diff -u -p -r1.8 inftarg.c
--- inftarg.c 9 Jan 2002 00:36:58 -0000 1.8
+++ inftarg.c 23 Aug 2002 21:57:44 -0000
@@ -774,6 +774,7 @@ init_child_ops (void)
child_ops.to_terminal_init = terminal_init_inferior;
child_ops.to_terminal_inferior = terminal_inferior;
child_ops.to_terminal_ours_for_output = terminal_ours_for_output;
+ child_ops.to_terminal_save_ours = terminal_save_ours;
child_ops.to_terminal_ours = terminal_ours;
child_ops.to_terminal_info = child_terminal_info;
child_ops.to_kill = kill_inferior;
Index: m3-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/m3-nat.c,v
retrieving revision 1.16
diff -u -p -r1.16 m3-nat.c
--- m3-nat.c 5 May 2002 01:15:13 -0000 1.16
+++ m3-nat.c 23 Aug 2002 21:57:46 -0000
@@ -4474,6 +4474,7 @@ init_m3_ops (void)
m3_ops.to_terminal_init = terminal_init_inferior;
m3_ops.to_terminal_inferior = terminal_inferior;
m3_ops.to_terminal_ours_for_output = terminal_ours_for_output;
+ m3_ops.to_terminal_save_ours = terminal_save_ours;
m3_ops.to_terminal_ours = terminal_ours;
m3_ops.to_terminal_info = child_terminal_info;
m3_ops.to_kill = m3_kill_inferior;
Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.39
diff -u -p -r1.39 procfs.c
--- procfs.c 13 Aug 2002 18:03:37 -0000 1.39
+++ procfs.c 23 Aug 2002 21:57:50 -0000
@@ -170,6 +170,7 @@ init_procfs_ops (void)
procfs_ops.to_terminal_inferior = terminal_inferior;
procfs_ops.to_terminal_ours_for_output = terminal_ours_for_output;
procfs_ops.to_terminal_ours = terminal_ours;
+ procfs_ops.to_terminal_save_ours = terminal_save_ours;
procfs_ops.to_terminal_info = child_terminal_info;
procfs_ops.to_find_new_threads = procfs_find_new_threads;
Index: sol-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/sol-thread.c,v
retrieving revision 1.29
diff -u -p -r1.29 sol-thread.c
--- sol-thread.c 9 Jan 2002 00:36:58 -0000 1.29
+++ sol-thread.c 23 Aug 2002 21:57:52 -0000
@@ -1556,6 +1556,7 @@ init_sol_thread_ops (void)
sol_thread_ops.to_terminal_inferior = terminal_inferior;
sol_thread_ops.to_terminal_ours_for_output = terminal_ours_for_output;
sol_thread_ops.to_terminal_ours = terminal_ours;
+ sol_thread_ops.to_terminal_save_ours = terminal_save_ours;
sol_thread_ops.to_terminal_info = child_terminal_info;
sol_thread_ops.to_kill = sol_thread_kill_inferior;
sol_thread_ops.to_load = 0;
Index: target.c
===================================================================
RCS file: /cvs/src/src/gdb/target.c,v
retrieving revision 1.39
diff -u -p -r1.39 target.c
--- target.c 1 Aug 2002 21:20:14 -0000 1.39
+++ target.c 23 Aug 2002 21:57:53 -0000
@@ -138,6 +138,8 @@ static void debug_to_terminal_inferior (
static void debug_to_terminal_ours_for_output (void);
+static void debug_to_terminal_save_ours (void);
+
static void debug_to_terminal_ours (void);
static void debug_to_terminal_info (char *, int);
@@ -445,6 +447,9 @@ cleanup_target (struct target_ops *t)
de_fault (to_terminal_ours,
(void (*) (void))
target_ignore);
+ de_fault (to_terminal_save_ours,
+ (void (*) (void))
+ target_ignore);
de_fault (to_terminal_info,
default_terminal_info);
de_fault (to_kill,
@@ -608,6 +613,7 @@ update_current_target (void)
INHERIT (to_terminal_inferior, t);
INHERIT (to_terminal_ours_for_output, t);
INHERIT (to_terminal_ours, t);
+ INHERIT (to_terminal_save_ours, t);
INHERIT (to_terminal_info, t);
INHERIT (to_kill, t);
INHERIT (to_load, t);
@@ -1980,6 +1986,14 @@ debug_to_terminal_ours (void)
}
static void
+debug_to_terminal_save_ours (void)
+{
+ debug_target.to_terminal_save_ours ();
+
+ fprintf_unfiltered (gdb_stdlog, "target_terminal_save_ours ()\n");
+}
+
+static void
debug_to_terminal_info (char *arg, int from_tty)
{
debug_target.to_terminal_info (arg, from_tty);
@@ -2405,6 +2419,7 @@ setup_target_debug (void)
current_target.to_terminal_inferior = debug_to_terminal_inferior;
current_target.to_terminal_ours_for_output = debug_to_terminal_ours_for_output;
current_target.to_terminal_ours = debug_to_terminal_ours;
+ current_target.to_terminal_save_ours = debug_to_terminal_save_ours;
current_target.to_terminal_info = debug_to_terminal_info;
current_target.to_kill = debug_to_kill;
current_target.to_load = debug_to_load;
Index: target.h
===================================================================
RCS file: /cvs/src/src/gdb/target.h,v
retrieving revision 1.25
diff -u -p -r1.25 target.h
--- target.h 1 Aug 2002 21:20:14 -0000 1.25
+++ target.h 23 Aug 2002 21:57:54 -0000
@@ -264,6 +264,7 @@ struct target_ops
void (*to_terminal_inferior) (void);
void (*to_terminal_ours_for_output) (void);
void (*to_terminal_ours) (void);
+ void (*to_terminal_save_ours) (void);
void (*to_terminal_info) (char *, int);
void (*to_kill) (void);
void (*to_load) (char *, int);
@@ -625,6 +626,14 @@ extern void print_section_info (struct t
#define target_terminal_ours() \
(*current_target.to_terminal_ours) ()
+
+/* Save our terminal settings.
+ This is called from TUI after entering or leaving the curses
+ mode. Since curses modifies our terminal this call is here
+ to take this change into account. */
+
+#define target_terminal_save_ours() \
+ (*current_target.to_terminal_save_ours) ()
/* Print useful information about our terminal status, if such a thing
exists. */
Index: win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.60
diff -u -p -r1.60 win32-nat.c
--- win32-nat.c 11 Jul 2002 13:50:49 -0000 1.60
+++ win32-nat.c 23 Aug 2002 21:57:57 -0000
@@ -1791,6 +1791,7 @@ init_child_ops (void)
child_ops.to_terminal_inferior = terminal_inferior;
child_ops.to_terminal_ours_for_output = terminal_ours_for_output;
child_ops.to_terminal_ours = terminal_ours;
+ child_ops.to_terminal_save_ours = terminal_save_ours;
child_ops.to_terminal_info = child_terminal_info;
child_ops.to_kill = child_kill_inferior;
child_ops.to_load = 0;
Index: wince.c
===================================================================
RCS file: /cvs/src/src/gdb/wince.c,v
retrieving revision 1.19
diff -u -p -r1.19 wince.c
--- wince.c 10 Jul 2002 22:38:05 -0000 1.19
+++ wince.c 23 Aug 2002 21:57:58 -0000
@@ -1910,6 +1910,7 @@ init_child_ops (void)
child_ops.to_terminal_inferior = terminal_inferior;
child_ops.to_terminal_ours_for_output = terminal_ours_for_output;
child_ops.to_terminal_ours = terminal_ours;
+ child_ops.to_terminal_save_ours = terminal_save_ours;
child_ops.to_terminal_info = child_terminal_info;
child_ops.to_kill = child_kill_inferior;
child_ops.to_load = child_load;