summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.arch/riscv-default-tdesc.exp
blob: 1fd787243f86411088240eec784ee86b7defe6e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Copyright 2021-2022 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"
    }
}