gdb/tui: don't add windows to global list from tui_layout:window::apply
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 25 Jan 2021 15:46:58 +0000 (15:46 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 8 Feb 2021 11:18:33 +0000 (11:18 +0000)
commit1cf2399651ef3fe1350ad8276cf00d16ddeb9960
treeef7670ef713ccdc3f2013d9477a0c4882032c5d7
parenta53a265752ef4b911d175aea62e082e54e717497
gdb/tui: don't add windows to global list from tui_layout:window::apply

This commit was inspired by this mailing list patch:

  https://sourceware.org/pipermail/gdb-patches/2021-January/174713.html

Currently, calling tui_layout_window::apply will add the window from
the layout object to the global tui_windows list.

Unfortunately, when the user runs the 'winheight' command, this calls
tui_adjust_window_height, which calls the tui_layout_base::adjust_size
function, which can then call tui_layout_base::apply.  The consequence
of this is that when the user does 'winheight' duplicate copies of a
window can be added to the global tui_windows list.

The original patch fixed this by changing the apply function to only
update the global list some of the time.

This patch takes a different approach.  The apply function no longer
updates the global tui_windows list.  Instead a new virtual function
is added to tui_layout_base which is used to gather all the currently
applied windows into a vector.  Finally tui_apply_current_layout is
updated to make use of this new function to update the tui_windows
list.

The benefits I see in this approach are, (a) the apply function now no
longer touches global state, this solves the immediate problem,
and (b) now that tui_windows is updated directly in the function
tui_apply_current_layout, we can drop the saved_tui_windows global.

gdb/ChangeLog:

* tui-layout.c (saved_tui_windows): Delete.
(tui_apply_current_layout): Don't make use of saved_tui_windows,
call new get_windows member function instead.
(tui_get_window_by_name): Check in tui_windows.
(tui_layout_window::apply): Don't add to tui_windows.
* tui-layout.h (tui_layout_base::get_windows): New member function.
(tui_layout_window::get_windows): Likewise.
(tui_layout_split::get_windows): Likewise.

gdb/testsuite/ChangeLog:

* gdb.tui/winheight.exp: Add more tests.
gdb/ChangeLog
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.tui/winheight.exp
gdb/tui/tui-layout.c
gdb/tui/tui-layout.h
This page took 0.039572 seconds and 4 git commands to generate.