Commit | Line | Data |
---|---|---|
88b9d363 | 1 | # Copyright 2008-2022 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 | ||
50441f0f | 31 | runto_main |
02506ff1 | 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 | ||
24fe640b TV |
38 | set is_stmt [is_stmt_addresses $srcfile] |
39 | ||
02506ff1 MS |
40 | set end_location [gdb_get_line_number "end of main" ] |
41 | gdb_test "break $end_location" \ | |
a80db015 | 42 | "Breakpoint $decimal at .*$srcfile, line $end_location\." \ |
bb95117e | 43 | "breakpoint at end of main" |
02506ff1 MS |
44 | |
45 | gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main" | |
46 | ||
55baab26 TT |
47 | gdb_test "record save $precsave" \ |
48 | "Saved core file $precsave with execution log\." \ | |
02506ff1 MS |
49 | "save process recfile" |
50 | ||
cdc7edd7 | 51 | gdb_test "kill" "" "kill process, prepare to debug log file" \ |
02506ff1 MS |
52 | "Kill the program being debugged\\? \\(y or n\\) " "y" |
53 | ||
55baab26 | 54 | gdb_test "record restore $precsave" \ |
470e2f4e | 55 | "Restored records from core file .*" \ |
02506ff1 MS |
56 | "reload precord save file" |
57 | ||
58 | gdb_breakpoint foo | |
59 | gdb_test "continue" "Breakpoint $decimal, foo .*" \ | |
60 | "continue to breakpoint in foo" | |
61 | ||
62 | set foo1_addr 0 | |
63 | set foo2_addr 0 | |
64 | set stop_addr 0 | |
65 | ||
ec9f1212 | 66 | gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" { |
02506ff1 MS |
67 | global hex |
68 | global foo1_addr | |
69 | global foo2_addr | |
70 | global gdb_prompt | |
71 | ||
240e538a | 72 | -re "=> ($hex).*\[\r\n\]+ ($hex).*$gdb_prompt $" { |
02506ff1 MS |
73 | set foo1_addr $expect_out(1,string) |
74 | set foo2_addr $expect_out(2,string) | |
75 | pass "get breakpoint address for foo" | |
76 | } | |
02506ff1 MS |
77 | } |
78 | ||
79 | gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \ | |
80 | "set bp, 2nd instr" | |
81 | ||
82 | set testmsg "stopped at bp, 2nd instr" | |
83 | gdb_test_multiple "step" $testmsg { | |
24fe640b | 84 | -re -wrap "Breakpoint $decimal, ($hex) in foo.*" { |
02506ff1 MS |
85 | set stop_addr $expect_out(1,string) |
86 | if [eval expr "$foo2_addr == $stop_addr"] then { | |
87 | pass "stopped at bp, 2nd instr" | |
88 | } else { | |
89 | fail "stopped at bp, 2nd instr (wrong address)" | |
90 | } | |
91 | } | |
24fe640b TV |
92 | -re -wrap "Breakpoint $decimal, foo.*" { |
93 | set stop_addr [get_valueof "/x" "\$pc" "" "value of pc"] | |
94 | set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt] | |
95 | if { ! $stop_addr_is_stmt } { | |
96 | fail "stopped at bp, 2nd instr (missing hex prefix)" | |
97 | } elseif [eval expr "$foo2_addr == $stop_addr"] then { | |
98 | pass "stopped at bp, 2nd instr" | |
99 | } else { | |
100 | fail "stopped at bp, 2nd instr (wrong address)" | |
101 | } | |
102 | } | |
02506ff1 MS |
103 | } |
104 | ||
105 | ### | |
106 | ### | |
107 | ### | |
108 | ||
109 | # Set reverse execution direction | |
02506ff1 | 110 | |
bcd2dc50 | 111 | gdb_test_no_output "set exec-dir reverse" "set reverse execution" |
02506ff1 MS |
112 | |
113 | # Now step backward and hope to hit the first breakpoint. | |
114 | ||
115 | set test_msg "stopped at bp in reverse, 1st instr" | |
116 | gdb_test_multiple "step" "$test_msg" { | |
117 | -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" { | |
118 | set stop_addr $expect_out(1,string) | |
119 | if [eval expr "$foo1_addr == $stop_addr"] then { | |
120 | pass "$test_msg" | |
121 | } else { | |
122 | fail "$test_msg (wrong address)" | |
123 | } | |
124 | } | |
125 | -re "Breakpoint $decimal, foo.*$gdb_prompt $" { | |
ec9f1212 MS |
126 | gdb_test "print \$pc == $foo1_addr" \ |
127 | "$decimal = 1" \ | |
128 | "$test_msg" | |
02506ff1 MS |
129 | } |
130 | } |