GNU Binutils with patches for OS216
Revisión | dddcc4b5eec8b9c89c54131ddcb6c73949de98ea (tree) |
---|---|
Tiempo | 2020-06-26 01:23:38 |
Autor | Luis Machado <luis.machado@lina...> |
Commiter | Luis Machado |
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.
@@ -50,6 +50,8 @@ | ||
50 | 50 | #include "arch-utils.h" |
51 | 51 | #include "value.h" |
52 | 52 | |
53 | +#include "gdbsupport/selftest.h" | |
54 | + | |
53 | 55 | /* Signal frame handling. |
54 | 56 | |
55 | 57 | +------------+ ^ |
@@ -1900,10 +1902,39 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
1900 | 1902 | set_gdbarch_gcc_target_options (gdbarch, aarch64_linux_gcc_target_options); |
1901 | 1903 | } |
1902 | 1904 | |
1905 | +#if GDB_SELF_TEST | |
1906 | + | |
1907 | +namespace selftests { | |
1908 | + | |
1909 | +/* Verify functions to read and write logical tags. */ | |
1910 | + | |
1911 | +static void | |
1912 | +aarch64_linux_ltag_tests (void) | |
1913 | +{ | |
1914 | + /* We have 4 bits of tags, but we test writing all the bits of the top | |
1915 | + byte of address. */ | |
1916 | + for (int i = 0; i < 1 << 8; i++) | |
1917 | + { | |
1918 | + CORE_ADDR addr = ((CORE_ADDR) i << 56) | 0xdeadbeef; | |
1919 | + SELF_CHECK (aarch64_linux_get_ltag (addr) == (i & 0xf)); | |
1920 | + | |
1921 | + addr = aarch64_linux_set_ltag (0xdeadbeef, i); | |
1922 | + SELF_CHECK (addr = ((CORE_ADDR) (i & 0xf) << 56) | 0xdeadbeef); | |
1923 | + } | |
1924 | +} | |
1925 | + | |
1926 | +} // namespace selftests | |
1927 | +#endif /* GDB_SELF_TEST */ | |
1928 | + | |
1903 | 1929 | void _initialize_aarch64_linux_tdep (); |
1904 | 1930 | void |
1905 | 1931 | _initialize_aarch64_linux_tdep () |
1906 | 1932 | { |
1907 | 1933 | gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_LINUX, |
1908 | 1934 | aarch64_linux_init_abi); |
1935 | + | |
1936 | +#if GDB_SELF_TEST | |
1937 | + selftests::register_test ("aarch64-linux-tagged-address", | |
1938 | + selftests::aarch64_linux_ltag_tests); | |
1939 | +#endif | |
1909 | 1940 | } |