[PATCH 0/3 v4] gdb: Make printing enum types prettier

Daniel Knezevic
2025-11-26T12:03:43Z

This is v4 of:
https://inbox.sourceware.org/gdb-patches/20251124132726.325366-1-daniel.knezevic@htecgroup.com/

Patch 1:
- A preparation patch, as suggested by Simon, that moves logic for printing
enums to a helper function.

Patch 2:
- Updates tests to use multi_line as a preparation step for future changes
related to enum printing.

Patch 3:
- Implements the new way of printing enums and updates tests using enums.
- I tried to reduce the number of print calls to minimum by using fprintf_styled
function. When printing <variable name> = <value> two print calls are
used. The reason for this is maintain printing in the right style (keep the
same color scheme as before). The first fprintf_styled prints a colored
(styled) variable name, then the gdb_printf prints out the value in default
color.

Daniel Knezevic (3):
gdb: Move logic for printing enums to a helper function
gdb: Replace \r\n with multi_line to make tests more readable
gdb: Make printing enum types prettier.

gdb/c-typeprint.c | 151 +++++++-------
gdb/testsuite/gdb.base/call-sc.exp | 11 +-
gdb/testsuite/gdb.base/ctf-ptype.exp | 181 ++++++++++++++---
gdb/testsuite/gdb.base/ptype.exp | 186 +++++++++++++++---
.../gdb.base/whatis-ptype-typedefs.exp | 8 +-
gdb/testsuite/gdb.cp/classes.exp | 27 ++-
gdb/testsuite/gdb.cp/empty-enum.exp | 24 ++-
gdb/testsuite/gdb.cp/enum-class.exp | 6 +-
gdb/testsuite/gdb.cp/nested-types.exp | 6 +-
gdb/testsuite/gdb.dwarf2/enum-type.exp | 14 +-
gdb/testsuite/gdb.xml/tdesc-regs.exp | 39 +++-
gdb/testsuite/lib/cp-support.exp | 39 +++-
12 files changed, 529 insertions(+), 163 deletions(-)

--
2.43.0