]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.reverse/consecutive-precsave.exp
* gdb.reverse/break-precsave.exp: Use standard_testfile.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / consecutive-precsave.exp
1 # Copyright 2008-2012 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 # This file is part of the GDB testsuite. It tests stepping over
17 # consecutive instructions in a process record logfile.
18
19 # This test suitable only for process record-replay
20 if ![supports_process_record] {
21 return
22 }
23
24 standard_testfile consecutive-reverse.c
25
26 if { [prepare_for_testing $testfile.exp $testfile $srcfile] } {
27 return -1
28 }
29
30 runto main
31
32 if [supports_process_record] {
33 # Activate process record/replay
34 gdb_test_no_output "record" "Turn on process record"
35 }
36
37 set end_location [gdb_get_line_number "end of main" ]
38 gdb_test "break $end_location" \
39 "Breakpoint $decimal at .*/$srcfile, line $end_location\." \
40 "BP at end of main"
41
42 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
43
44 gdb_test "record save consecutive.precsave" \
45 "Saved core file consecutive.precsave with execution log\." \
46 "save process recfile"
47
48 gdb_test "kill" "" "Kill process, prepare to debug log file" \
49 "Kill the program being debugged\\? \\(y or n\\) " "y"
50
51 gdb_test "record restore consecutive.precsave" \
52 "Program terminated with signal .*" \
53 "reload precord save file"
54
55 gdb_breakpoint foo
56 gdb_test "continue" "Breakpoint $decimal, foo .*" \
57 "continue to breakpoint in foo"
58
59 set foo1_addr 0
60 set foo2_addr 0
61 set stop_addr 0
62
63 gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" {
64 global hex
65 global foo1_addr
66 global foo2_addr
67 global gdb_prompt
68
69 -re "=> ($hex).*\[\r\n\]+ ($hex).*$gdb_prompt $" {
70 set foo1_addr $expect_out(1,string)
71 set foo2_addr $expect_out(2,string)
72 pass "get breakpoint address for foo"
73 }
74 }
75
76 gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \
77 "set bp, 2nd instr"
78
79 set testmsg "stopped at bp, 2nd instr"
80 gdb_test_multiple "step" $testmsg {
81 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
82 set stop_addr $expect_out(1,string)
83 if [eval expr "$foo2_addr == $stop_addr"] then {
84 pass "stopped at bp, 2nd instr"
85 } else {
86 fail "stopped at bp, 2nd instr (wrong address)"
87 }
88 }
89 }
90
91 ###
92 ###
93 ###
94
95 # Set reverse execution direction
96
97 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
98
99 # Now step backward and hope to hit the first breakpoint.
100
101 set test_msg "stopped at bp in reverse, 1st instr"
102 gdb_test_multiple "step" "$test_msg" {
103 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
104 set stop_addr $expect_out(1,string)
105 if [eval expr "$foo1_addr == $stop_addr"] then {
106 pass "$test_msg"
107 } else {
108 fail "$test_msg (wrong address)"
109 }
110 }
111 -re "Breakpoint $decimal, foo.*$gdb_prompt $" {
112 gdb_test "print \$pc == $foo1_addr" \
113 "$decimal = 1" \
114 "$test_msg"
115 }
116 }