aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuis Machado <luis.machado@linaro.org>2020-06-15 15:11:07 -0300
committerLuis Machado <luis.machado@linaro.org>2020-06-25 13:23:38 -0300
commitdddcc4b5eec8b9c89c54131ddcb6c73949de98ea (patch)
treee5dcf4ce4ba144e888502086d2e324295f36e075
parent74e76b725d270a7d800ba472b780eaac0d9cfc78 (diff)
downloadgdb-dddcc4b5eec8b9c89c54131ddcb6c73949de98ea.zip
gdb-dddcc4b5eec8b9c89c54131ddcb6c73949de98ea.tar.gz
gdb-dddcc4b5eec8b9c89c54131ddcb6c73949de98ea.tar.bz2
AArch64: Add unit testing for logical tag set/get operations
Add some unit testing to exercise setting/getting logical tags in the AArch64 implementation. gdb/ChangeLog: YYYY-MM-DD Luis Machado <luis.machado@linaro.org> * aarch64-linux-tdep.c: Include gdbsupport/selftest.h. (aarch64_linux_ltag_tests): New function. (_initialize_aarch64_linux_tdep): Register aarch64_linux_ltag_tests.
-rw-r--r--gdb/aarch64-linux-tdep.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c
index 0cc2e74..892977d 100644
--- a/gdb/aarch64-linux-tdep.c
+++ b/gdb/aarch64-linux-tdep.c
@@ -50,6 +50,8 @@
#include "arch-utils.h"
#include "value.h"
+#include "gdbsupport/selftest.h"
+
/* Signal frame handling.
+------------+ ^
@@ -1900,10 +1902,39 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
set_gdbarch_gcc_target_options (gdbarch, aarch64_linux_gcc_target_options);
}
+#if GDB_SELF_TEST
+
+namespace selftests {
+
+/* Verify functions to read and write logical tags. */
+
+static void
+aarch64_linux_ltag_tests (void)
+{
+ /* We have 4 bits of tags, but we test writing all the bits of the top
+ byte of address. */
+ for (int i = 0; i < 1 << 8; i++)
+ {
+ CORE_ADDR addr = ((CORE_ADDR) i << 56) | 0xdeadbeef;
+ SELF_CHECK (aarch64_linux_get_ltag (addr) == (i & 0xf));
+
+ addr = aarch64_linux_set_ltag (0xdeadbeef, i);
+ SELF_CHECK (addr = ((CORE_ADDR) (i & 0xf) << 56) | 0xdeadbeef);
+ }
+}
+
+} // namespace selftests
+#endif /* GDB_SELF_TEST */
+
void _initialize_aarch64_linux_tdep ();
void
_initialize_aarch64_linux_tdep ()
{
gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_LINUX,
aarch64_linux_init_abi);
+
+#if GDB_SELF_TEST
+ selftests::register_test ("aarch64-linux-tagged-address",
+ selftests::aarch64_linux_ltag_tests);
+#endif
}