]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.dwarf2/typeddwarf.exp
Update years in copyright notice for the GDB files.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.dwarf2 / typeddwarf.exp
CommitLineData
8acc9f48 1# Copyright 2011-2013 Free Software Foundation, Inc.
8a9b8146
TT
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
16load_lib dwarf.exp
17
18set test "typeddwarf"
19
20# This test can only be run on targets which support DWARF-2 and use gas.
21if ![dwarf2_support] {
22 return 0
23}
24
7f062217 25# This test can only be run on x86 and amd64 targets (and not x32).
3543a589
TT
26if { [is_x86_like_target] } {
27 set sfile ${test}.S
7f062217 28} elseif {[istarget "x86_64-*-*"] && [is_lp64_target]} {
3543a589
TT
29 set sfile ${test}-amd64.S
30} else {
8a9b8146
TT
31 return 0
32}
33
3543a589 34if { [prepare_for_testing "${test}.exp" "${test}" ${sfile} {nodebug additional_flags=-nostdlib}] } {
8a9b8146
TT
35 return -1
36}
37
38if ![runto_main] {
39 return -1
40}
41
24ece742
DE
42# Initialize tests to be an empty array.
43unset -nocomplain tests
44array set tests {}
8a9b8146
TT
45
46proc gdb-test {line var value} {
47 global tests
48
49 lappend tests($line) [list $var $value 0]
50}
51
3543a589
TT
52# Add an XFAIL'd test. If ARCH_PATTERN is given, and does not match
53# the target, then the test is simply added and not XFAIL'd.
54proc xfail-gdb-test {line var value {arch_pattern ""}} {
8a9b8146
TT
55 global tests
56
3543a589
TT
57 set flag 1
58 if {$arch_pattern != ""} {
59 if {! [istarget $arch_pattern]} {
60 set flag 0
61 }
62 }
63
64 lappend tests($line) [list $var $value $flag]
8a9b8146
TT
65}
66
67proc scan_gdb_tests {} {
68 global srcdir subdir test
69
70 set file "$srcdir/$subdir/$test.c"
71
72 set fd [open "$file"]
73 while {![eof $fd]} {
74 set line [gets $fd]
75 if {! [regexp "\{ (gdb-test .+) \} \}" $line ignore test_cmd]} {
76 continue
77 }
78
79 eval $test_cmd
80 }
81 close $fd
82}
83
84scan_gdb_tests
85
86foreach line [lsort [array names tests]] {
87 gdb_test "break typeddwarf.c:$line" "Breakpoint .*" \
88 "set breakpoint at typeddwarf.c:$line"
89 gdb_continue_to_breakpoint "continue to typeddwarf.c:$line"
90
91 foreach test $tests($line) {
92 set var [lindex $test 0]
93 set value [lindex $test 1]
94 set should_xfail [lindex $test 2]
95
96 if {$should_xfail} {
97 setup_xfail *-*-*
98 }
99
100 gdb_test "print $var" \
101 " = $value" \
102 "check value of $var at typeddwarf.c:$line"
103 }
104}