* features/rs6000/powerpc-32.c, features/rs6000/powerpc-403.c,
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.xml / tdesc-regs.exp
CommitLineData
123dc839
DJ
1# Copyright 2007 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
e22f8b7c 5# the Free Software Foundation; either version 3 of the License, or
123dc839
DJ
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
e22f8b7c 14# along with this program. If not, see <http://www.gnu.org/licenses/>.
123dc839
DJ
15
16if {[gdb_skip_xml_test]} {
17 unsupported "tdesc-regs.exp"
18 return -1
19}
20
21gdb_start
22
23# To test adding registers, we need a core set of registers for this
24# architecture, or the description will be rejected.
25
26set core-regs ""
27switch -glob -- [istarget] {
28 "*arm-*-*" {
f8b73d13 29 set core-regs {arm-core.xml}
123dc839
DJ
30 }
31 "xscale-*-*" {
f8b73d13
DJ
32 set core-regs {arm-core.xml}
33 }
34 "mips*-*-*" {
35 set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml}
123dc839
DJ
36 }
37}
38
39# If no core registers were specified, assume this target does not
40# support target-defined registers. Verify that we get a warning if
41# we try to use them. This not only tests the warning, but also
42# reminds maintainers to add test support when they add the feature.
43if {[string equal ${core-regs} ""]} {
44 gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \
45 "warning: Target-supplied registers are not supported.*" \
46 "set tdesc file single-reg.xml"
47 unsupported "register tests"
48 return 0
49}
50
51# Otherwise, we support both XML and target defined registers.
52
53# Make sure we reject a description missing standard registers,
54# like the PC.
55gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \
56 "warning: Architecture rejected target-supplied description" \
57 "set tdesc file single-reg.xml"
58
59# Copy the core registers into the objdir if necessary, so that they
60# will be found by <xi:include>.
f8b73d13
DJ
61foreach src ${core-regs} {
62 file delete "$src"
63 file copy "$srcdir/../features/$src" "$src"
64}
123dc839
DJ
65
66# Similarly, we need to copy files under test into the objdir.
67proc load_description { file errmsg } {
68 global srcdir
69 global subdir
70 global gdb_prompt
f8b73d13 71 global core-regs
123dc839
DJ
72
73 file delete "regs.xml"
f8b73d13
DJ
74 set ifd [open "$srcdir/$subdir/$file" r]
75 set ofd [open "regs.xml" w]
76 while {[gets $ifd line] >= 0} {
77 if {[regexp {<xi:include href="core-regs.xml"/>} $line]} {
78 foreach src ${core-regs} {
79 puts $ofd " <xi:include href=\"$src\"/>"
80 }
81 } else {
82 puts $ofd $line
83 }
84 }
85 close $ifd
86 close $ofd
123dc839
DJ
87
88 # Anchor the test output, so that error messages are detected.
89 set cmd "set tdesc filename regs.xml"
90 set msg "set tdesc filename $file"
91 set cmd_regex [string_to_regexp $cmd]
92 gdb_test_multiple $cmd $msg {
93 -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" {
94 pass $msg
95 }
96 }
97}
98
99load_description "extra-regs.xml" ""
100gdb_test "ptype \$extrareg" "type = (int|long|long long)"
101gdb_test "ptype \$uintreg" "type = uint32_t"
102gdb_test "ptype \$vecreg" "type = int8_t \\\[4\\\]"
103gdb_test "ptype \$unionreg" \
104 "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
105gdb_test "ptype \$unionreg.v4" "type = int8_t \\\[4\\\]"
106
107load_description "core-only.xml" ""
108# The extra register from the previous description should be gone.
109gdb_test "ptype \$extrareg" "type = void"
110
f8b73d13
DJ
111foreach src ${core-regs} {
112 file delete "$src"
113}
123dc839 114file delete "regs.xml"
This page took 0.116391 seconds and 4 git commands to generate.