From: Andrew Burgess Date: Thu, 26 Nov 2020 11:42:03 +0000 (+0000) Subject: gdb/riscv: remove csr aliases created with DECLARE_CSR_ALIAS X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=533b2ae07d0437d0f9ae26f2067c1eab7999c5ba;p=binutils-gdb.git gdb/riscv: remove csr aliases created with DECLARE_CSR_ALIAS In this commit: commit 767a879e31ce31179e6135c2f991f670a35709fa Date: Tue Jun 9 17:38:30 2020 +0100 gdb/riscv: Improved register alias name creation RISC-V GDB was changed to make use of the DECLARE_CSR_ALIAS macro to define register aliases for some CSRs. Actually, only one alias was created 'dscratch' as an alias for 'dscratch0'. All of the other DECLARE_CSR_ALIAS lines (from include/opcode/riscv-opc.h) were filtered out. In this commit: commit 08ccfccf0ed825be9be2972594d4be4a2207ef13 Date: Mon Jun 8 10:54:53 2020 +0800 RISC-V: Support debug and float CSR as the unprivileged ones. Changes were made to include/opcode/riscv-opc.h so that GDB no longer created even the dscratch alias. This caused a test failure in gdb.arch/riscv-tdesc-regs.exp. In looking at how to address this failure I think that the best strategy is, for now at least, to just remove the code that tries to create aliases with DECLARE_CSR_ALIAS. My thoughts are that: 1. At least some of the aliases are for CSRs where the register now has a completely different use. Being able to reference the CSR using a completely inappropriate name just seems confusing. This was solved by the filtering added in the first commit referenced above. But we certainly don't want to blindly add all aliases. 2. Names presented in a target description are always honoured, so if a user has a legacy target then they should just start sending a target description with their legacy register names in, this problem is then solved. 3. It's easy enough to figure out which CSRs a target has with the info registers command, so missing an alias shouldn't be a big issue. 4. Allowing users to use names for registers that differ from the names the target announces doesn't feel like a critical feature. If in the future targets want multiple names for a register then maybe we could/should extend target descriptions to allow the target to send aliases as well as the primary name.... but that can wait for another day. So in this commit I remove the use of DECLARE_CSR_ALIAS, and remove the test that was failing. gdb/ChangeLog: * riscv-tdep.c (riscv_create_csr_aliases): Remove use of DECLARE_CSR_ALIAS. gdb/testsuite/ChangeLog: * gdb.arch/riscv-tdesc-regs.exp: Remove unwanted test. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1d5bbcfe696..fdda9131041 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-12-02 Andrew Burgess + + * riscv-tdep.c (riscv_create_csr_aliases): Remove use of + DECLARE_CSR_ALIAS. + 2020-12-02 Andrew Burgess * riscv-tdep.c (riscv_is_unknown_csr): New function, diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 437e8f847ae..2f182e8ba8c 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -376,16 +376,6 @@ riscv_create_csr_aliases () int csr_num = reg.regnum - RISCV_FIRST_CSR_REGNUM; const char *alias = xstrprintf ("csr%d", csr_num); reg.names.push_back (alias); - - /* Setup the other csr aliases. We don't use a switch table here in - case there are multiple aliases with the same value. Also filter - based on ABRT_VER in order to avoid a very old alias for misa that - duplicates the name "misa" but at a different CSR address. */ -#define DECLARE_CSR_ALIAS(NAME,VALUE,CLASS,DEF_VER,ABRT_VER) \ - if (csr_num == VALUE && ABRT_VER >= PRIV_SPEC_CLASS_1P11) \ - reg.names.push_back ( # NAME ); -#include "opcode/riscv-opc.h" -#undef DECLARE_CSR_ALIAS } } diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index f0938453932..c00bc612480 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-12-02 Andrew Burgess + + * gdb.arch/riscv-tdesc-regs.exp: Remove unwanted test. + 2020-12-02 Andrew Burgess * gdb.arch/riscv-tdesc-regs.exp (get_expected_result): New proc, diff --git a/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp b/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp index e35d6181b7f..6ee2bb7cb16 100644 --- a/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp +++ b/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp @@ -76,10 +76,6 @@ gdb_test_no_output "set tdesc filename $remote_file" \ # Check that an alias for an unknown CSR will give a suitable error. gdb_test "info registers \$csr0" "Invalid register `csr0'" -# Check we can access the dscratch register using either of its names. -gdb_test "info registers \$dscratch0" "dscratch0\[ \t\]+.*" -gdb_test "info registers \$dscratch" "dscratch\[ \t\]+.*" - # Return the number of times REGISTER should appear in GROUP, this # will either be 0 or 1. proc get_expected_result { register group } {