From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19180 invoked by alias); 9 Oct 2014 15:57:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 19165 invoked by uid 89); 9 Oct 2014 15:57:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00,MISSING_MID,SPF_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mail2.openmailbox.org Received: from mail2.openmailbox.org (HELO mail2.openmailbox.org) (212.129.8.132) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 09 Oct 2014 15:57:46 +0000 Received: from localhost (localhost [127.0.0.1]) by mail2.openmailbox.org (Postfix) with ESMTP id A958D202479 for ; Thu, 9 Oct 2014 17:57:43 +0200 (CEST) Received: from mail2.openmailbox.org ([212.129.8.132]) by localhost (mail.openmailbox.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id v6gqp-9Rc7iz for ; Thu, 9 Oct 2014 17:57:41 +0200 (CEST) X-Mailbox-Line: From 79b690999cbfc67d2b5cd6e57c5530e2b23e9630 Mon Sep 17 00:00:00 2001 From: CustaiCo Date: Thu, 09 Oct 2014 15:57:00 -0000 Subject: [PATCH] [PR gdb/16762 gdb/15958] Fixes for properly resizing TUI To: gdb-patches@sourceware.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------2.1.2" X-SW-Source: 2014-10/txt/msg00207.txt.bz2 Message-ID: <20141009155700.vtu19IhGa_KcM5qI6BhUsc3kdCyWG1rosrPLEOTLCME@z> This is a multi-part message in MIME format. --------------2.1.2 Content-Type: text/plain; charset=UTF-8; format=fixed Content-Transfer-Encoding: 8bit Content-length: 2445 This patch is to fix Bug 16762 - GDB doesn't update display size when host terminal resize, and it inadvertently fixes Bug 15958 - readline modifies env (LINES+COLUMNS) as well. Before it was getting it's size data from curses, but curses is not available to the readline based interface, so things would get out of sync. The readline based interface had no way at all to know if there had been any changes to the size of the window. I have changed it so that both the sides use the same callback function. The event handler has been changed to call some clean up operations that readlines needs and then puts in a request to call the resize function in the main event loop on the next pass. It does change a couple new parameters that readline 6.3 introduces, rl_change_environment and rl_prefer_env_winsize They make it so readline does not set ROWS or COLUMNS in the environment, and seems to be suggested by the ncurses FAQ [1]. The previous method that handedled resizing after getting input from curses, along with some support code, has been removed. The only problem I am aware of with this patch is that until the first character is typed after resizing in curses mode, you do not see the contents of the command window. This seems to have no impact on any other function. Resizing with, without, or any number of switches in between curses and readline modes were unable to produce a out of sync size report for me. Without the patch, any resize operation shrinks the size of the command portion of the window to 3 lines, which is retained as the full height of the screen in readline mode until you exit the session. I see no regressions in the test suite, even though this isn't the sort of issue that automated testing is very good at. CustaiCo [1] http://invisible-island.net/ncurses/ncurses.faq.html#handle_resize === gdb Summary === # of expected passes 28624 # of unexpected failures 98 # of unexpected successes 1 # of expected failures 58 # of known failures 55 # of unresolved testcases 12 # of untested testcases 46 # of unsupported tests 184 --- gdb/ChangeLog | 14 ++++++++++++++ gdb/tui/tui-data.c | 16 ---------------- gdb/tui/tui-io.c | 21 --------------------- gdb/tui/tui-win.c | 40 +++++++++++++++++++++++++++++++++++----- gdb/utils.c | 7 +++++-- 5 files changed, 54 insertions(+), 44 deletions(-) --------------2.1.2 Content-Type: text/x-patch; name="0001-Fixes-issue-gdb-16762-and-gdb-15958.patch" Content-Transfer-Encoding: 8bit Content-Disposition: attachment; filename="0001-Fixes-issue-gdb-16762-and-gdb-15958.patch" Content-length: 5560 diff --git a/gdb/ChangeLog b/gdb/ChangeLog index ee82f1f..73be21b 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,17 @@ +2014-10-09 CustaiCo + + PR gdb/16762 + PR gdb/15958 + * tui/tui-win.c: Changed the signal handling code to use the main + event loop. + * tui/tui-io.c: tui_handle_resize_during_io is not needed. The main + event loop handles the call back to resized the windows. + * tui/tui-data.c: Support methods for tui_handle_resize_during_io + removed. + * utils.c: Set new option in latest readline to prevent + environment from being changed. Also changed to not incorrectly resize + window when tui running. + 2014-10-09 Yao Qi * infrun.c (handle_signal_stop): Remove local variable diff --git a/gdb/tui/tui-data.c b/gdb/tui/tui-data.c index 7e51b3e..06ea29b 100644 --- a/gdb/tui/tui-data.c +++ b/gdb/tui/tui-data.c @@ -98,22 +98,6 @@ tui_set_win_highlight (struct tui_win_info *win_info, ** ACCESSORS & MUTATORS FOR PRIVATE DATA ******************************************/ -/* Answer a whether the terminal window has been resized or not. */ -int -tui_win_resized (void) -{ - return win_resized; -} - - -/* Set a whether the terminal window has been resized or not. */ -void -tui_set_win_resized_to (int resized) -{ - win_resized = resized; -} - - /* Answer a pointer to the current layout definition. */ struct tui_layout_def * tui_layout_def (void) diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index 601d278..4c7fca8 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -146,8 +146,6 @@ static int tui_readline_pipe[2]; This may be the main gdb prompt or a secondary prompt. */ static char *tui_rl_saved_prompt; -static unsigned int tui_handle_resize_during_io (unsigned int); - static void tui_putc (char c) { @@ -653,7 +651,6 @@ tui_getc (FILE *fp) #endif ch = wgetch (w); - ch = tui_handle_resize_during_io (ch); /* The \n must be echoed because it will not be printed by readline. */ @@ -694,21 +691,3 @@ tui_getc (FILE *fp) return ch; } - - -/* Cleanup when a resize has occured. - Returns the character that must be processed. */ -static unsigned int -tui_handle_resize_during_io (unsigned int original_ch) -{ - if (tui_win_resized ()) - { - tui_resize_all (); - tui_refresh_all_win (); - dont_repeat (); - tui_set_win_resized_to (FALSE); - return '\n'; - } - else - return original_ch; -} diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index 9c7a23f..095097a 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -29,6 +29,7 @@ #include "symtab.h" #include "breakpoint.h" #include "frame.h" +#include "event-loop.h" #include "cli/cli-cmds.h" #include "top.h" #include "source.h" @@ -72,7 +73,7 @@ static void tui_scroll_right_command (char *, int); static void parse_scrolling_args (char *, struct tui_win_info **, int *); - +static void tui_handle_resize (void *); /*************************************** ** DEFINITIONS @@ -457,6 +458,31 @@ bold-standout use extra bright or bold with standout mode"), &tui_setlist, &tui_showlist); } +/* This is called from the main event loop after we catch SIGWINCH */ +void +tui_handle_resize (void *signal) +{ + char cmd[50]; + int col, row; + if (tui_active) + { + tui_resize_all (); + tui_refresh_all_win (); + xsnprintf (cmd, sizeof (cmd), "set width %d", TUI_CMD_WIN->generic.width); + execute_command (cmd, 0); + xsnprintf (cmd, sizeof (cmd), "set height %d", TUI_CMD_WIN->generic.height); + execute_command (cmd, 0); + } + else + { + rl_get_screen_size (&row, &col); + xsnprintf (cmd, sizeof (cmd), "set width %d", col); + execute_command (cmd, 0); + xsnprintf (cmd, sizeof (cmd), "set height %d", row); + execute_command (cmd, 0); + } +} + /* Update gdb's knowledge of the terminal size. */ void tui_update_gdb_sizes (void) @@ -670,7 +696,7 @@ tui_resize_all (void) #ifdef HAVE_RESIZE_TERM resize_term (screenheight, screenwidth); -#endif +#endif /* Turn keypad off while we resize. */ if (win_with_focus != TUI_CMD_WIN) keypad (TUI_CMD_WIN->generic.handle, FALSE); @@ -818,9 +844,13 @@ tui_resize_all (void) static void tui_sigwinch_handler (int signal) { - /* Say that a resize was done so that the readline can do it later - when appropriate. */ - tui_set_win_resized_to (TRUE); + /* Say that a resize was done so that the we can update + the UI when appropriate. */ + struct tui_translate data; + data.value = signal; + rl_cleanup_after_signal (); + rl_resize_terminal (); + mark_async_signal_handler (create_async_signal_handler (tui_handle_resize, &data)); } #endif diff --git a/gdb/utils.c b/gdb/utils.c index 3915b58..ae0342a 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1686,6 +1686,8 @@ init_page_info (void) chars_per_line = cols; #else /* Make sure Readline has initialized its terminal settings. */ + rl_change_environment = 0; + rl_prefer_env_winsize = 0; rl_reset_terminal (NULL); /* Get the screen size from Readline. */ @@ -1775,8 +1777,9 @@ set_screen_size (void) if (cols <= 0) cols = INT_MAX; - /* Update Readline's idea of the terminal size. */ - rl_set_screen_size (rows, cols); + /* Don't update with tui active or it will be too large */ + if (!tui_active) + rl_set_screen_size (rows, cols); } /* Reinitialize WRAP_BUFFER according to the current value of --------------2.1.2--