1 # Copyright 2010 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 # Test single stepping over Thumb-2 IT blocks.
18 if {![istarget arm*-*eabi*]} then {
19 verbose "Skipping Thumb-2 tests."
23 set testfile "thumb2-it"
24 set srcfile ${testfile}.S
25 set binfile ${objdir}/${subdir}/${testfile}
27 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable debug] != "" } {
28 untested thumb2-it.exp
34 gdb_reinitialize_dir $srcdir/$subdir
37 if ![runto_main] then {
38 untested thumb2-it.exp
42 # Make sure that the compiler options allow Thumb-2.
43 gdb_test_multiple "list" "list main" {
44 -re ".*@ No Thumb-2.*$gdb_prompt $" {
46 untested thumb2-it.exp
49 -re ".*@ Thumb-2 OK.*$gdb_prompt $" {
54 proc test_it_block { func } {
58 if { ! [gdb_breakpoint "*${func}"] } {
59 unresolved "$func, IT block tests"
63 gdb_test "call ${func}()" "Breakpoint.*@ Setup.*" "$func, call"
71 set msg "$func, stepi $steps"
72 gdb_test_multiple "stepi" "$msg" {
73 -re ".*@ Setup.*$gdb_prompt $" {
77 -re ".*@ IT instruction, Expected == (\[0-9\]*)\r\n$gdb_prompt $" {
78 set expected $expect_out(1,string)
82 -re ".*@ Reached.*$gdb_prompt $" {
86 if { [regexp {@ Reached, Set ([^\r\n]*)\r\n} $expect_out(0,string) dummy change] } {
87 gdb_test "set $change" "" "$func, set $change"
90 -re ".*@ Not reached.*$gdb_prompt $" {
91 # An instruction in an IT block whose predicate is false when
92 # we reach it. If using software single step, we should not
94 if { $software_step } {
101 -re ".*@ Never reached.*$gdb_prompt $" {
102 # An instruction that should be branched over.
105 -re ".*@ Done.*$gdb_prompt $" {
107 if { $reached == $expected } {
108 pass "$func, correct instructions reached"
110 fail "$func, correct instructions reached"
112 if { [regexp {@ Done, Check ([^\r\n]*)\r\n} $expect_out(0,string) dummy check] } {
113 gdb_test "print $check" ".* = 1" "$func, $check"
124 gdb_test "continue" "" "$func, continue"
128 # If we are using software single-stepping in GDB, then GDB will not
129 # stop at conditional instructions with a false predicate during stepi.
130 # If we are using a simulator or debug interface with hardware single
131 # step, then GDB will stop at such instructions.
132 if { [istarget arm*-linux*] } {
138 for { set i 1 } { $i <= 8 } { incr i } {
139 test_it_block it_${i}