gdb/riscv: Loop over all registers for 'info all-registers'

Currently the 'info all-registers' command only loops over those
registers that are known to GDB.  Any registers that are unknown, that
is, are mentioned in the target description, but are not something GDB
otherwise knows, will not be displayed.

This feels wrong, so this commit fixes this mistake.  The output of
'info all-registers' now matches 'info registers all'.

gdb/ChangeLog:

	* riscv-tdep.c (riscv_print_registers_info): Loop over all
	registers, not just the known core set of registers.

gdb/testsuite/ChangeLog:

	* gdb.arch/riscv-tdesc-regs.exp: New test cases.
This commit is contained in:
Andrew Burgess 2020-06-16 17:00:33 +01:00
parent 2e52d03824
commit 6d74da72da
4 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,8 @@
2020-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
* riscv-tdep.c (riscv_print_registers_info): Loop over all
registers, not just the known core set of registers.
2020-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
* riscv-tdep.c (riscv_register_name): Return NULL for duplicate

View File

@ -1071,7 +1071,7 @@ riscv_print_registers_info (struct gdbarch *gdbarch,
else
reggroup = general_reggroup;
for (regnum = 0; regnum <= RISCV_LAST_REGNUM; ++regnum)
for (regnum = 0; regnum < gdbarch_num_cooked_regs (gdbarch); ++regnum)
{
/* Zero never changes, so might as well hide by default. */
if (regnum == RISCV_ZERO_REGNUM && !print_all)

View File

@ -1,3 +1,7 @@
2020-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.arch/riscv-tdesc-regs.exp: New test cases.
2020-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
* gdb.arch/riscv-tdesc-regs.exp: Extend test case.

View File

@ -80,11 +80,15 @@ gdb_test "info registers \$csr0" "Invalid register `csr0'"
gdb_test "info registers \$dscratch0" "dscratch0\[ \t\]+.*"
gdb_test "info registers \$dscratch" "dscratch\[ \t\]+.*"
foreach rgroup {all save restore} {
foreach rgroup {x_all all save restore} {
# Now use 'info registers all' to see how many times the floating
# point status registers show up in the output.
array set reg_counts {}
set test "info registers $rgroup"
if {$rgroup == "x_all"} {
set test "info all-registers"
} else {
set test "info registers $rgroup"
}
gdb_test_multiple $test $test {
-re ".*info registers all\r\n" {
verbose -log "Skip to first register"
@ -107,7 +111,7 @@ foreach rgroup {all save restore} {
set count 0
}
if {($reg == "unknown_csr" || $reg == "dscratch") \
&& $rgroup != "all"} {
&& $rgroup != "all" && $rgroup != "x_all"} {
gdb_assert {$count == 0} \
"register $reg not seen in reggroup $rgroup"
} else {