summaryrefslogtreecommitdiff
path: root/gdb/arch-utils.c
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@linaro.org>2020-06-19 17:36:14 -0300
committerLuis Machado <luis.machado@linaro.org>2021-03-24 14:47:52 -0300
commitc193949e75809a656b99c8408e5b29504aec436a (patch)
treee8adec412217398f1684fe69a4a26d63f3be7046 /gdb/arch-utils.c
parentdbe692af2d1814100748b18a5dd70214e8611107 (diff)
downloadbinutils-gdb-c193949e75809a656b99c8408e5b29504aec436a.tar.gz
New gdbarch memory tagging hooks
We need some new gdbarch hooks to help us manipulate memory tags without having to have GDB call the target methods directly. This patch adds the following hooks: gdbarch_memtag_to_string -- Returns a printable string corresponding to the tag. gdbarch_tagged_address_p -- Checks if a particular address is protected with memory tagging. gdbarch_memtag_matches_p -- Checks if the logical tag of a pointer and the allocation tag from the address the pointer points to matches. gdbarch_set_memtags: -- Sets either the allocation tag or the logical tag for a particular value. gdbarch_get_memtag: -- Gets either the allocation tag or the logical tag for a particular value. gdbarch_memtag_granule_size -- Sets the memory tag granule size, which represents the number of bytes a particular allocation tag covers. For example, this is 16 bytes for AArch64's MTE. I've used struct value as opposed to straight CORE_ADDR so other architectures can use the infrastructure without having to rely on a particular type for addresses/pointers. Some architecture may use pointers of 16 bytes that don't fit in a CORE_ADDR, for example. gdb/ChangeLog: 2021-03-24 Luis Machado <luis.machado@linaro.org> * arch-utils.c (default_memtag_to_string, default_tagged_address_p) (default_memtag_matches_p, default_set_memtags) (default_get_memtag): New functions. * arch-utils.h (default_memtag_to_string, default_tagged_address_p) (default_memtag_matches_p, default_set_memtags) (default_get_memtag): New prototypes. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. * gdbarch.sh (memtag_to_string, tagged_address_p, memtag_matches_p) (set_memtags, get_memtag, memtag_granule_size): New gdbarch hooks. (enum memtag_type): New enum.
Diffstat (limited to 'gdb/arch-utils.c')
-rw-r--r--gdb/arch-utils.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index b5547424e48..0017e706ef1 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -77,6 +77,55 @@ legacy_register_sim_regno (struct gdbarch *gdbarch, int regnum)
return LEGACY_SIM_REGNO_IGNORE;
}
+
+/* See arch-utils.h */
+
+std::string
+default_memtag_to_string (struct gdbarch *gdbarch, struct value *tag)
+{
+ error (_("This architecture has no method to convert a memory tag to"
+ " a string."));
+}
+
+/* See arch-utils.h */
+
+bool
+default_tagged_address_p (struct gdbarch *gdbarch, struct value *address)
+{
+ /* By default, assume the address is untagged. */
+ return false;
+}
+
+/* See arch-utils.h */
+
+bool
+default_memtag_matches_p (struct gdbarch *gdbarch, struct value *address)
+{
+ /* By default, assume the tags match. */
+ return true;
+}
+
+/* See arch-utils.h */
+
+bool
+default_set_memtags (struct gdbarch *gdbarch, struct value *address,
+ size_t length, const gdb::byte_vector &tags,
+ memtag_type tag_type)
+{
+ /* By default, return true (successful); */
+ return true;
+}
+
+/* See arch-utils.h */
+
+struct value *
+default_get_memtag (struct gdbarch *gdbarch, struct value *address,
+ memtag_type tag_type)
+{
+ /* By default, return no tag. */
+ return nullptr;
+}
+
CORE_ADDR
generic_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{