1 # Copyright 2008, 2009, 2010, 2011 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 # This file is part of the GDB testsuite. It tests stepping over
17 # consecutive instructions in reverse.
19 if ![supports_reverse] {
23 set testfile "consecutive-reverse"
24 set srcfile ${testfile}.c
26 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
32 if [supports_process_record] {
33 # Activate process record/replay
34 gdb_test_no_output "record" "Turn on process record"
38 gdb_test "continue" "Breakpoint $decimal, foo .*" \
39 "continue to breakpoint in foo"
45 gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" {
51 -re "=> ($hex).*\[\r\n\]+ ($hex).*$gdb_prompt $" {
52 set foo1_addr $expect_out(1,string)
53 set foo2_addr $expect_out(2,string)
54 pass "get breakpoint address for foo"
58 gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \
61 set testmsg "stopped at bp, 2nd instr"
62 gdb_test_multiple "step" $testmsg {
63 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
64 set stop_addr $expect_out(1,string)
65 if [eval expr "$foo2_addr == $stop_addr"] then {
66 pass "stopped at bp, 2nd instr"
68 fail "stopped at bp, 2nd instr (wrong address)"
77 # Set reverse execution direction
79 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
81 # Now step backward and hope to hit the first breakpoint.
83 set test_msg "stopped at bp in reverse, 1st instr"
84 gdb_test_multiple "step" "$test_msg" {
85 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
86 set stop_addr $expect_out(1,string)
87 if [eval expr "$foo1_addr == $stop_addr"] then {
90 fail "$test_msg (wrong address)"
93 -re "Breakpoint $decimal, foo.*$gdb_prompt $" {
94 gdb_test "print \$pc == $foo1_addr" \