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