]>
Commit | Line | Data |
---|---|---|
1 | # Copyright 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. | |
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 | |
5 | # the Free Software Foundation; either version 3 of the License, or | |
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 | |
14 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
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 "" | |
27 | set regdir "" | |
28 | set architecture "" | |
29 | switch -glob -- [istarget] { | |
30 | "arm*-*-*" { | |
31 | set core-regs {arm-core.xml} | |
32 | } | |
33 | "*m68k-*-*" { | |
34 | set core-regs {m68k-core.xml} | |
35 | } | |
36 | "mips*-*-*" { | |
37 | set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml} | |
38 | } | |
39 | "powerpc*-*-*" { | |
40 | set regdir "rs6000/" | |
41 | set core-regs {power-core.xml} | |
42 | } | |
43 | "s390*-*-*" { | |
44 | set core-regs {s390-core32.xml s390-acr.xml s390-fpr.xml} | |
45 | } | |
46 | "spu*-*-*" { | |
47 | # This may be either the spu-linux-nat target, or the Cell/B.E. | |
48 | # multi-architecture debugger in SPU standalone executable mode. | |
49 | # We do not support XML register sets on SPU in either case. | |
50 | # However, the multi-arch debugger will accept XML registers sets | |
51 | # (on the PowerPC side), hence the test below would fail. | |
52 | # Simply return unconditionally here. | |
53 | unsupported "register tests" | |
54 | return 0 | |
55 | } | |
56 | "i?86-*-*" { | |
57 | set architecture "i386" | |
58 | set regdir "i386/" | |
59 | set core-regs {32bit-core.xml 32bit-sse.xml} | |
60 | } | |
61 | "x86_64-*-*" { | |
62 | set architecture "i386:x86-64" | |
63 | set regdir "i386/" | |
64 | set core-regs {64bit-core.xml 64bit-sse.xml} | |
65 | } | |
66 | } | |
67 | ||
68 | # If no core registers were specified, assume this target does not | |
69 | # support target-defined registers. Verify that we get a warning if | |
70 | # we try to use them. This not only tests the warning, but also | |
71 | # reminds maintainers to add test support when they add the feature. | |
72 | if {[string equal ${core-regs} ""]} { | |
73 | gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \ | |
74 | "warning: Target-supplied registers are not supported.*" \ | |
75 | "set tdesc file single-reg.xml" | |
76 | unsupported "register tests" | |
77 | return 0 | |
78 | } | |
79 | ||
80 | # Otherwise, we support both XML and target defined registers. | |
81 | ||
82 | # Make sure we reject a description missing standard registers, | |
83 | # like the PC. | |
84 | gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \ | |
85 | "warning: Architecture rejected target-supplied description" \ | |
86 | "set tdesc file single-reg.xml" | |
87 | ||
88 | # Copy the core registers into the objdir if necessary, so that they | |
89 | # will be found by <xi:include>. | |
90 | foreach src ${core-regs} { | |
91 | set file [remote_download host "$srcdir/../features/$regdir$src" "$src"] | |
92 | } | |
93 | ||
94 | # Similarly, we need to copy files under test into the objdir. | |
95 | proc load_description { file errmsg } { | |
96 | global srcdir | |
97 | global subdir | |
98 | global gdb_prompt | |
99 | global core-regs | |
100 | global architecture | |
101 | ||
102 | file delete "$subdir/regs.xml" | |
103 | set ifd [open "$srcdir/$subdir/$file" r] | |
104 | set ofd [open "$subdir/regs.xml" w] | |
105 | while {[gets $ifd line] >= 0} { | |
106 | if {[regexp {<xi:include href="core-regs.xml"/>} $line]} { | |
107 | if {! [string equal ${architecture} ""]} { | |
108 | puts $ofd " <architecture>${architecture}</architecture>" | |
109 | } | |
110 | foreach src ${core-regs} { | |
111 | puts $ofd " <xi:include href=\"$src\"/>" | |
112 | } | |
113 | } else { | |
114 | puts $ofd $line | |
115 | } | |
116 | } | |
117 | close $ifd | |
118 | close $ofd | |
119 | remote_download host "$subdir/regs.xml" "regs.xml" | |
120 | file delete "$subdir/regs.xml" | |
121 | ||
122 | # Anchor the test output, so that error messages are detected. | |
123 | set cmd "set tdesc filename regs.xml" | |
124 | set msg "set tdesc filename regs.xml - from $file" | |
125 | set cmd_regex [string_to_regexp $cmd] | |
126 | gdb_test_multiple $cmd $msg { | |
127 | -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" { | |
128 | pass $msg | |
129 | } | |
130 | } | |
131 | remote_file host delete "regs.xml" | |
132 | } | |
133 | ||
134 | load_description "extra-regs.xml" "" | |
135 | gdb_test "ptype \$extrareg" "type = (int|long|long long)" | |
136 | gdb_test "ptype \$uintreg" "type = uint32_t" | |
137 | gdb_test "ptype \$vecreg" "type = int8_t \\\[4\\\]" | |
138 | gdb_test "ptype \$unionreg" \ | |
139 | "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" | |
140 | gdb_test "ptype \$unionreg.v4" "type = int8_t \\\[4\\\]" | |
141 | gdb_test "ptype \$structreg" \ | |
142 | "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" | |
143 | gdb_test "ptype \$structreg.v4" "type = int8_t \\\[4\\\]" | |
144 | gdb_test "ptype \$bitfields" \ | |
145 | "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}" | |
146 | ||
147 | load_description "core-only.xml" "" | |
148 | # The extra register from the previous description should be gone. | |
149 | gdb_test "ptype \$extrareg" "type = void" | |
150 | ||
151 | foreach src ${core-regs} { | |
152 | remote_file host delete "$src" | |
153 | } |