]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify tag management in value structs
authorLuis Machado <luis.machado@linaro.org>
Thu, 30 Dec 2021 14:10:07 +0000 (11:10 -0300)
committerLuis Machado <luis.machado@linaro.org>
Fri, 14 Jan 2022 14:30:35 +0000 (11:30 -0300)
Instead of actively setting the tagged field of struct value *, initialize
the tagged field right when allocating a new value. This simplifies the
management of this field.

gdb/aarch64-tdep.c
gdb/value.c

index 587ccf5dbc3ba580e0d1d62eef337529ed79f8e6..9c010cc0edcea13648e0f01f4fe61570c12153c2 100644 (file)
@@ -1453,10 +1453,7 @@ aarch64_prologue_prev_register (struct frame_info *this_frame,
 
       /* Copy the capability tag over, if it exists.  */
       if (prev_regnum == tdep->cap_reg_pcc && value_tagged (lr_value))
-       {
-         set_value_tagged (lr_value_adjusted, 1);
-         set_value_tag (lr_value_adjusted, value_tag (lr_value));
-       }
+       set_value_tag (lr_value_adjusted, value_tag (lr_value));
 
       return lr_value_adjusted;
     }
@@ -1651,10 +1648,7 @@ aarch64_dwarf2_prev_register (struct frame_info *this_frame,
 
       /* Copy the capability tag over, if it exists.  */
       if (regnum == tdep->cap_reg_pcc && value_tagged (lr_value))
-       {
-         set_value_tagged (lr_value_adjusted, 1);
-         set_value_tag (lr_value_adjusted, value_tag (lr_value));
-       }
+       set_value_tag (lr_value_adjusted, value_tag (lr_value));
 
       return lr_value_adjusted;
     }
@@ -3476,7 +3470,6 @@ morello_extract_return_value (struct value *value, struct regcache *regs,
       if (aapcs64_cap)
        {
          regno = tdep->cap_reg_base + AARCH64_X0_REGNUM;
-         set_value_tagged (value, true);
          set_value_tag (value, true);
        }
       else
index fde31dbe70f067ce9a3ba6da8893fad11a9f98cc..b1414fe78f3356445b23a4aab76995dcb5196204 100644 (file)
@@ -178,10 +178,13 @@ struct value
       lazy (1),
       initialized (1),
       stack (0),
-      tagged (0),
       type (type_),
       enclosing_type (type_)
   {
+    if (type_ != nullptr
+       && (type_->code () == TYPE_CODE_CAPABILITY
+           || TYPE_CAPABILITY (type_)))
+      tagged = 1;
   }
 
   ~value ()
@@ -341,7 +344,7 @@ struct value
   LONGEST pointed_to_offset = 0;
 
   /* The tag value, if tagged.  */
-  bool tag;
+  bool tag = false;
 
   /* Actual contents of the value.  Target byte-order.  NULL or not
      valid if lazy is nonzero.  */
@@ -3857,7 +3860,6 @@ value_fetch_lazy_memory (struct value *val)
 
   if (TYPE_CAPABILITY (type))
     {
-      set_value_tagged (val, true);
       bool tag = gdbarch_get_cap_tag_from_address (get_value_arch (val), addr);
       set_value_tag (val, tag);
     }