From 2c83109da51757fe4801088f057cb9c7a152a90c Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 6 Jul 2022 13:46:11 -0700 Subject: [PATCH] struct type: Add TYPE_TAGGED property on types. Set this property on capability types and capability-sized pointer types. --- gdb/gdbtypes.c | 13 +++++++++++++ gdb/gdbtypes.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index dd4bb84924b..ee0a1b6c77c 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -374,6 +374,8 @@ make_pointer_type (struct type *type, struct type **typeptr) /* FIXME! Assumes the machine has only one representation for pointers! */ TYPE_LENGTH (ntype) = gdbarch_ptr_bit (type->arch ()) / TARGET_CHAR_BIT; + ntype->set_tagged (gdbarch_ptr_bit (type->arch ()) + == gdbarch_capability_bit (type->arch ())); ntype->set_code (TYPE_CODE_PTR); /* Mark pointers as unsigned. The target converts between pointers @@ -386,6 +388,7 @@ make_pointer_type (struct type *type, struct type **typeptr) while (chain != ntype) { TYPE_LENGTH (chain) = TYPE_LENGTH (ntype); + chain->set_tagged (ntype->is_tagged ()); chain = TYPE_CHAIN (chain); } @@ -773,6 +776,7 @@ make_capability_type (struct type *type) NULL); TYPE_LENGTH (ntype) = gdbarch_capability_bit (type->arch ()) / TARGET_CHAR_BIT; + ntype->set_tagged (true); return ntype; } @@ -3532,6 +3536,7 @@ init_capability_type (struct objfile *objfile, t = init_type (objfile, TYPE_CODE_CAPABILITY, bit, name); t->set_is_unsigned (unsigned_p); + t->set_tagged (true); return t; } @@ -5338,6 +5343,10 @@ recursive_dump_type (struct type *type, int spaces) { puts_filtered (" TYPE_CONTAINS_CAPABILITY"); } + if (type->is_tagged ()) + { + puts_filtered (" TYPE_TAGGED"); + } if (type->is_stub ()) { puts_filtered (" TYPE_STUB"); @@ -6250,9 +6259,11 @@ gdbtypes_post_init (struct gdbarch *gdbarch) builtin_type->builtin_intcap_t = arch_capability_type (gdbarch, gdbarch_capability_bit (gdbarch), 0, "__intcap_t"); + builtin_type->builtin_intcap_t->set_tagged (true); builtin_type->builtin_uintcap_t = arch_capability_type (gdbarch, gdbarch_capability_bit (gdbarch), 1, "__uintcap_t"); + builtin_type->builtin_uintcap_t->set_tagged (true); /* Capability pointer types. */ builtin_type->builtin_data_capability @@ -6261,6 +6272,7 @@ gdbtypes_post_init (struct gdbarch *gdbarch) builtin_type->builtin_data_capability->set_instance_flags (builtin_type->builtin_data_capability->instance_flags () | TYPE_INSTANCE_FLAG_CAPABILITY); + builtin_type->builtin_data_capability->set_tagged (true); builtin_type->builtin_code_capability = arch_pointer_type (gdbarch, gdbarch_capability_bit (gdbarch), "", @@ -6268,6 +6280,7 @@ gdbtypes_post_init (struct gdbarch *gdbarch) builtin_type->builtin_code_capability->set_instance_flags (builtin_type->builtin_code_capability->instance_flags () | TYPE_INSTANCE_FLAG_CAPABILITY); + builtin_type->builtin_code_capability->set_tagged (true); /* This type represents a GDB internal function. */ builtin_type->internal_fn diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 04d89538e1e..013938648fb 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -922,6 +922,7 @@ struct main_type unsigned int m_flag_objfile_owned : 1; unsigned int m_flag_endianity_not_default : 1; unsigned int m_flag_contains_capability : 1; + unsigned int m_flag_tagged : 1; /* * True if this type was declared with "class" rather than "struct". */ @@ -1367,6 +1368,17 @@ struct type const gdb_mpq &fixed_point_scaling_factor (); + /* Indicates whether this type is tagged. */ + bool is_tagged () const + { + return this->main_type->m_flag_tagged; + } + + void set_tagged (bool tagged) + { + this->main_type->m_flag_tagged = tagged; + } + /* Indicates whether this type contains a capability. */ bool contains_capability () const -- 2.47.2