gdb: use tui_set_layout not show_layout to fix window focus
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sun, 22 Dec 2019 23:45:31 +0000 (23:45 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Sun, 5 Jan 2020 21:49:05 +0000 (21:49 +0000)
When calling tui_add_win_to_layout, use tui_set_layout not show_layout
so that window focus is correctly updated.  If the focus is not
correctly maintained then GDB can be crashed like this:

  start
  tui enable
  layout asm
  list SOME_FUNCTION

At this point GDB will have "popped up" the source window to
display SOME_FUNCTION.  Previously no window would have focus at this
point, and so if the user now does 'focus next' or 'focus prev', then
GDB would crash.

Calling tui_set_layout ensures that focus is correctly calculated as
the source window is "popped up", and this fixes the issue.

gdb/ChangeLog:

* tui/tui-layout.c (tui_add_win_to_layout): Use tui_set_layout not
show_layout.

gdb/testsuite/ChangeLog:

* gdb.tui/list.exp: Test 'focus next' after 'list main'.

Change-Id: Id0b13f99b0e889261efedfd0adabe82020202f44

gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.tui/list.exp
gdb/tui/tui-layout.c

index 735333fdf65ea3fc8ce2e314a9c1810fdf6781b7..c24dccaaa97cf90806296b5691526cf7126281da 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-05  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * tui/tui-layout.c (tui_add_win_to_layout): Use tui_set_layout not
+       show_layout.
+
 2020-01-05  Luis Machado  <luis.machado@linaro.org>
 
        * aarch64-linux-nat.c
index 78f9700f25713b57073f66734638bd523108445d..ba857a46f3b6299a9ceb4cb96dffa67a8ff123f0 100644 (file)
@@ -1,3 +1,7 @@
+2020-01-05  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * gdb.tui/list.exp: Test 'focus next' after 'list main'.
+
 2020-01-03  Philippe Waroquiers  <philippe.waroquiers@skynet.be>
 
        * gdb.base/style.exp: Test that warnings are styled.
index a4a9fdabfb6eaf9aa8999912f6a4928581df1106..41cec125d534dcaa3cc62d7c4eeaf335eed244f9 100644 (file)
@@ -35,3 +35,6 @@ Term::check_contents "asm window shows main" "$hex <main>"
 
 Term::command "list main"
 Term::check_contents "list main" "21 *return 0"
+# The following 'focus next' must be immediately after 'list main' to
+# ensure that GDB has a valid idea of what is currently focused.
+Term::command "focus next"
index 1e9c5c53e3f5b2a856262f883572c0cc2523446b..3720d3edc3c2810c002a2272556d0663efa8d4bd 100644 (file)
@@ -201,9 +201,9 @@ tui_add_win_to_layout (enum tui_win_type type)
          && cur_layout != SRC_DATA_COMMAND)
        {
          if (cur_layout == DISASSEM_DATA_COMMAND)
-           show_layout (SRC_DATA_COMMAND);
+           tui_set_layout (SRC_DATA_COMMAND);
          else
-           show_layout (SRC_COMMAND);
+           tui_set_layout (SRC_COMMAND);
        }
       break;
     case DISASSEM_WIN:
@@ -212,9 +212,9 @@ tui_add_win_to_layout (enum tui_win_type type)
          && cur_layout != DISASSEM_DATA_COMMAND)
        {
          if (cur_layout == SRC_DATA_COMMAND)
-           show_layout (DISASSEM_DATA_COMMAND);
+           tui_set_layout (DISASSEM_DATA_COMMAND);
          else
-           show_layout (DISASSEM_COMMAND);
+           tui_set_layout (DISASSEM_COMMAND);
        }
       break;
     case DATA_WIN:
@@ -222,9 +222,9 @@ tui_add_win_to_layout (enum tui_win_type type)
          && cur_layout != DISASSEM_DATA_COMMAND)
        {
          if (cur_layout == DISASSEM_COMMAND)
-           show_layout (DISASSEM_DATA_COMMAND);
+           tui_set_layout (DISASSEM_DATA_COMMAND);
          else
-           show_layout (SRC_DATA_COMMAND);
+           tui_set_layout (SRC_DATA_COMMAND);
        }
       break;
     default:
This page took 0.032565 seconds and 4 git commands to generate.