aboutsummaryrefslogtreecommitdiff
path: root/gdb/tui
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2015-02-17 10:05:52 +0000
committerPedro Alves <palves@redhat.com>2015-02-17 10:05:52 +0000
commitf8e5e23e3dc46042fcf5fad6013e6fa8db13ec43 (patch)
tree6beb0760ade2ff5db035a64a365b4bfb410fd21d /gdb/tui
parent9f2e07213aa91f1882112df3e0d227638b7a085b (diff)
downloadgdb-f8e5e23e3dc46042fcf5fad6013e6fa8db13ec43.zip
gdb-f8e5e23e3dc46042fcf5fad6013e6fa8db13ec43.tar.gz
gdb-f8e5e23e3dc46042fcf5fad6013e6fa8db13ec43.tar.bz2
TUI: resize windows to new terminal size before displaying them
If the user: #1 - disables the TUI #2 - resizes the terminal #3 - and then re-enables the TUI the next wgetch() returns KEY_RESIZE. This indicates to the ncurses client that ncurses detected that the terminal has been resized. We don't handle KEY_RESIZE anywhere, so it gets passed on to readline which interprets it as a multibyte character, and then the end result is that the first key press after enabling the TUI is misinterpreted. We shouldn't really need to handle KEY_RESIZE (and not all ncurses implementations have that). We have our own SIGWINCH handler, and, when we re-enable the TUI, we explicitly detect terminal resizes and resize all windows. The reason ncurses currently does detects a resize is that something within tui_enable forces a refresh/display of some window before we get to do the actual resizing. Setting a break on ncurses' 'resizeterm' function helps find the culprit(s): (top-gdb) bt #0 resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462 #1 0x0000003b42812f3f in _nc_update_screensize (sp=0x2674730) at ../../ncurses/tinfo/lib_setup.c:443 #2 0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726 #3 0x0000003b08215539 in wrefresh (win=0x2a7bc00) at ../../ncurses/base/lib_refresh.c:65 #4 0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60 #5 0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269 #6 0x00000000005273a6 in tui_set_key_mode (mode=TUI_COMMAND_MODE) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:321 #7 0x00000000005278c7 in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:494 #8 0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108 That is, tui_enable calls tui_set_key_mode before we've resized all windows, and that refreshes a window as side effect. And if we're already debugging something (there's a frame), then we'll instead show a window from within tui_show_frame_info: (top-gdb) bt #0 resizeterm (ToLines=28, ToCols=114) at ../../ncurses/base/resizeterm.c:462 #1 0x0000003b42812f3f in _nc_update_screensize (sp=0x202e6c0) at ../../ncurses/tinfo/lib_setup.c:443 #2 0x0000003b0821cbe0 in doupdate () at ../../ncurses/tty/tty_update.c:726 #3 0x0000003b08215539 in wrefresh (win=0x2042890) at ../../ncurses/base/lib_refresh.c:65 #4 0x00000000005257cb in tui_refresh_win (win_info=0xd73d60 <_locator>) at /home/pedro/gdb/mygit/src/gdb/tui/tui-wingeneral.c:60 #5 0x000000000052265b in tui_show_locator_content () at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:269 #6 0x0000000000522931 in tui_show_frame_info (fi=0x16b9cc0) at /home/pedro/gdb/mygit/src/gdb/tui/tui-stack.c:364 #7 0x00000000005278ba in tui_enable () at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:491 #8 0x0000000000527011 in tui_rl_switch_mode (notused1=1, notused2=1) at /home/pedro/gdb/mygit/src/gdb/tui/tui.c:108 The fix is to resize windows earlier. gdb/ChangeLog: 2015-02-17 Pedro Alves <palves@redhat.com> * tui/tui.c (tui_enable): Resize windows before anything might show a window.
Diffstat (limited to 'gdb/tui')
-rw-r--r--gdb/tui/tui.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 834e682..0397ee9 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -487,18 +487,22 @@ tui_enable (void)
tui_setup_io (1);
tui_active = 1;
- if (deprecated_safe_get_selected_frame ())
- tui_show_frame_info (deprecated_safe_get_selected_frame ());
- /* Restore TUI keymap. */
- tui_set_key_mode (tui_current_key_mode);
-
- /* Resize and refresh the screen. */
+ /* Resize windows before anything might display/refresh a
+ window. */
if (tui_win_resized ())
{
tui_resize_all ();
tui_set_win_resized_to (FALSE);
}
+
+ if (deprecated_safe_get_selected_frame ())
+ tui_show_frame_info (deprecated_safe_get_selected_frame ());
+
+ /* Restore TUI keymap. */
+ tui_set_key_mode (tui_current_key_mode);
+
+ /* Refresh the screen. */
tui_refresh_all_win ();
/* Update gdb's knowledge of its terminal. */