GNU Binutils with patches for OS216
修訂 | 9e45a8561d934bc1ae07ff4356312afb69e0bd00 (tree) |
---|---|
時間 | 2020-06-16 21:58:32 |
作者 | Luis Machado <luis.machado@lina...> |
Commiter | Luis Machado |
Add unit testing for logical tag set/get
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.
@@ -52,6 +52,8 @@ | ||
52 | 52 | |
53 | 53 | #include "arch/aarch64-linux.h" |
54 | 54 | |
55 | +#include "gdbsupport/selftest.h" | |
56 | + | |
55 | 57 | /* Signal frame handling. |
56 | 58 | |
57 | 59 | +------------+ ^ |
@@ -1956,10 +1958,39 @@ aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) | ||
1956 | 1958 | set_gdbarch_gcc_target_options (gdbarch, aarch64_linux_gcc_target_options); |
1957 | 1959 | } |
1958 | 1960 | |
1961 | +#if GDB_SELF_TEST | |
1962 | + | |
1963 | +namespace selftests { | |
1964 | + | |
1965 | +/* Verify functions to read and write logical tags. */ | |
1966 | + | |
1967 | +static void | |
1968 | +aarch64_linux_ltag_tests (void) | |
1969 | +{ | |
1970 | + /* We have 4 bits of tags, but we test writing all the bits of the top | |
1971 | + byte of address. */ | |
1972 | + for (int i = 0; i < 1 << 8; i++) | |
1973 | + { | |
1974 | + CORE_ADDR addr = ((CORE_ADDR) i << 56) | 0xdeadbeef; | |
1975 | + SELF_CHECK (aarch64_linux_get_ltag (addr) == (i & 0xf)); | |
1976 | + | |
1977 | + addr = aarch64_linux_set_ltag (0xdeadbeef, i); | |
1978 | + SELF_CHECK (addr = ((CORE_ADDR) (i & 0xf) << 56) | 0xdeadbeef); | |
1979 | + } | |
1980 | +} | |
1981 | + | |
1982 | +} // namespace selftests | |
1983 | +#endif /* GDB_SELF_TEST */ | |
1984 | + | |
1959 | 1985 | void _initialize_aarch64_linux_tdep (); |
1960 | 1986 | void |
1961 | 1987 | _initialize_aarch64_linux_tdep () |
1962 | 1988 | { |
1963 | 1989 | gdbarch_register_osabi (bfd_arch_aarch64, 0, GDB_OSABI_LINUX, |
1964 | 1990 | aarch64_linux_init_abi); |
1991 | + | |
1992 | +#if GDB_SELF_TEST | |
1993 | + selftests::register_test ("aarch64-linux-tagged-address", | |
1994 | + selftests::aarch64_linux_ltag_tests); | |
1995 | +#endif | |
1965 | 1996 | } |