aboutsummaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorPatrick Palka <patrick@parcs.ath.cx>2014-11-22 14:12:49 -0500
committerPatrick Palka <patrick@parcs.ath.cx>2015-01-07 09:02:07 -0500
commit6a06d66006d33293215eaf706ee416f6a99da273 (patch)
tree83411c66f901029094b7c967db1f514fc7c8e293 /gdb/top.c
parent8d983e3645b62e72373b3ba4a9af548b82fb43bc (diff)
downloadgdb-6a06d66006d33293215eaf706ee416f6a99da273.zip
gdb-6a06d66006d33293215eaf706ee416f6a99da273.tar.gz
gdb-6a06d66006d33293215eaf706ee416f6a99da273.tar.bz2
Don't propagate our current terminal state to the inferior
Currently when we start an inferior we have the inferior inherit our terminal state. Under TUI, our terminal is highly modified by ncurses and readline. So when starting an inferior under TUI, the inferior will have a highly modified terminal state which will interfere with standard I/O. For example, $ gdb gdb (gdb) break main (gdb) run (gdb) print puts ("a\nb") a b $1 = 4 (gdb) [enter TUI mode] (gdb) run (gdb) [exit TUI mode] (gdb) print puts ("a\nb") a b $2 = 4 (gdb) print puts ("a\r\nb\r") a b $3 = 6 As you can see, when we start the inferior under the regular interface, puts() prints the text properly. But when we start the inferior under TUI, puts() does not print the text properly. This is because when we start the inferior under TUI it inherits our current terminal state which has been modified by ncurses to, among other things, require an explicit \r\n to print a new line. As a result the inferior performs standard I/O in an unexpected way. Because of this discrepancy, it doesn't seem like a good idea to have the inferior inherit our _current_ terminal state for it may have been modified by readline and/or ncurses. Instead, we should have the inferior inherit a pristine snapshot of our terminal state taken before readline or ncurses have had a chance to alter it. This enables the inferior to run in a more accurate way, more closely mimicking the program's behavior had it run standalone. And it fixes the above mentioned issue. Tested on x86_64-unknown-linux-gnu. gdb/ChangeLog: * terminal.h (set_initial_gdb_ttystate): Declare. * inflow.c (initial_gdb_ttystate): New static variable. (set_initial_gdb_ttystate): New setter. (child_terminal_init_with_pgrp): Copy initial_gdb_ttystate instead of our current terminal state. * top.c (gdb_init): Call set_initial_gdb_ttystate.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/top.c b/gdb/top.c
index 524a92b..b85ea1a 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1890,6 +1890,10 @@ gdb_init (char *argv0)
initialize_stdin_serial ();
+ /* Take a snapshot of our tty state before readline/ncurses have had a chance
+ to alter it. */
+ set_initial_gdb_ttystate ();
+
async_init_signals ();
/* We need a default language for parsing expressions, so simple