Commit | Line | Data |
---|---|---|
8acc9f48 | 1 | # Copyright 2007-2013 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] { |
810cfdbb | 30 | "arm*-*-*" { |
f8b73d13 DJ |
31 | set core-regs {arm-core.xml} |
32 | } | |
276a961b MK |
33 | "*m68k-*-*" { |
34 | set core-regs {m68k-core.xml} | |
35 | } | |
f8b73d13 | 36 | "mips*-*-*" { |
1faeff08 | 37 | set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml mips-dsp.xml} |
123dc839 | 38 | } |
2dd6254d SL |
39 | "nios2-*-*" { |
40 | set core-regs {nios2-cpu.xml} | |
41 | } | |
7cc46491 DJ |
42 | "powerpc*-*-*" { |
43 | set regdir "rs6000/" | |
44 | set core-regs {power-core.xml} | |
45 | } | |
7803799a UW |
46 | "s390*-*-*" { |
47 | set core-regs {s390-core32.xml s390-acr.xml s390-fpr.xml} | |
48 | } | |
85e747d2 UW |
49 | "spu*-*-*" { |
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" | |
57 | return 0 | |
58 | } | |
d93f7b5c YQ |
59 | "tic6x-*-*" { |
60 | set core-regs {tic6x-core.xml} | |
61 | } | |
90884b2b L |
62 | "i?86-*-*" { |
63 | set architecture "i386" | |
64 | set regdir "i386/" | |
65 | set core-regs {32bit-core.xml 32bit-sse.xml} | |
66 | } | |
67 | "x86_64-*-*" { | |
68 | set architecture "i386:x86-64" | |
69 | set regdir "i386/" | |
70 | set core-regs {64bit-core.xml 64bit-sse.xml} | |
71 | } | |
123dc839 DJ |
72 | } |
73 | ||
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. | |
78 | if {[string equal ${core-regs} ""]} { | |
79 | gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \ | |
80 | "warning: Target-supplied registers are not supported.*" \ | |
81 | "set tdesc file single-reg.xml" | |
82 | unsupported "register tests" | |
83 | return 0 | |
84 | } | |
85 | ||
86 | # Otherwise, we support both XML and target defined registers. | |
87 | ||
88 | # Make sure we reject a description missing standard registers, | |
89 | # like the PC. | |
90 | gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \ | |
91 | "warning: Architecture rejected target-supplied description" \ | |
92 | "set tdesc file single-reg.xml" | |
93 | ||
94 | # Copy the core registers into the objdir if necessary, so that they | |
95 | # will be found by <xi:include>. | |
f8b73d13 | 96 | foreach src ${core-regs} { |
d252f7e5 | 97 | set file [remote_download host "$srcdir/../features/$regdir$src" "$src"] |
f8b73d13 | 98 | } |
123dc839 DJ |
99 | |
100 | # Similarly, we need to copy files under test into the objdir. | |
101 | proc load_description { file errmsg } { | |
102 | global srcdir | |
103 | global subdir | |
104 | global gdb_prompt | |
f8b73d13 | 105 | global core-regs |
90884b2b | 106 | global architecture |
123dc839 | 107 | |
d252f7e5 | 108 | file delete "$subdir/regs.xml" |
f8b73d13 | 109 | set ifd [open "$srcdir/$subdir/$file" r] |
d252f7e5 | 110 | set ofd [open "$subdir/regs.xml" w] |
f8b73d13 DJ |
111 | while {[gets $ifd line] >= 0} { |
112 | if {[regexp {<xi:include href="core-regs.xml"/>} $line]} { | |
90884b2b L |
113 | if {! [string equal ${architecture} ""]} { |
114 | puts $ofd " <architecture>${architecture}</architecture>" | |
115 | } | |
f8b73d13 DJ |
116 | foreach src ${core-regs} { |
117 | puts $ofd " <xi:include href=\"$src\"/>" | |
118 | } | |
119 | } else { | |
120 | puts $ofd $line | |
121 | } | |
122 | } | |
123 | close $ifd | |
124 | close $ofd | |
d252f7e5 DJ |
125 | remote_download host "$subdir/regs.xml" "regs.xml" |
126 | file delete "$subdir/regs.xml" | |
123dc839 DJ |
127 | |
128 | # Anchor the test output, so that error messages are detected. | |
129 | set cmd "set tdesc filename regs.xml" | |
d252f7e5 | 130 | set msg "set tdesc filename regs.xml - from $file" |
123dc839 DJ |
131 | set cmd_regex [string_to_regexp $cmd] |
132 | gdb_test_multiple $cmd $msg { | |
133 | -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" { | |
134 | pass $msg | |
135 | } | |
136 | } | |
d252f7e5 | 137 | remote_file host delete "regs.xml" |
123dc839 DJ |
138 | } |
139 | ||
140 | load_description "extra-regs.xml" "" | |
141 | gdb_test "ptype \$extrareg" "type = (int|long|long long)" | |
142 | gdb_test "ptype \$uintreg" "type = uint32_t" | |
42056501 | 143 | gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" |
123dc839 DJ |
144 | gdb_test "ptype \$unionreg" \ |
145 | "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" | |
42056501 | 146 | gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" |
f5dff777 DJ |
147 | gdb_test "ptype \$structreg" \ |
148 | "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" | |
42056501 | 149 | gdb_test "ptype \$structreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)" |
f5dff777 DJ |
150 | gdb_test "ptype \$bitfields" \ |
151 | "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}" | |
123dc839 DJ |
152 | |
153 | load_description "core-only.xml" "" | |
154 | # The extra register from the previous description should be gone. | |
155 | gdb_test "ptype \$extrareg" "type = void" | |
156 | ||
f8b73d13 | 157 | foreach src ${core-regs} { |
d252f7e5 | 158 | remote_file host delete "$src" |
f8b73d13 | 159 | } |