]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
struct type: Add TYPE_TAGGED property on types.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 6 Jul 2022 20:46:11 +0000 (13:46 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 23:43:05 +0000 (16:43 -0700)
Set this property on capability types and capability-sized pointer
types.

gdb/gdbtypes.c
gdb/gdbtypes.h

index dd4bb84924bfcfc5ca3ea032736c6695afb49e1a..ee0a1b6c77cd925f7e6f1d1143bb4e09b88b05e3 100644 (file)
@@ -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
index 04d89538e1e817d68727e56b8d29b7e4bded574e..013938648fb19aebca55ade3578dbc88f4272c4c 100644 (file)
@@ -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