]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
make_pointer_type: Set TYPE_INSTANCE_FLAG_CAPABILITY on cap pointers.
authorJohn Baldwin <jhb@FreeBSD.org>
Thu, 17 Nov 2022 22:31:26 +0000 (14:31 -0800)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 17 Nov 2022 22:31:26 +0000 (14:31 -0800)
For purecap this isn't always set by DWARF attributes, and in particular
it isn't for CHERI-RISC-V.

gdb/gdbtypes.c

index d18d7f0a0a47157e18147f82ea4f3b04e3c12cc7..858219c5953dc8a515895a5be0ac5769b9f71ee4 100644 (file)
@@ -377,6 +377,8 @@ make_pointer_type (struct type *type, struct type **typeptr)
   ntype->set_tagged (gdbarch_ptr_bit (type->arch ())
                     == gdbarch_capability_bit (type->arch ()));
   ntype->set_code (TYPE_CODE_PTR);
+  if (ntype->is_tagged ())
+    ntype->set_instance_flags (TYPE_INSTANCE_FLAG_CAPABILITY);
 
   /* Mark pointers as unsigned.  The target converts between pointers
      and addresses (CORE_ADDRs) using gdbarch_pointer_to_address and
@@ -389,6 +391,12 @@ make_pointer_type (struct type *type, struct type **typeptr)
     {
       TYPE_LENGTH (chain) = TYPE_LENGTH (ntype);
       chain->set_tagged (ntype->is_tagged ());
+      if (ntype->is_tagged ())
+       chain->set_instance_flags (chain->instance_flags ()
+                                  | TYPE_INSTANCE_FLAG_CAPABILITY);
+      else
+       chain->set_instance_flags (chain->instance_flags ()
+                                  & ~TYPE_INSTANCE_FLAG_CAPABILITY);
       chain = TYPE_CHAIN (chain);
     }