Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH 00/16] Rewrite type instance flags as a struct with bitfields
@ 2026-07-13 13:59 Tankut Baris Aktemur
  2026-07-13 14:00 ` [PATCH 01/16] gdb: use type instance macros to query const, volatile, restrict Tankut Baris Aktemur
                   ` (15 more replies)
  0 siblings, 16 replies; 30+ messages in thread
From: Tankut Baris Aktemur @ 2026-07-13 13:59 UTC (permalink / raw)
  To: gdb-patches

A type in GDB has an "instance flags" fields that encodes some
information about the type as a bitmask.  The information includes
things like whether the type is const, volatile, restrict, etc.  These
are boolean flags and the meaning is clear.

There are two bits to encode Harvard address space information (code
and data space), which are seemingly indepedent bits in the current
encoding.  However, those two bits essentially encode an enum of
no-space, code-space, and data-space.  That is, it doesn't make sense
that code and data space bits are both set.  But the current encoding
does not make this clear.

Similarly, two bits are allocated to store address class information.
Architectures are left completely free to set/unset these bits to
encode address class information specific to them.  It is reasonable
to expect that architectures would also encode enum values in these
bits.  (Currently, in upstream GDB, there are three architectures that
use the address class information: avr, ft32, and s390.  They all use
the first bit only.)

The aim of this series is to rewrite type instance flags to a struct
with bitfields with boolean types for flag fields and unsigned scalar
types for Harvard address space and address class information to
enable enum-like usage.  This transformation helps make the code
cleaner by avoiding low level bitwise manipulation and by not passing
the complete bitmask around.

A complication in this rewrite is the Harvard address space and
address class topics.  First, the code and data space topic is
currently usually referred to as "address space" in the code.
However, "address space" is an overloaded term.  For example, see the
DWARF issues

  https://dwarfstd.org/issues/260617.1.html

and

  https://dwarfstd.org/issues/260211.1.html

and OpenCL's address space qualifiers:

  https://registry.khronos.org/OpenCL/specs/unified/refpages/man/html/addressSpaceQualifiers.html

To make the current meaning of "address space" in GDB code base clear,
the series aims to consistently say "Harvard address spaces" and
update the code accordingly.  (Based on the DWARF discussions listed
above, we can expect GDB to have support for target architecture
address spaces in the future; so it would be nice to separate the
topics.)

Furthermore, when dealing with Harvard address spaces and address
classes, GDB passes a whole type instance flags bitmask value around,
which makes the boundaries unclear.  For example,
`address_space_name_to_type_instance_flags` takes a Harvard address
space or an address class name, and returns type instance flags.  The
function `address_space_type_instance_flags_to_name` does the opposite
transformation.  The separation between the two concepts is not
reflected.  The series performs a number of renamings and refactorings
to gradually separate the two topics and make type instance flags
clearer, eventually reaching a struct definition.

Regards,
Baris

Signed-off-by: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
---
Tankut Baris Aktemur (16):
      gdb: use type instance macros to query const, volatile, restrict
      gdb: convert address_class_type_flags_to_name to address_class_id_to_name
      gdb: convert address_class_name_to_type_flags to address_class_name_to_id
      gdb: convert address_class_type_flags to address_class_dwarf_to_id
      gdb: inline address_space_{name,type_instance_flags}_to_{type_instance_flags,name}
      gdb: split make_type_with_address_space
      gdb: convert type instance flags to bitfields
      gdb: convert TYPE_NOTTEXT macro to type::is_nottext
      gdb: convert TYPE_CONST macro to type::is_const
      gdb: convert TYPE_VOLATILE macro to type::is_volatile
      gdb: convert TYPE_CODE_SPACE macro to type::is_code_space
      gdb: convert TYPE_DATA_SPACE macro to type::is_data_space
      gdb: convert TYPE_RESTRICT macro to type::is_restrict
      gdb: convert TYPE_ATOMIC macro to type::is_atomic
      gdb: convert TYPE_ADDRESS_CLASS macro to type::address_class
      gdb: remove unnecessary braces in recursive_dump_type

 gdb/avr-tdep.c                                     |  62 +++--
 gdb/c-typeprint.c                                  |  37 ++-
 gdb/c-valprint.c                                   |   2 +-
 gdb/compile/compile-c-types.c                      |  10 +-
 gdb/compile/compile-cplus-types.c                  |  16 +-
 gdb/ctfread.c                                      |   8 +-
 gdb/d-lang.c                                       |   9 +-
 gdb/dwarf2/read.c                                  |  26 +--
 gdb/expop.h                                        |   6 +
 gdb/expprint.c                                     |   4 +-
 gdb/ft32-tdep.c                                    |  50 ++--
 gdb/gdb-gdb.py.in                                  |  99 ++------
 gdb/gdbarch-gen.c                                  |  92 ++++----
 gdb/gdbarch-gen.h                                  |  28 +--
 gdb/gdbarch_components.py                          |  16 +-
 gdb/gdbtypes.c                                     | 258 +++++++--------------
 gdb/gdbtypes.h                                     | 228 +++++++++++-------
 gdb/gnu-v3-abi.c                                   |   2 +-
 gdb/iq2000-tdep.c                                  |   2 +-
 gdb/m2-typeprint.c                                 |   2 +-
 gdb/m2-valprint.c                                  |   2 +-
 gdb/opencl-lang.c                                  |   2 +-
 gdb/printcmd.c                                     |  12 +-
 gdb/python/py-type.c                               |   8 +-
 gdb/rl78-tdep.c                                    |   2 +-
 gdb/s390-tdep.c                                    |  38 +--
 gdb/testsuite/gdb.base/address_space_qualifier.exp |   4 +-
 gdb/testsuite/gdb.base/maint.exp                   |   2 +-
 gdb/testsuite/gdb.gdb/python-helper.exp            |   8 +-
 gdb/type-stack.c                                   |  70 ++++--
 gdb/type-stack.h                                   |  31 ++-
 gdb/valops.c                                       |  10 +-
 32 files changed, 567 insertions(+), 579 deletions(-)
---
base-commit: fbafe3b994c6f8f9778bab0b3160e9a21bfa211f
change-id: 20260713-users-aktemur-type-instance-flags-71f5a70c9875

Best regards,
--  
Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>


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

end of thread, other threads:[~2026-07-22 13:38 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-13 13:59 [PATCH 00/16] Rewrite type instance flags as a struct with bitfields Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 01/16] gdb: use type instance macros to query const, volatile, restrict Tankut Baris Aktemur
2026-07-21 17:52   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 02/16] gdb: convert address_class_type_flags_to_name to address_class_id_to_name Tankut Baris Aktemur
2026-07-21 18:03   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 03/16] gdb: convert address_class_name_to_type_flags to address_class_name_to_id Tankut Baris Aktemur
2026-07-21 18:10   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 04/16] gdb: convert address_class_type_flags to address_class_dwarf_to_id Tankut Baris Aktemur
2026-07-21 18:19   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 05/16] gdb: inline address_space_{name, type_instance_flags}_to_{type_instance_flags, name} Tankut Baris Aktemur
2026-07-21 18:29   ` Tom Tromey
2026-07-22 10:29     ` Aktemur, Baris
2026-07-22 13:38       ` Tom Tromey
2026-07-13 14:00 ` [PATCH 06/16] gdb: split make_type_with_address_space Tankut Baris Aktemur
2026-07-21 18:49   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 07/16] gdb: convert type instance flags to bitfields Tankut Baris Aktemur
2026-07-21 19:13   ` Tom Tromey
2026-07-22 10:29     ` Aktemur, Baris
2026-07-13 14:00 ` [PATCH 08/16] gdb: convert TYPE_NOTTEXT macro to type::is_nottext Tankut Baris Aktemur
2026-07-21 18:39   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 09/16] gdb: convert TYPE_CONST macro to type::is_const Tankut Baris Aktemur
2026-07-21 18:40   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 10/16] gdb: convert TYPE_VOLATILE macro to type::is_volatile Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 11/16] gdb: convert TYPE_CODE_SPACE macro to type::is_code_space Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 12/16] gdb: convert TYPE_DATA_SPACE macro to type::is_data_space Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 13/16] gdb: convert TYPE_RESTRICT macro to type::is_restrict Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 14/16] gdb: convert TYPE_ATOMIC macro to type::is_atomic Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 15/16] gdb: convert TYPE_ADDRESS_CLASS macro to type::address_class Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 16/16] gdb: remove unnecessary braces in recursive_dump_type Tankut Baris Aktemur
2026-07-21 18:45   ` Tom Tromey

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