mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
6d74da72da
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.
124 lines
3.6 KiB
Plaintext
124 lines
3.6 KiB
Plaintext
# Copyright 2020 Free Software Foundation, Inc.
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
# Various tests to check which register names are available after
|
|
# loading a new target description file, and which registers show up
|
|
# in the output of the 'info registers' command.
|
|
|
|
if {![istarget "riscv*-*-*"]} {
|
|
verbose "Skipping ${gdb_test_file_name}."
|
|
return
|
|
}
|
|
|
|
standard_testfile
|
|
|
|
if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
|
|
{debug quiet}] } {
|
|
unsupported "failed to compile"
|
|
return -1
|
|
}
|
|
|
|
if { ![runto_main] } {
|
|
untested "failed to runto main"
|
|
return -1
|
|
}
|
|
|
|
# First, figure out if we are 32-bit or 64-bit.
|
|
set xlen [get_valueof "/d" "sizeof (\$a0)" 0]
|
|
set flen [get_valueof "/d" "sizeof (\$fa0)" 0]
|
|
|
|
gdb_assert { $xlen != 0 && $flen != 0 } "read xlen and flen"
|
|
|
|
# We only handle 32-bit or 64-bit x-registers.
|
|
if { $xlen != 4 && $xlen != 8 } {
|
|
unsupported "unknown x-register size"
|
|
return -1
|
|
}
|
|
|
|
# If FLEN is 1 then the target doesn't have floating point support
|
|
# (the register $fa0 was not recognised). Otherwise, we can only
|
|
# proceed if FLEN equals XLEN, otherwise we'd need more test XML
|
|
# files.
|
|
if { $flen != 1 && $flen != $xlen } {
|
|
unsupport "unknown xlen/flen combination"
|
|
return -1
|
|
}
|
|
|
|
if { $xlen == 4 } {
|
|
set xml_tdesc "riscv-tdesc-regs-32.xml"
|
|
} else {
|
|
set xml_tdesc "riscv-tdesc-regs-64.xml"
|
|
}
|
|
set xml_tdesc "${srcdir}/${subdir}/${xml_tdesc}"
|
|
|
|
# Maybe copy the target over if we're remote testing.
|
|
if {[is_remote host]} {
|
|
set remote_file [remote_download host $xml_tdesc]
|
|
} else {
|
|
set remote_file $xml_tdesc
|
|
}
|
|
|
|
gdb_test_no_output "set tdesc filename $remote_file" \
|
|
"load the new target description"
|
|
|
|
# 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\]+.*"
|
|
|
|
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 {}
|
|
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"
|
|
exp_continue
|
|
}
|
|
-re "^(\[^ \t\]+)\[ \t\]+\[^\r\n\]+\r\n" {
|
|
set reg $expect_out(1,string)
|
|
incr reg_counts($reg)
|
|
exp_continue
|
|
}
|
|
-re "^$gdb_prompt $" {
|
|
# Done.
|
|
}
|
|
}
|
|
|
|
foreach reg {fflags frm fcsr unknown_csr dscratch} {
|
|
if { [info exists reg_counts($reg) ] } {
|
|
set count $reg_counts($reg)
|
|
} else {
|
|
set count 0
|
|
}
|
|
if {($reg == "unknown_csr" || $reg == "dscratch") \
|
|
&& $rgroup != "all" && $rgroup != "x_all"} {
|
|
gdb_assert {$count == 0} \
|
|
"register $reg not seen in reggroup $rgroup"
|
|
} else {
|
|
gdb_assert {$count == 1} \
|
|
"register $reg seen once in reggroup $rgroup"
|
|
}
|
|
}
|
|
array unset reg_counts
|
|
}
|