| 1 | # Copyright 2011-2013 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 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. |
| 21 | if ![dwarf2_support] { |
| 22 | return 0 |
| 23 | } |
| 24 | |
| 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 |
| 32 | } |
| 33 | |
| 34 | if { [prepare_for_testing "${test}.exp" "${test}" ${sfile} {nodebug additional_flags=-nostdlib}] } { |
| 35 | return -1 |
| 36 | } |
| 37 | |
| 38 | if ![runto_main] { |
| 39 | return -1 |
| 40 | } |
| 41 | |
| 42 | # Initialize tests to be an empty array. |
| 43 | unset -nocomplain tests |
| 44 | array set tests {} |
| 45 | |
| 46 | proc gdb-test {line var value} { |
| 47 | global tests |
| 48 | |
| 49 | lappend tests($line) [list $var $value 0] |
| 50 | } |
| 51 | |
| 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 |
| 56 | |
| 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] |
| 65 | } |
| 66 | |
| 67 | proc 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 | |
| 84 | scan_gdb_tests |
| 85 | |
| 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" |
| 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 | } |