Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] PR tui/21599: GDB crashes if TUI terminal window is made too small
@ 2017-06-14 21:19 Sergio Durigan Junior
  2017-06-15 22:21 ` Simon Marchi
  0 siblings, 1 reply; 3+ messages in thread
From: Sergio Durigan Junior @ 2017-06-14 21:19 UTC (permalink / raw)
  To: GDB Patches; +Cc: Sergio Durigan Junior

This problem happens mostly when using TUI mode inside a tmux pane
which is split horizontally.  To reproduce:

1) Enter tmux.  I am assuming that the modifier sequence for your tmux is C-b (the default).

2) Split the pane horizontally (C-b ").

3) Start GDB in TUI mode (gdb -tui) on the upper pane.

4) Resize the upper pane, making it as small as possible (C-b <upper-arrow>, repeatedly).

The problem happens because tmux's pane has a screen height that makes
GDB miscalculate the minimum screen height that can be set by the
terminal.  The solution I found was to first check if this minimum
height is actually negative, and avoid using it if so.  In this case,
TUI can just use the MIN_WIN_HEIGHT define and be done with the
resizing process.

gdb/ChangeLog:
yyyy-mm-dd  Sergio Durigan Junior  <sergiodj@redhat.com>

	PR tui/21599
	* tui-win.c (tui_resize_all): New variable 'min_screenheight'.
	Use it to avoid resizing the TUI window to an invalid value.
---
 gdb/tui/tui-win.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c
index f49d7d5..ec594bf 100644
--- a/gdb/tui/tui-win.c
+++ b/gdb/tui/tui-win.c
@@ -753,6 +753,7 @@ tui_resize_all (void)
 {
   int height_diff, width_diff;
   int screenheight, screenwidth;
+  int min_screenheight;
 
   rl_get_screen_size (&screenheight, &screenwidth);
   width_diff = screenwidth - tui_term_width ();
@@ -795,6 +796,7 @@ tui_resize_all (void)
       erase ();
       clearok (curscr, TRUE);
       refresh ();
+      min_screenheight = screenheight - MIN_CMD_WIN_HEIGHT - 1;
       switch (cur_layout)
        {
 	case SRC_COMMAND:
@@ -805,9 +807,16 @@ tui_resize_all (void)
 	  /* Check for invalid heights.  */
 	  if (height_diff == 0)
 	    new_height = first_win->generic.height;
+	  else if (min_screenheight < 0)
+	    {
+	      /* In some cases min_screenheight can be negative.
+		 E.g., when using tmux and resizing the screen to the
+		 minimum allowed.  See PR tui/21599.  */
+	      new_height = MIN_WIN_HEIGHT;
+	    }
 	  else if ((first_win->generic.height + split_diff) >=
-		   (screenheight - MIN_CMD_WIN_HEIGHT - 1))
-	    new_height = screenheight - MIN_CMD_WIN_HEIGHT - 1;
+		   min_screenheight)
+	    new_height = min_screenheight;
 	  else if ((first_win->generic.height + split_diff) <= 0)
 	    new_height = MIN_WIN_HEIGHT;
 	  else
-- 
2.9.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-15 23:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-14 21:19 [PATCH] PR tui/21599: GDB crashes if TUI terminal window is made too small Sergio Durigan Junior
2017-06-15 22:21 ` Simon Marchi
2017-06-15 23:56   ` Sergio Durigan Junior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox