1 # Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
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
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
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.
13 # You should have received a copy of the GNU General Public License
14 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 if {[gdb_skip_xml_test]} {
17 unsupported "tdesc-regs.exp"
23 # To test adding registers, we need a core set of registers for this
24 # architecture, or the description will be rejected.
28 switch -glob -- [istarget] {
30 set core-regs {arm-core.xml}
33 set core-regs {arm-core.xml}
36 set core-regs {m68k-core.xml}
39 set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml}
43 set core-regs {power-core.xml}
46 set core-regs {s390-core32.xml s390-acr.xml s390-fpr.xml}
49 # This may be either the spu-linux-nat target, or the Cell/B.E.
50 # multi-architecture debugger in SPU standalone executable mode.
51 # We do not support XML register sets on SPU in either case.
52 # However, the multi-arch debugger will accept XML registers sets
53 # (on the PowerPC side), hence the test below would fail.
54 # Simply return unconditionally here.
55 unsupported "register tests"
60 # If no core registers were specified, assume this target does not
61 # support target-defined registers. Verify that we get a warning if
62 # we try to use them. This not only tests the warning, but also
63 # reminds maintainers to add test support when they add the feature.
64 if {[string equal ${core-regs} ""]} {
65 gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \
66 "warning: Target-supplied registers are not supported.*" \
67 "set tdesc file single-reg.xml"
68 unsupported "register tests"
72 # Otherwise, we support both XML and target defined registers.
74 # Make sure we reject a description missing standard registers,
76 gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \
77 "warning: Architecture rejected target-supplied description" \
78 "set tdesc file single-reg.xml"
80 # Copy the core registers into the objdir if necessary, so that they
81 # will be found by <xi:include>.
82 foreach src ${core-regs} {
84 file copy "$srcdir/../features/$regdir$src" "$src"
87 # Similarly, we need to copy files under test into the objdir.
88 proc load_description { file errmsg } {
94 file delete "regs.xml"
95 set ifd [open "$srcdir/$subdir/$file" r]
96 set ofd [open "regs.xml" w]
97 while {[gets $ifd line] >= 0} {
98 if {[regexp {<xi:include href="core-regs.xml"/>} $line]} {
99 foreach src ${core-regs} {
100 puts $ofd " <xi:include href=\"$src\"/>"
109 # Anchor the test output, so that error messages are detected.
110 set cmd "set tdesc filename regs.xml"
111 set msg "set tdesc filename $file"
112 set cmd_regex [string_to_regexp $cmd]
113 gdb_test_multiple $cmd $msg {
114 -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" {
120 load_description "extra-regs.xml" ""
121 gdb_test "ptype \$extrareg" "type = (int|long|long long)"
122 gdb_test "ptype \$uintreg" "type = uint32_t"
123 gdb_test "ptype \$vecreg" "type = int8_t \\\[4\\\]"
124 gdb_test "ptype \$unionreg" \
125 "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
126 gdb_test "ptype \$unionreg.v4" "type = int8_t \\\[4\\\]"
128 load_description "core-only.xml" ""
129 # The extra register from the previous description should be gone.
130 gdb_test "ptype \$extrareg" "type = void"
132 foreach src ${core-regs} {
135 file delete "regs.xml"