Fix a pair of screen-resizing issues in TUI

Message ID 1420861759-10700-1-git-send-email-patrick@parcs.ath.cx
State New, archived
Headers

Commit Message

Patrick Palka Jan. 10, 2015, 3:49 a.m. UTC
  This patch fixes a pair of TUI issues related to screen resizing:

1. In tui_handle_resize_during_io(), when the TUI screen gets resized,
we fail to update GDB's idea about the height of the output window.

You can see this bug by doing:

  a. Enter TUI mode.
  b. "show height"
  c. Resize the terminal.
  d. "show height"

And observe that despite resizing the terminal, the reported height
remains unchanged.  Note that a similar issue exists in the CLI.

The fix for this is simple: call tui_update_gdb_sizes() after performing
a resize, so that the "height" variable remains consistent with the
height of TUI's output window.

2. In tui_enable(), the call to tui_update_gdb_sizes() may clobber
readline's idea of the actual screen dimensions, and a subsequent
pending resize will use bogus terminal dimensions.

You can see this bug by doing:

  a. Enter TUI mode.
  b. Exit TUI mode.
  c. Resize the terminal.
  d. Enter TUI mode.
  e. Press a key to resize the screen.

And observe that the terminal gets incorrectly resized to the wrong
dimensions.  To fix this issue, we should oppurtunistically resize the
screen in tui_enable().  That way we eliminate the possibility of a
pending resize triggering right after we call tui_update_gdb_sizes().

gdb/ChangeLog:

	* tui/tui-io.c (tui_handle_resize_during_io): Call
	tui_update_gdb_sizes() after resizing the screen.
	* tui/tui.c (tui_enable): Resize the terminal before
	calling tui_update_gdb_sizes().
---
 gdb/tui/tui-io.c | 1 +
 gdb/tui/tui.c    | 7 +++++++
 2 files changed, 8 insertions(+)
  

Comments

Patrick Palka Jan. 10, 2015, 3:56 a.m. UTC | #1
Note that the fix for issue #2 is a more direct variant of
https://sourceware.org/ml/gdb-patches/2014-09/msg00004.html

And that fix #1 addresses (at least on the TUI side) some of the "show
height" issues that Pedro raised in the same thread here
https://sourceware.org/ml/gdb-patches/2014-09/msg00127.html
  
Patrick Palka Jan. 26, 2015, 7:15 p.m. UTC | #2
Ping.
  
Patrick Palka Feb. 4, 2015, 2:49 p.m. UTC | #3
Ping.
  
Pedro Alves Feb. 10, 2015, 5:27 p.m. UTC | #4
On 01/10/2015 03:49 AM, Patrick Palka wrote:
> This patch fixes a pair of TUI issues related to screen resizing:
> 
> 1. In tui_handle_resize_during_io(), when the TUI screen gets resized,
> we fail to update GDB's idea about the height of the output window.
> 
> You can see this bug by doing:
> 
>   a. Enter TUI mode.
>   b. "show height"
>   c. Resize the terminal.
>   d. "show height"
> 
> And observe that despite resizing the terminal, the reported height
> remains unchanged.  Note that a similar issue exists in the CLI.
> 
> The fix for this is simple: call tui_update_gdb_sizes() after performing
> a resize, so that the "height" variable remains consistent with the
> height of TUI's output window.
> 
> 2. In tui_enable(), the call to tui_update_gdb_sizes() may clobber
> readline's idea of the actual screen dimensions, and a subsequent
> pending resize will use bogus terminal dimensions.
> 
> You can see this bug by doing:
> 
>   a. Enter TUI mode.
>   b. Exit TUI mode.
>   c. Resize the terminal.
>   d. Enter TUI mode.
>   e. Press a key to resize the screen.
> 
> And observe that the terminal gets incorrectly resized to the wrong
> dimensions.  To fix this issue, we should oppurtunistically resize the
> screen in tui_enable().  That way we eliminate the possibility of a
> pending resize triggering right after we call tui_update_gdb_sizes().
> 
> gdb/ChangeLog:
> 
> 	* tui/tui-io.c (tui_handle_resize_during_io): Call
> 	tui_update_gdb_sizes() after resizing the screen.
> 	* tui/tui.c (tui_enable): Resize the terminal before
> 	calling tui_update_gdb_sizes().

OK.

Thanks!
  

Patch

diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 94c3ec2..fccada5 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -767,6 +767,7 @@  tui_handle_resize_during_io (void)
     {
       tui_resize_all ();
       tui_refresh_all_win ();
+      tui_update_gdb_sizes ();
       tui_set_win_resized_to (FALSE);
     }
 }
diff --git a/gdb/tui/tui.c b/gdb/tui/tui.c
index 00e505d..53eb6d2 100644
--- a/gdb/tui/tui.c
+++ b/gdb/tui/tui.c
@@ -483,6 +483,13 @@  tui_enable (void)
 
   /* Restore TUI keymap.  */
   tui_set_key_mode (tui_current_key_mode);
+
+  /* Resize and refresh the screen.  */
+  if (tui_win_resized ())
+    {
+      tui_resize_all ();
+      tui_set_win_resized_to (FALSE);
+    }
   tui_refresh_all_win ();
 
   /* Update gdb's knowledge of its terminal.  */