Commit | Line | Data |
---|---|---|
b811d2c2 | 1 | # Copyright 2007-2020 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 | } | |
ad0a504f AK |
33 | "arc*-*-*" { |
34 | set architecture "arc:ARCv2" | |
35 | set core-regs {arc-v2.xml} | |
36 | } | |
810cfdbb | 37 | "arm*-*-*" { |
1d0e042a | 38 | set regdir "arm/" |
f8b73d13 DJ |
39 | set core-regs {arm-core.xml} |
40 | } | |
276a961b MK |
41 | "*m68k-*-*" { |
42 | set core-regs {m68k-core.xml} | |
43 | } | |
f8b73d13 | 44 | "mips*-*-*" { |
1faeff08 | 45 | set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml mips-dsp.xml} |
123dc839 | 46 | } |
a28d8e50 YTL |
47 | "nds32*-*-*" { |
48 | set core-regs {nds32-core.xml} | |
49 | } | |
2dd6254d SL |
50 | "nios2-*-*" { |
51 | set core-regs {nios2-cpu.xml} | |
52 | } | |
fe49c6f5 SH |
53 | "or1k-*-*" { |
54 | set core-regs {or1k-core.xml} | |
55 | } | |
7cc46491 DJ |
56 | "powerpc*-*-*" { |
57 | set regdir "rs6000/" | |
58 | set core-regs {power-core.xml} | |
59 | } | |
7803799a UW |
60 | "s390*-*-*" { |
61 | set core-regs {s390-core32.xml s390-acr.xml s390-fpr.xml} | |
62 | } | |
3f7b46f2 IR |
63 | "sparc-*-*" { |
64 | set regdir "sparc/" | |
65 | set core-regs {sparc32-cpu.xml sparc32-fpu.xml sparc32-cp0.xml} | |
66 | } | |
67 | "sparc64-*-*" { | |
68 | set architecture "sparc:v9" | |
69 | set regdir "sparc/" | |
70 | set core-regs {sparc64-cpu.xml sparc64-fpu.xml sparc64-cp0.xml} | |
71 | } | |
d93f7b5c YQ |
72 | "tic6x-*-*" { |
73 | set core-regs {tic6x-core.xml} | |
74 | } | |
90884b2b L |
75 | "i?86-*-*" { |
76 | set architecture "i386" | |
77 | set regdir "i386/" | |
78 | set core-regs {32bit-core.xml 32bit-sse.xml} | |
79 | } | |
80 | "x86_64-*-*" { | |
81 | set architecture "i386:x86-64" | |
82 | set regdir "i386/" | |
83 | set core-regs {64bit-core.xml 64bit-sse.xml} | |
84 | } | |
123dc839 DJ |
85 | } |
86 | ||
87 | # If no core registers were specified, assume this target does not | |
88 | # support target-defined registers. Verify that we get a warning if | |
89 | # we try to use them. This not only tests the warning, but also | |
90 | # reminds maintainers to add test support when they add the feature. | |
b22089ab YQ |
91 | |
92 | set single_reg_xml [gdb_remote_download host \ | |
93 | "$srcdir/$subdir/single-reg.xml"] | |
94 | ||
123dc839 | 95 | if {[string equal ${core-regs} ""]} { |
b22089ab | 96 | gdb_test "set tdesc file $single_reg_xml" \ |
123dc839 DJ |
97 | "warning: Target-supplied registers are not supported.*" \ |
98 | "set tdesc file single-reg.xml" | |
99 | unsupported "register tests" | |
100 | return 0 | |
101 | } | |
102 | ||
103 | # Otherwise, we support both XML and target defined registers. | |
104 | ||
105 | # Make sure we reject a description missing standard registers, | |
106 | # like the PC. | |
b22089ab | 107 | gdb_test "set tdesc file $single_reg_xml" \ |
123dc839 DJ |
108 | "warning: Architecture rejected target-supplied description" \ |
109 | "set tdesc file single-reg.xml" | |
110 | ||
111 | # Copy the core registers into the objdir if necessary, so that they | |
112 | # will be found by <xi:include>. | |
f8b73d13 | 113 | foreach src ${core-regs} { |
cfb7b9a3 TT |
114 | set remote_filename($src) \ |
115 | [gdb_remote_download host "$srcdir/../features/$regdir$src"] | |
f8b73d13 | 116 | } |
123dc839 DJ |
117 | |
118 | # Similarly, we need to copy files under test into the objdir. | |
81516450 | 119 | proc load_description { file errmsg xml_file } { |
123dc839 DJ |
120 | global srcdir |
121 | global subdir | |
122 | global gdb_prompt | |
f8b73d13 | 123 | global core-regs |
90884b2b | 124 | global architecture |
cfb7b9a3 | 125 | global remote_filename |
123dc839 | 126 | |
81516450 | 127 | set regs_file [standard_output_file $xml_file] |
cfb7b9a3 TT |
128 | |
129 | file delete $regs_file | |
f8b73d13 | 130 | set ifd [open "$srcdir/$subdir/$file" r] |
cfb7b9a3 | 131 | set ofd [open $regs_file w] |
f8b73d13 DJ |
132 | while {[gets $ifd line] >= 0} { |
133 | if {[regexp {<xi:include href="core-regs.xml"/>} $line]} { | |
90884b2b L |
134 | if {! [string equal ${architecture} ""]} { |
135 | puts $ofd " <architecture>${architecture}</architecture>" | |
136 | } | |
f8b73d13 DJ |
137 | foreach src ${core-regs} { |
138 | puts $ofd " <xi:include href=\"$src\"/>" | |
139 | } | |
140 | } else { | |
141 | puts $ofd $line | |
142 | } | |
143 | } | |
144 | close $ifd | |
145 | close $ofd | |
cfb7b9a3 TT |
146 | |
147 | if {[is_remote host]} { | |
81516450 | 148 | set regs_file [remote_download host "$subdir/$xml_file" $xml_file] |
cfb7b9a3 | 149 | } |
123dc839 DJ |
150 | |
151 | # Anchor the test output, so that error messages are detected. | |
cfb7b9a3 | 152 | set cmd "set tdesc filename [file tail $regs_file]" |
81516450 | 153 | set msg "set tdesc filename $xml_file - from $file" |
123dc839 DJ |
154 | set cmd_regex [string_to_regexp $cmd] |
155 | gdb_test_multiple $cmd $msg { | |
156 | -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" { | |
157 | pass $msg | |
158 | } | |
159 | } | |
cfb7b9a3 TT |
160 | } |
161 | ||
162 | if {![is_remote host]} { | |
163 | gdb_test "cd [standard_output_file {}]" "Working directory .*" \ | |
164 | "cd to directory holding xml" | |
123dc839 DJ |
165 | } |
166 | ||
81516450 | 167 | load_description "extra-regs.xml" "" "test-extra-regs.xml" |
123dc839 DJ |
168 | gdb_test "ptype \$extrareg" "type = (int|long|long long)" |
169 | gdb_test "ptype \$uintreg" "type = uint32_t" | |
42056501 | 170 | gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" |
123dc839 | 171 | gdb_test "ptype \$unionreg" \ |
e86ca25f | 172 | "type = union vecint {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" |
42056501 | 173 | gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" |
f5dff777 DJ |
174 | gdb_test "ptype \$structreg" \ |
175 | "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" | |
42056501 | 176 | gdb_test "ptype \$structreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" |
f5dff777 DJ |
177 | gdb_test "ptype \$bitfields" \ |
178 | "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}" | |
81516450 | 179 | gdb_test "ptype \$flags" \ |
ee8da4b8 | 180 | "type = flag flags {\r\n *bool X @0;\r\n *uint32_t Y @2;\r\n}" |
81516450 | 181 | gdb_test "ptype \$mixed_flags" \ |
e86ca25f | 182 | "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 Z_values {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}" |
cef0f868 SH |
183 | # Reggroups should have at least general and the extra foo group |
184 | gdb_test "maintenance print reggroups" \ | |
185 | " Group\[ \t\]+Type\[ \t\]+\r\n.* general\[ \t\]+user\[ \t\]+\r\n.* foo\[ \t\]+user\[ \t\]+" | |
123dc839 | 186 | |
c9f3b40e TV |
187 | with_test_prefix "core-only.xml" { |
188 | load_description "core-only.xml" "" "test-regs.xml" | |
189 | # The extra register from the previous description should be gone. | |
190 | gdb_test "ptype \$extrareg" "type = void" | |
191 | } |