| # Copyright 2021 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/>. |
| |
| # Check the size of the $pc register as the user changes the selected |
| # architecture. As no executable is provided then the size of the $pc |
| # register is defined by the default target description selected by |
| # GDB. |
| # |
| # This test ensures that GDB is selecting an RV32 default if the user |
| # has forced the current architecture to be riscv:rv32. |
| # |
| # In all other cases the default will be RV64. |
| |
| if {![istarget "riscv*-*-*"]} { |
| verbose "Skipping ${gdb_test_file_name}." |
| return |
| } |
| |
| # Start GDB with no executable. |
| gdb_start |
| |
| # The tests are defined by a list of architecture names to switch too |
| # and the expected size of $pc. The first list entry is special and |
| # has an empty architecture string, this checks GDB's default value on |
| # startup. |
| foreach data {{"" 8} {"riscv:rv32" 4} {"riscv:rv64" 8} {"riscv" 8} \ |
| {"auto" 8}} { |
| set arch [lindex $data 0] |
| set size [lindex $data 1] |
| |
| # Switch architecture. |
| if { $arch != "" && $arch != "auto" } { |
| gdb_test "set architecture $arch" \ |
| "The target architecture is set to \"$arch\"\\." |
| } elseif { $arch == "auto" } { |
| gdb_test "set architecture $arch" \ |
| "The target architecture is set to \"auto\" \\(currently \"riscv\"\\)\\." |
| } else { |
| set arch "default architecture" |
| } |
| |
| # Check the size of $pc. |
| with_test_prefix "$arch" { |
| gdb_test "p sizeof (\$pc)" " = $size" \ |
| "size of \$pc register is $size" |
| } |
| } |