[PATCH 00/66] Clean up the TUI

Tom Tromey
2019-06-23T22:43:41Z

My first real encounter with the TUI code was last year, when I added
syntax styling to it.

On the one hand, this experience convinced me that this code was some
of the ugliest in gdb. It uses two different unions at different
spots in the conceptual class hierarchy, leading to very obscure code.
It also hard-codes both the possible window types but also the
qpossible layout types in a brittle and unextensible way.

On the other hand, working on the TUI changed my mind about the TUI
generally. I've become a fan. I think it would be good to improve
the TUI for users, but to do that I think we first have to improve its
code.

This series is a start at this. It's already quite long,
unfortunately, and yet is still incomplete. Still, I think it is
progress. This series:

* Splits tui_win_info into subclasses, one per window type.

* Adds virtual methods, particularly in an attempt to remove all the
code that switches based on the type of the window. This is
important to make it simpler to add new window types.

* Changes tui_gen_win_info into a real base class for tui_win_info.

* Removes the uses of unions from the window class hierarchy.

* Simplifies and C++-ifies various other minor things along the way.

There is still a ways to go, I only stopped here in the interest of
review sanity. In particular:

* Window layouts should be first-class entities that do not involve
hard-coding the possible layouts in the C++.

* tui_win_list should be changed to allow multiple types of windows.

* The few remaining checks of the various *_WIN constants should be
removed.

I think once these things are done it should be possible to move on to
making useful user-visible changes, like allowing custom layouts, or
allowing custom windows to be written in Python.

I tested this by trying the various TUI features by hand. However,
I'm not sure I managed to test them all. I've also run the gdb.tui
part of the test suite, though that does not really test very much.

This series fixes one latent bug that I found with valgrind. I found
two other existing bugs as well, but those I simply filed.

Tom