Commit | Line | Data |
---|---|---|
123dc839 DJ |
1 | # Copyright 2007 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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | if {[gdb_skip_xml_test]} { | |
18 | unsupported "tdesc-regs.exp" | |
19 | return -1 | |
20 | } | |
21 | ||
22 | gdb_start | |
23 | ||
24 | # To test adding registers, we need a core set of registers for this | |
25 | # architecture, or the description will be rejected. | |
26 | ||
27 | set core-regs "" | |
28 | switch -glob -- [istarget] { | |
29 | "*arm-*-*" { | |
f8b73d13 | 30 | set core-regs {arm-core.xml} |
123dc839 DJ |
31 | } |
32 | "xscale-*-*" { | |
f8b73d13 DJ |
33 | set core-regs {arm-core.xml} |
34 | } | |
35 | "mips*-*-*" { | |
36 | set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml} | |
123dc839 DJ |
37 | } |
38 | } | |
39 | ||
40 | # If no core registers were specified, assume this target does not | |
41 | # support target-defined registers. Verify that we get a warning if | |
42 | # we try to use them. This not only tests the warning, but also | |
43 | # reminds maintainers to add test support when they add the feature. | |
44 | if {[string equal ${core-regs} ""]} { | |
45 | gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \ | |
46 | "warning: Target-supplied registers are not supported.*" \ | |
47 | "set tdesc file single-reg.xml" | |
48 | unsupported "register tests" | |
49 | return 0 | |
50 | } | |
51 | ||
52 | # Otherwise, we support both XML and target defined registers. | |
53 | ||
54 | # Make sure we reject a description missing standard registers, | |
55 | # like the PC. | |
56 | gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \ | |
57 | "warning: Architecture rejected target-supplied description" \ | |
58 | "set tdesc file single-reg.xml" | |
59 | ||
60 | # Copy the core registers into the objdir if necessary, so that they | |
61 | # will be found by <xi:include>. | |
f8b73d13 DJ |
62 | foreach src ${core-regs} { |
63 | file delete "$src" | |
64 | file copy "$srcdir/../features/$src" "$src" | |
65 | } | |
123dc839 DJ |
66 | |
67 | # Similarly, we need to copy files under test into the objdir. | |
68 | proc load_description { file errmsg } { | |
69 | global srcdir | |
70 | global subdir | |
71 | global gdb_prompt | |
f8b73d13 | 72 | global core-regs |
123dc839 DJ |
73 | |
74 | file delete "regs.xml" | |
f8b73d13 DJ |
75 | set ifd [open "$srcdir/$subdir/$file" r] |
76 | set ofd [open "regs.xml" w] | |
77 | while {[gets $ifd line] >= 0} { | |
78 | if {[regexp {<xi:include href="core-regs.xml"/>} $line]} { | |
79 | foreach src ${core-regs} { | |
80 | puts $ofd " <xi:include href=\"$src\"/>" | |
81 | } | |
82 | } else { | |
83 | puts $ofd $line | |
84 | } | |
85 | } | |
86 | close $ifd | |
87 | close $ofd | |
123dc839 DJ |
88 | |
89 | # Anchor the test output, so that error messages are detected. | |
90 | set cmd "set tdesc filename regs.xml" | |
91 | set msg "set tdesc filename $file" | |
92 | set cmd_regex [string_to_regexp $cmd] | |
93 | gdb_test_multiple $cmd $msg { | |
94 | -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" { | |
95 | pass $msg | |
96 | } | |
97 | } | |
98 | } | |
99 | ||
100 | load_description "extra-regs.xml" "" | |
101 | gdb_test "ptype \$extrareg" "type = (int|long|long long)" | |
102 | gdb_test "ptype \$uintreg" "type = uint32_t" | |
103 | gdb_test "ptype \$vecreg" "type = int8_t \\\[4\\\]" | |
104 | gdb_test "ptype \$unionreg" \ | |
105 | "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}" | |
106 | gdb_test "ptype \$unionreg.v4" "type = int8_t \\\[4\\\]" | |
107 | ||
108 | load_description "core-only.xml" "" | |
109 | # The extra register from the previous description should be gone. | |
110 | gdb_test "ptype \$extrareg" "type = void" | |
111 | ||
f8b73d13 DJ |
112 | foreach src ${core-regs} { |
113 | file delete "$src" | |
114 | } | |
123dc839 | 115 | file delete "regs.xml" |