1 # Copyright 2007-2014 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.
29 switch -glob -- [istarget] {
31 set core-regs {arm-core.xml}
34 set core-regs {m68k-core.xml}
37 set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml mips-dsp.xml}
40 set core-regs {nios2-cpu.xml}
44 set core-regs {power-core.xml}
47 set core-regs {s390-core32.xml s390-acr.xml s390-fpr.xml}
50 # This may be either the spu-linux-nat target, or the Cell/B.E.
51 # multi-architecture debugger in SPU standalone executable mode.
52 # We do not support XML register sets on SPU in either case.
53 # However, the multi-arch debugger will accept XML registers sets
54 # (on the PowerPC side), hence the test below would fail.
55 # Simply return unconditionally here.
56 unsupported "register tests"
60 set core-regs {tic6x-core.xml}
63 set architecture "i386"
65 set core-regs {32bit-core.xml 32bit-sse.xml}
68 set architecture "i386:x86-64"
70 set core-regs {64bit-core.xml 64bit-sse.xml}
74 # If no core registers were specified, assume this target does not
75 # support target-defined registers. Verify that we get a warning if
76 # we try to use them. This not only tests the warning, but also
77 # reminds maintainers to add test support when they add the feature.
79 set single_reg_xml [gdb_remote_download host \
80 "$srcdir/$subdir/single-reg.xml"]
82 if {[string equal ${core-regs} ""]} {
83 gdb_test "set tdesc file $single_reg_xml" \
84 "warning: Target-supplied registers are not supported.*" \
85 "set tdesc file single-reg.xml"
86 unsupported "register tests"
90 # Otherwise, we support both XML and target defined registers.
92 # Make sure we reject a description missing standard registers,
94 gdb_test "set tdesc file $single_reg_xml" \
95 "warning: Architecture rejected target-supplied description" \
96 "set tdesc file single-reg.xml"
98 # Copy the core registers into the objdir if necessary, so that they
99 # will be found by <xi:include>.
100 foreach src ${core-regs} {
101 set remote_filename($src) \
102 [gdb_remote_download host "$srcdir/../features/$regdir$src"]
105 # Similarly, we need to copy files under test into the objdir.
106 proc load_description { file errmsg } {
112 global remote_filename
114 set regs_file [standard_output_file regs.xml]
116 file delete $regs_file
117 set ifd [open "$srcdir/$subdir/$file" r]
118 set ofd [open $regs_file w]
119 while {[gets $ifd line] >= 0} {
120 if {[regexp {<xi:include href="core-regs.xml"/>} $line]} {
121 if {! [string equal ${architecture} ""]} {
122 puts $ofd " <architecture>${architecture}</architecture>"
124 foreach src ${core-regs} {
125 puts $ofd " <xi:include href=\"$src\"/>"
134 if {[is_remote host]} {
135 set regs_file [remote_download host "$subdir/regs.xml" "regs.xml"]
138 # Anchor the test output, so that error messages are detected.
139 set cmd "set tdesc filename [file tail $regs_file]"
140 set msg "set tdesc filename regs.xml - from $file"
141 set cmd_regex [string_to_regexp $cmd]
142 gdb_test_multiple $cmd $msg {
143 -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" {
148 if {[is_remote host]} {
149 remote_file host delete "regs.xml"
153 if {![is_remote host]} {
154 gdb_test "cd [standard_output_file {}]" "Working directory .*" \
155 "cd to directory holding xml"
158 load_description "extra-regs.xml" ""
159 gdb_test "ptype \$extrareg" "type = (int|long|long long)"
160 gdb_test "ptype \$uintreg" "type = uint32_t"
161 gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
162 gdb_test "ptype \$unionreg" \
163 "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
164 gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
165 gdb_test "ptype \$structreg" \
166 "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
167 gdb_test "ptype \$structreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
168 gdb_test "ptype \$bitfields" \
169 "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}"
171 load_description "core-only.xml" ""
172 # The extra register from the previous description should be gone.
173 gdb_test "ptype \$extrareg" "type = void"
175 foreach src ${core-regs} {
176 remote_file host delete $remote_filename($src)