Make "end" field in feature specs required again.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.xml / tdesc-regs.exp
CommitLineData
618f726f 1# Copyright 2007-2016 Free Software Foundation, Inc.
123dc839
DJ
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 ""
7cc46491 27set regdir ""
90884b2b 28set architecture ""
123dc839 29switch -glob -- [istarget] {
21613c12
YQ
30 "aarch64*-*-*" {
31 set core-regs {aarch64-core.xml}
32 }
ad0a504f
AK
33 "arc*-*-*" {
34 set architecture "arc:ARCv2"
35 set core-regs {arc-v2.xml}
36 }
810cfdbb 37 "arm*-*-*" {
f8b73d13
DJ
38 set core-regs {arm-core.xml}
39 }
276a961b
MK
40 "*m68k-*-*" {
41 set core-regs {m68k-core.xml}
42 }
f8b73d13 43 "mips*-*-*" {
1faeff08 44 set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml mips-dsp.xml}
123dc839 45 }
a28d8e50
YTL
46 "nds32*-*-*" {
47 set core-regs {nds32-core.xml}
48 }
2dd6254d
SL
49 "nios2-*-*" {
50 set core-regs {nios2-cpu.xml}
51 }
7cc46491
DJ
52 "powerpc*-*-*" {
53 set regdir "rs6000/"
54 set core-regs {power-core.xml}
55 }
7803799a
UW
56 "s390*-*-*" {
57 set core-regs {s390-core32.xml s390-acr.xml s390-fpr.xml}
58 }
85e747d2
UW
59 "spu*-*-*" {
60 # This may be either the spu-linux-nat target, or the Cell/B.E.
61 # multi-architecture debugger in SPU standalone executable mode.
62 # We do not support XML register sets on SPU in either case.
63 # However, the multi-arch debugger will accept XML registers sets
64 # (on the PowerPC side), hence the test below would fail.
65 # Simply return unconditionally here.
66 unsupported "register tests"
67 return 0
68 }
d93f7b5c
YQ
69 "tic6x-*-*" {
70 set core-regs {tic6x-core.xml}
71 }
90884b2b
L
72 "i?86-*-*" {
73 set architecture "i386"
74 set regdir "i386/"
75 set core-regs {32bit-core.xml 32bit-sse.xml}
76 }
77 "x86_64-*-*" {
78 set architecture "i386:x86-64"
79 set regdir "i386/"
80 set core-regs {64bit-core.xml 64bit-sse.xml}
81 }
123dc839
DJ
82}
83
84# If no core registers were specified, assume this target does not
85# support target-defined registers. Verify that we get a warning if
86# we try to use them. This not only tests the warning, but also
87# reminds maintainers to add test support when they add the feature.
b22089ab
YQ
88
89set single_reg_xml [gdb_remote_download host \
90 "$srcdir/$subdir/single-reg.xml"]
91
123dc839 92if {[string equal ${core-regs} ""]} {
b22089ab 93 gdb_test "set tdesc file $single_reg_xml" \
123dc839
DJ
94 "warning: Target-supplied registers are not supported.*" \
95 "set tdesc file single-reg.xml"
96 unsupported "register tests"
97 return 0
98}
99
100# Otherwise, we support both XML and target defined registers.
101
102# Make sure we reject a description missing standard registers,
103# like the PC.
b22089ab 104gdb_test "set tdesc file $single_reg_xml" \
123dc839
DJ
105 "warning: Architecture rejected target-supplied description" \
106 "set tdesc file single-reg.xml"
107
108# Copy the core registers into the objdir if necessary, so that they
109# will be found by <xi:include>.
f8b73d13 110foreach src ${core-regs} {
cfb7b9a3
TT
111 set remote_filename($src) \
112 [gdb_remote_download host "$srcdir/../features/$regdir$src"]
f8b73d13 113}
123dc839
DJ
114
115# Similarly, we need to copy files under test into the objdir.
81516450 116proc load_description { file errmsg xml_file } {
123dc839
DJ
117 global srcdir
118 global subdir
119 global gdb_prompt
f8b73d13 120 global core-regs
90884b2b 121 global architecture
cfb7b9a3 122 global remote_filename
123dc839 123
81516450 124 set regs_file [standard_output_file $xml_file]
cfb7b9a3
TT
125
126 file delete $regs_file
f8b73d13 127 set ifd [open "$srcdir/$subdir/$file" r]
cfb7b9a3 128 set ofd [open $regs_file w]
f8b73d13
DJ
129 while {[gets $ifd line] >= 0} {
130 if {[regexp {<xi:include href="core-regs.xml"/>} $line]} {
90884b2b
L
131 if {! [string equal ${architecture} ""]} {
132 puts $ofd " <architecture>${architecture}</architecture>"
133 }
f8b73d13
DJ
134 foreach src ${core-regs} {
135 puts $ofd " <xi:include href=\"$src\"/>"
136 }
137 } else {
138 puts $ofd $line
139 }
140 }
141 close $ifd
142 close $ofd
cfb7b9a3
TT
143
144 if {[is_remote host]} {
81516450 145 set regs_file [remote_download host "$subdir/$xml_file" $xml_file]
cfb7b9a3 146 }
123dc839
DJ
147
148 # Anchor the test output, so that error messages are detected.
cfb7b9a3 149 set cmd "set tdesc filename [file tail $regs_file]"
81516450 150 set msg "set tdesc filename $xml_file - from $file"
123dc839
DJ
151 set cmd_regex [string_to_regexp $cmd]
152 gdb_test_multiple $cmd $msg {
153 -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" {
154 pass $msg
155 }
156 }
cfb7b9a3
TT
157}
158
159if {![is_remote host]} {
160 gdb_test "cd [standard_output_file {}]" "Working directory .*" \
161 "cd to directory holding xml"
123dc839
DJ
162}
163
81516450 164load_description "extra-regs.xml" "" "test-extra-regs.xml"
123dc839
DJ
165gdb_test "ptype \$extrareg" "type = (int|long|long long)"
166gdb_test "ptype \$uintreg" "type = uint32_t"
42056501 167gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
123dc839
DJ
168gdb_test "ptype \$unionreg" \
169 "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
42056501 170gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
f5dff777
DJ
171gdb_test "ptype \$structreg" \
172 "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
42056501 173gdb_test "ptype \$structreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
f5dff777
DJ
174gdb_test "ptype \$bitfields" \
175 "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}"
81516450 176gdb_test "ptype \$flags" \
ee8da4b8 177 "type = flag flags {\r\n *bool X @0;\r\n *uint32_t Y @2;\r\n}"
81516450 178gdb_test "ptype \$mixed_flags" \
ee8da4b8 179 "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}"
123dc839 180
81516450 181load_description "core-only.xml" "" "test-regs.xml"
123dc839
DJ
182# The extra register from the previous description should be gone.
183gdb_test "ptype \$extrareg" "type = void"
This page took 1.156521 seconds and 4 git commands to generate.