]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.twreverse/consecutive-reverse.exp
This commit was manufactured by cvs2svn to create branch
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.twreverse / consecutive-reverse.exp
1 # Copyright 2008 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 # Please email any bugs, comments, and/or additions to this file to:
17 # bug-gdb@prep.ai.mit.edu
18
19 # Based on a file written by Michael Snyder. (msnyder@redhat.com)
20
21 #
22 # Test breakpoints at consecutive instruction addresses.
23 #
24
25 set testfile "consecutive-reverse"
26 set srcfile ${testfile}.c
27
28 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
29 return -1
30 }
31
32 runto main
33
34 # FIXME 'record' command should say something so we know it's working.
35 gdb_test "record" "" "start recording"
36
37 gdb_breakpoint foo
38 gdb_test "continue" "Breakpoint $decimal, foo .*" \
39 "continue to breakpoint in foo"
40
41 set foo1_addr 0
42 set foo2_addr 0
43 set stop_addr 0
44
45 send_gdb "x /2i \$pc\n"
46 gdb_expect {
47 global hex
48 global foo1_addr
49 global foo2_addr
50 global gdb_prompt
51
52 -re "($hex).*\[\r\n\]+($hex).*$gdb_prompt $" {
53 set foo1_addr $expect_out(1,string)
54 set foo2_addr $expect_out(2,string)
55 pass "get breakpoint address for foo"
56 }
57 -re ".*$gdb_prompt $" {
58 fail "get breakpoint address for foo"
59 return 0;
60 }
61 timeout {
62 fail "get breakpoint address for foo (timeout)"
63 return 0;
64 }
65 }
66
67 gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \
68 "set bp, 2nd instr"
69
70 send_gdb "step\n"
71 gdb_expect {
72 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
73 set stop_addr $expect_out(1,string)
74 if [eval expr "$foo2_addr == $stop_addr"] then {
75 pass "stopped at bp, 2nd instr"
76 } else {
77 fail "stopped at bp, 2nd instr (wrong address)"
78 }
79 }
80 -re ".*$gdb_prompt $" {
81 fail "stopped at bp, 2nd instr"
82 }
83 timeout {
84 fail "stopped at bp, 2nd instr (timeout)"
85
86 }
87 }
88
89 ###
90 ###
91 ###
92
93 # Set reverse execution direction
94 # FIXME: command needs to acknowledge, so we can test if it succeeded.
95
96 gdb_test "set exec-dir reverse" "" "set reverse execution"
97
98 # Now step backward and hope to hit the first breakpoint.
99
100 set test_msg "stopped at bp in reverse, 1st instr"
101 gdb_test_multiple "step" "$test_msg" {
102 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
103 set stop_addr $expect_out(1,string)
104 if [eval expr "$foo1_addr == $stop_addr"] then {
105 pass "$test_msg"
106 } else {
107 fail "$test_msg (wrong address)"
108 }
109 }
110 -re "Breakpoint $decimal, foo.*$gdb_prompt $" {
111 send_gdb "print \$pc == $foo1_addr\n"
112 gdb_expect {
113 -re "$decimal = 1\[\r\n\]+$gdb_prompt $" {
114 pass "$test_msg"
115 }
116 -re "$decimal = 0\[\r\n\]+$gdb_prompt $" {
117 fail "$test_msg (wrong address)"
118 }
119 }
120 }
121 -re ".*$gdb_prompt $" {
122 fail "$test_msg"
123 }
124 }