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