From 6d74da72dacdbbe2b87a6b931e0f7edc3d3463e3 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Tue, 16 Jun 2020 17:00:33 +0100 Subject: [PATCH] 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. --- gdb/ChangeLog | 5 +++++ gdb/riscv-tdep.c | 2 +- gdb/testsuite/ChangeLog | 4 ++++ gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp | 10 +++++++--- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f3ede9463f3..0a36c6bc48c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-06-25 Andrew Burgess + + * riscv-tdep.c (riscv_print_registers_info): Loop over all + registers, not just the known core set of registers. + 2020-06-25 Andrew Burgess * riscv-tdep.c (riscv_register_name): Return NULL for duplicate diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index cfc45d1a7f5..b86ba630540 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -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) diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 00903273f1a..8ad2448080a 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2020-06-25 Andrew Burgess + + * gdb.arch/riscv-tdesc-regs.exp: New test cases. + 2020-06-25 Andrew Burgess * gdb.arch/riscv-tdesc-regs.exp: Extend test case. diff --git a/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp b/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp index 9feddbad074..1be32e0e8a1 100644 --- a/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp +++ b/gdb/testsuite/gdb.arch/riscv-tdesc-regs.exp @@ -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 { -- 2.30.2