Commit | Line | Data |
---|---|---|
618f726f | 1 | # Copyright 2008-2016 Free Software Foundation, Inc. |
02506ff1 MS |
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 | |
d3895d7d | 20 | if ![supports_process_record] { |
02506ff1 MS |
21 | return |
22 | } | |
23 | ||
7686c074 | 24 | standard_testfile consecutive-reverse.c |
55baab26 | 25 | set precsave [standard_output_file consecutive.precsave] |
02506ff1 | 26 | |
5b362f04 | 27 | if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { |
02506ff1 MS |
28 | return -1 |
29 | } | |
30 | ||
31 | runto main | |
32 | ||
d3895d7d | 33 | if [supports_process_record] { |
02506ff1 | 34 | # Activate process record/replay |
9f058c10 | 35 | gdb_test_no_output "record" "turn on process record" |
02506ff1 MS |
36 | } |
37 | ||
38 | set end_location [gdb_get_line_number "end of main" ] | |
39 | gdb_test "break $end_location" \ | |
a80db015 | 40 | "Breakpoint $decimal at .*$srcfile, line $end_location\." \ |
bb95117e | 41 | "breakpoint at end of main" |
02506ff1 MS |
42 | |
43 | gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" | |
44 | ||
55baab26 TT |
45 | gdb_test "record save $precsave" \ |
46 | "Saved core file $precsave with execution log\." \ | |
02506ff1 MS |
47 | "save process recfile" |
48 | ||
cdc7edd7 | 49 | gdb_test "kill" "" "kill process, prepare to debug log file" \ |
02506ff1 MS |
50 | "Kill the program being debugged\\? \\(y or n\\) " "y" |
51 | ||
55baab26 | 52 | gdb_test "record restore $precsave" \ |
470e2f4e | 53 | "Restored records from core file .*" \ |
02506ff1 MS |
54 | "reload precord save file" |
55 | ||
56 | gdb_breakpoint foo | |
57 | gdb_test "continue" "Breakpoint $decimal, foo .*" \ | |
58 | "continue to breakpoint in foo" | |
59 | ||
60 | set foo1_addr 0 | |
61 | set foo2_addr 0 | |
62 | set stop_addr 0 | |
63 | ||
ec9f1212 | 64 | gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" { |
02506ff1 MS |
65 | global hex |
66 | global foo1_addr | |
67 | global foo2_addr | |
68 | global gdb_prompt | |
69 | ||
240e538a | 70 | -re "=> ($hex).*\[\r\n\]+ ($hex).*$gdb_prompt $" { |
02506ff1 MS |
71 | set foo1_addr $expect_out(1,string) |
72 | set foo2_addr $expect_out(2,string) | |
73 | pass "get breakpoint address for foo" | |
74 | } | |
02506ff1 MS |
75 | } |
76 | ||
77 | gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \ | |
78 | "set bp, 2nd instr" | |
79 | ||
80 | set testmsg "stopped at bp, 2nd instr" | |
81 | gdb_test_multiple "step" $testmsg { | |
82 | -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { | |
83 | set stop_addr $expect_out(1,string) | |
84 | if [eval expr "$foo2_addr == $stop_addr"] then { | |
85 | pass "stopped at bp, 2nd instr" | |
86 | } else { | |
87 | fail "stopped at bp, 2nd instr (wrong address)" | |
88 | } | |
89 | } | |
90 | } | |
91 | ||
92 | ### | |
93 | ### | |
94 | ### | |
95 | ||
96 | # Set reverse execution direction | |
02506ff1 | 97 | |
bcd2dc50 | 98 | gdb_test_no_output "set exec-dir reverse" "set reverse execution" |
02506ff1 MS |
99 | |
100 | # Now step backward and hope to hit the first breakpoint. | |
101 | ||
102 | set test_msg "stopped at bp in reverse, 1st instr" | |
103 | gdb_test_multiple "step" "$test_msg" { | |
104 | -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { | |
105 | set stop_addr $expect_out(1,string) | |
106 | if [eval expr "$foo1_addr == $stop_addr"] then { | |
107 | pass "$test_msg" | |
108 | } else { | |
109 | fail "$test_msg (wrong address)" | |
110 | } | |
111 | } | |
112 | -re "Breakpoint $decimal, foo.*$gdb_prompt $" { | |
ec9f1212 MS |
113 | gdb_test "print \$pc == $foo1_addr" \ |
114 | "$decimal = 1" \ | |
115 | "$test_msg" | |
02506ff1 MS |
116 | } |
117 | } |