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