From: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
To: <gdb-patches@sourceware.org>
Cc: <tom@tromey.com>
Subject: [PATCH v2 00/17] Rewrite type instance flags as a struct with bitfields
Date: Wed, 22 Jul 2026 05:41:49 -0500 [thread overview]
Message-ID: <20260722-users-aktemur-type-instance-flags-v2-0-d60dcbc2a76f@amd.com> (raw)
This is v2 of the series at
https://inbox.sourceware.org/gdb-patches/20260713-users-aktemur-type-instance-flags-v1-0-779cad0c85ec@amd.com
This revision addresses the review comments given by Tom Tromey. The
patch titled "gdb: refactor type_stack::insert methods" is new.
Some patches are already approved. They are still included in the
series for completeness.
===
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
---
Tankut Baris Aktemur (17):
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: refactor type_stack::insert methods
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 | 33 ++-
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 | 34 +--
gdb/gdbarch_components.py | 24 +-
gdb/gdbtypes.c | 260 +++++++--------------
gdb/gdbtypes.h | 231 +++++++++++-------
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 | 85 ++++---
gdb/type-stack.h | 49 ++--
gdb/valops.c | 10 +-
32 files changed, 595 insertions(+), 599 deletions(-)
---
base-commit: 640a79623d40d951092e3da46075d8db6b4679f1
change-id: 20260713-users-aktemur-type-instance-flags-71f5a70c9875
Best regards,
--
Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
next reply other threads:[~2026-07-22 10:43 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 10:41 Tankut Baris Aktemur [this message]
2026-07-22 10:41 ` [PATCH v2 01/17] gdb: use type instance macros to query const, volatile, restrict Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 02/17] gdb: convert address_class_type_flags_to_name to address_class_id_to_name Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 03/17] gdb: convert address_class_name_to_type_flags to address_class_name_to_id Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 04/17] gdb: convert address_class_type_flags to address_class_dwarf_to_id Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 05/17] gdb: refactor type_stack::insert methods Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 06/17] gdb: inline address_space_{name, type_instance_flags}_to_{type_instance_flags, name} Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 07/17] gdb: split make_type_with_address_space Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 08/17] gdb: convert type instance flags to bitfields Tankut Baris Aktemur
2026-07-24 19:10 ` Keith Seitz
2026-07-22 10:41 ` [PATCH v2 09/17] gdb: convert TYPE_NOTTEXT macro to type::is_nottext Tankut Baris Aktemur
2026-07-22 10:41 ` [PATCH v2 10/17] gdb: convert TYPE_CONST macro to type::is_const Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 11/17] gdb: convert TYPE_VOLATILE macro to type::is_volatile Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 12/17] gdb: convert TYPE_CODE_SPACE macro to type::is_code_space Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 13/17] gdb: convert TYPE_DATA_SPACE macro to type::is_data_space Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 14/17] gdb: convert TYPE_RESTRICT macro to type::is_restrict Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 15/17] gdb: convert TYPE_ATOMIC macro to type::is_atomic Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 16/17] gdb: convert TYPE_ADDRESS_CLASS macro to type::address_class Tankut Baris Aktemur
2026-07-22 10:42 ` [PATCH v2 17/17] gdb: remove unnecessary braces in recursive_dump_type Tankut Baris Aktemur
2026-07-22 15:42 ` [PATCH v2 00/17] Rewrite type instance flags as a struct with bitfields Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260722-users-aktemur-type-instance-flags-v2-0-d60dcbc2a76f@amd.com \
--to=tankutbaris.aktemur@amd.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox