]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Read memory capabilities atomically.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 10 Aug 2022 19:05:52 +0000 (12:05 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 23:47:42 +0000 (16:47 -0700)
When resolving a lazy memory capability value, use
target_read_capability to read the entire capability directly rather
than only using it to read the tag.  Also, just use
target_read_capability directly without requiring a gdbarch wrapper
method.

gdb/value.c

index 1dad82823c411c3013d089fe7359b55d1033d3db..1c0b8d5e4dddaefaa918e2b19e9a33efe1c2a8b3 100644 (file)
@@ -3960,16 +3960,25 @@ value_fetch_lazy_memory (struct value *val)
   CORE_ADDR addr = value_address (val);
   struct type *type = check_typedef (value_enclosing_type (val));
 
+  if (TYPE_CAPABILITY (type))
+    {
+      gdb::byte_vector cap = target_read_capability (addr);
+      if (cap.size () == TYPE_LENGTH (type) + 1)
+       {
+         memcpy (value_contents_all_raw (val).data (), cap.data () + 1,
+                 TYPE_LENGTH (type));
+         set_value_tag (val, cap[0] != 0);
+         return;
+       }
+    }
+
   if (TYPE_LENGTH (type))
       read_value_memory (val, 0, value_stack (val),
                         addr, value_contents_all_raw (val).data (),
                         type_length_units (type));
 
   if (TYPE_CAPABILITY (type))
-    {
-      bool tag = gdbarch_get_cap_tag_from_address (get_value_arch (val), addr);
-      set_value_tag (val, tag);
-    }
+    set_value_tag (val, false);
 }
 
 /* Helper for value_fetch_lazy when the value is in a register.  */