]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: aarch64: Move MTE address check out of set_memtag
authorGustavo Romero <gustavo.romero@linaro.org>
Thu, 18 Apr 2024 20:10:33 +0000 (20:10 +0000)
committerLuis Machado <luis.machado@arm.com>
Fri, 19 Apr 2024 14:29:39 +0000 (15:29 +0100)
Remove check in parse_set_allocation_tag_input as it is redundant:
currently the check happens at the end of parse_set_allocation_tag_input
and also in set_memtag (called after parse_set_allocation_tag_input).

After it, move MTE address check out of set_memtag and add this check to
the upper layer, before set_memtag is called.

This is a preparation for using a target hook instead of a gdbarch hook
on MTE address checks.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Approved-By: Luis Machado <luis.machado@arm.com>
gdb/aarch64-linux-tdep.c
gdb/printcmd.c

index 50055ac3f48d15be69610b37a06400b8eb15c55f..8e6e63d4dcb9619f374987da92e8b9511e58395c 100644 (file)
@@ -2525,10 +2525,6 @@ aarch64_linux_set_memtags (struct gdbarch *gdbarch, struct value *address,
       /* Remove the top byte.  */
       addr = gdbarch_remove_non_address_bits (gdbarch, addr);
 
-      /* Make sure we are dealing with a tagged address to begin with.  */
-      if (!aarch64_linux_tagged_address_p (gdbarch, address))
-       return false;
-
       /* With G being the number of tag granules and N the number of tags
         passed in, we can have the following cases:
 
index cb0d32aa4bcffd70aefbee876878ff807a036edc..5635f60531419c974ec884153867e0687ddc1256 100644 (file)
@@ -3101,11 +3101,6 @@ parse_set_allocation_tag_input (const char *args, struct value **val,
     error (_("Error parsing tags argument. Tags should be 2 digits per byte."));
 
   tags = hex2bin (tags_string.c_str ());
-
-  /* If the address is not in a region memory mapped with a memory tagging
-     flag, it is no use trying to access/manipulate its allocation tag.  */
-  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), *val))
-    show_addr_not_tagged (value_as_address (*val));
 }
 
 /* Implement the "memory-tag set-allocation-tag" command.
@@ -3127,6 +3122,11 @@ memory_tag_set_allocation_tag_command (const char *args, int from_tty)
   /* Parse the input.  */
   parse_set_allocation_tag_input (args, &val, &length, tags);
 
+  /* If the address is not in a region memory-mapped with a memory tagging
+     flag, it is no use trying to manipulate its allocation tag.  */
+  if (!gdbarch_tagged_address_p (current_inferior ()->arch (), val))
+    show_addr_not_tagged (value_as_address (val));
+
   if (!gdbarch_set_memtags (current_inferior ()->arch (), val, length, tags,
                            memtag_type::allocation))
     gdb_printf (_("Could not update the allocation tag(s).\n"));