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