Fix build failure in inf-ptrace.c.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.xml / tdesc-regs.exp
CommitLineData
0fb0cc75 1# Copyright 2007, 2008, 2009 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
16if {[gdb_skip_xml_test]} {
17 unsupported "tdesc-regs.exp"
18 return -1
19}
20
21gdb_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
26set core-regs ""
7cc46491 27set regdir ""
123dc839
DJ
28switch -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 }
276a961b
MK
35 "*m68k-*-*" {
36 set core-regs {m68k-core.xml}
37 }
f8b73d13
DJ
38 "mips*-*-*" {
39 set core-regs {mips-cpu.xml mips-cp0.xml mips-fpu.xml}
123dc839 40 }
7cc46491
DJ
41 "powerpc*-*-*" {
42 set regdir "rs6000/"
43 set core-regs {power-core.xml}
44 }
85e747d2
UW
45 "spu*-*-*" {
46 # This may be either the spu-linux-nat target, or the Cell/B.E.
47 # multi-architecture debugger in SPU standalone executable mode.
48 # We do not support XML register sets on SPU in either case.
49 # However, the multi-arch debugger will accept XML registers sets
50 # (on the PowerPC side), hence the test below would fail.
51 # Simply return unconditionally here.
52 unsupported "register tests"
53 return 0
54 }
123dc839
DJ
55}
56
57# If no core registers were specified, assume this target does not
58# support target-defined registers. Verify that we get a warning if
59# we try to use them. This not only tests the warning, but also
60# reminds maintainers to add test support when they add the feature.
61if {[string equal ${core-regs} ""]} {
62 gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \
63 "warning: Target-supplied registers are not supported.*" \
64 "set tdesc file single-reg.xml"
65 unsupported "register tests"
66 return 0
67}
68
69# Otherwise, we support both XML and target defined registers.
70
71# Make sure we reject a description missing standard registers,
72# like the PC.
73gdb_test "set tdesc file $srcdir/$subdir/single-reg.xml" \
74 "warning: Architecture rejected target-supplied description" \
75 "set tdesc file single-reg.xml"
76
77# Copy the core registers into the objdir if necessary, so that they
78# will be found by <xi:include>.
f8b73d13
DJ
79foreach src ${core-regs} {
80 file delete "$src"
7cc46491 81 file copy "$srcdir/../features/$regdir$src" "$src"
f8b73d13 82}
123dc839
DJ
83
84# Similarly, we need to copy files under test into the objdir.
85proc load_description { file errmsg } {
86 global srcdir
87 global subdir
88 global gdb_prompt
f8b73d13 89 global core-regs
123dc839
DJ
90
91 file delete "regs.xml"
f8b73d13
DJ
92 set ifd [open "$srcdir/$subdir/$file" r]
93 set ofd [open "regs.xml" w]
94 while {[gets $ifd line] >= 0} {
95 if {[regexp {<xi:include href="core-regs.xml"/>} $line]} {
96 foreach src ${core-regs} {
97 puts $ofd " <xi:include href=\"$src\"/>"
98 }
99 } else {
100 puts $ofd $line
101 }
102 }
103 close $ifd
104 close $ofd
123dc839
DJ
105
106 # Anchor the test output, so that error messages are detected.
107 set cmd "set tdesc filename regs.xml"
108 set msg "set tdesc filename $file"
109 set cmd_regex [string_to_regexp $cmd]
110 gdb_test_multiple $cmd $msg {
111 -re "^$cmd_regex\r\n$errmsg$gdb_prompt $" {
112 pass $msg
113 }
114 }
115}
116
117load_description "extra-regs.xml" ""
118gdb_test "ptype \$extrareg" "type = (int|long|long long)"
119gdb_test "ptype \$uintreg" "type = uint32_t"
120gdb_test "ptype \$vecreg" "type = int8_t \\\[4\\\]"
121gdb_test "ptype \$unionreg" \
122 "type = union {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
123gdb_test "ptype \$unionreg.v4" "type = int8_t \\\[4\\\]"
124
125load_description "core-only.xml" ""
126# The extra register from the previous description should be gone.
127gdb_test "ptype \$extrareg" "type = void"
128
f8b73d13
DJ
129foreach src ${core-regs} {
130 file delete "$src"
131}
123dc839 132file delete "regs.xml"
This page took 0.301395 seconds and 4 git commands to generate.