Automatic date update in version.in
[binutils-gdb/blckswan.git] / gdb / testsuite / gdb.dwarf2 / typeddwarf.exp
blob5abd575bc5bc948a989d5663e7b56c054734b8bd
1 # Copyright 2011-2022 Free Software Foundation, Inc.
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.
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.
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/>.
16 load_lib dwarf.exp
18 set test "typeddwarf"
20 # This test can only be run on targets which support DWARF-2 and use gas.
21 if ![dwarf2_support] {
22 return 0
25 # This test can only be run on x86 and amd64 targets (and not x32).
26 if { [is_x86_like_target] } {
27 set sfile ${test}.S
28 } elseif {[istarget "x86_64-*-*"] && [is_lp64_target]} {
29 set sfile ${test}-amd64.S
30 } else {
31 return 0
34 if { [prepare_for_testing "failed to prepare" "${test}" ${sfile} {nodebug additional_flags=-nostdlib}] } {
35 return -1
38 if ![runto_main] {
39 return -1
42 # Initialize tests to be an empty array.
43 unset -nocomplain tests
44 array set tests {}
46 proc gdb-test {line var value} {
47 global tests
49 lappend tests($line) [list $var $value 0]
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.
54 proc xfail-gdb-test {line var value {arch_pattern ""}} {
55 global tests
57 set flag 1
58 if {$arch_pattern != ""} {
59 if {! [istarget $arch_pattern]} {
60 set flag 0
64 lappend tests($line) [list $var $value $flag]
67 proc scan_gdb_tests {} {
68 global srcdir subdir test
70 set file "$srcdir/$subdir/$test.c"
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
79 eval $test_cmd
81 close $fd
84 scan_gdb_tests
86 foreach 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"
91 foreach test $tests($line) {
92 set var [lindex $test 0]
93 set value [lindex $test 1]
94 set should_xfail [lindex $test 2]
96 if {$should_xfail} {
97 setup_xfail *-*-*
100 gdb_test "print $var" \
101 " = $value" \
102 "check value of $var at typeddwarf.c:$line"