]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Write memory capabilities atomically.
authorJohn Baldwin <jhb@FreeBSD.org>
Wed, 10 Aug 2022 19:14:16 +0000 (12:14 -0700)
committerJohn Baldwin <jhb@FreeBSD.org>
Thu, 1 Sep 2022 23:47:42 +0000 (16:47 -0700)
Use target_write_capability to write a capability atomically in
put_frame_register.

gdb/frame.c

index 44b3bd0946378713cd920c1d41159aaa7d74f8d4..bc3189e3dac103b88a38f7dee5831b85ecfee9e4 100644 (file)
@@ -1399,15 +1399,21 @@ put_frame_register (struct frame_info *frame, int regnum,
     {
     case lval_memory:
       {
-       write_memory (addr, buf, register_size (gdbarch, regnum));
-
        /* If this value is a capability, we need to handle the capability tag
-          as well.  */
+          as an atomic write.  */
        if ((val_type->code () == TYPE_CODE_CAPABILITY
            || (val_type->code () == TYPE_CODE_PTR
                && TYPE_CAPABILITY (val_type)))
            && value_tagged (fromval))
-         gdbarch_set_cap_tag_from_address (gdbarch, addr, value_tag (fromval));
+         {
+           gdb::byte_vector cap (register_size (gdbarch, regnum) + 1);
+
+           cap[0] = value_tag (fromval) ? 1 : 0;
+           memcpy (cap.data () + 1, buf, register_size (gdbarch, regnum));
+           if (target_write_capability (addr, cap))
+             break;
+         }
+       write_memory (addr, buf, register_size (gdbarch, regnum));
        break;
       }
     case lval_register: