]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.reverse/consecutive-reverse.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / consecutive-reverse.exp
CommitLineData
1d506c26 1# Copyright 2008-2024 Free Software Foundation, Inc.
28d41a99
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 reverse.
18
5954db83 19require supports_reverse
28d41a99 20
7686c074 21standard_testfile
28d41a99 22
5b362f04 23if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
28d41a99
MS
24 return -1
25}
26
50441f0f 27runto_main
28d41a99 28
d3895d7d 29if [supports_process_record] {
28d41a99 30 # Activate process record/replay
9f058c10 31 gdb_test_no_output "record" "turn on process record"
28d41a99
MS
32}
33
24fe640b
TV
34set is_stmt [is_stmt_addresses $srcfile]
35
28d41a99
MS
36gdb_breakpoint foo
37gdb_test "continue" "Breakpoint $decimal, foo .*" \
38 "continue to breakpoint in foo"
39
40set foo1_addr 0
41set foo2_addr 0
42set stop_addr 0
43
ec9f1212 44gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" {
28d41a99
MS
45 global hex
46 global foo1_addr
47 global foo2_addr
48 global gdb_prompt
49
4cf866a3 50 -re "=> ($hex).*\[\r\n\]+ ($hex).*$gdb_prompt $" {
28d41a99
MS
51 set foo1_addr $expect_out(1,string)
52 set foo2_addr $expect_out(2,string)
53 pass "get breakpoint address for foo"
54 }
28d41a99
MS
55}
56
57gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \
58 "set bp, 2nd instr"
59
4cf866a3
MS
60set testmsg "stopped at bp, 2nd instr"
61gdb_test_multiple "step" $testmsg {
24fe640b 62 -re -wrap "Breakpoint $decimal, ($hex) in foo.*" {
28d41a99 63 set stop_addr $expect_out(1,string)
bde43e8d 64 if {[eval expr "$foo2_addr == $stop_addr"]} {
28d41a99
MS
65 pass "stopped at bp, 2nd instr"
66 } else {
67 fail "stopped at bp, 2nd instr (wrong address)"
68 }
69 }
24fe640b
TV
70 -re -wrap "Breakpoint $decimal, foo.*" {
71 set stop_addr [get_valueof "/x" "\$pc" "" "value of pc"]
72 set stop_addr_is_stmt [hex_in_list $stop_addr $is_stmt]
73 if { ! $stop_addr_is_stmt } {
74 fail "stopped at bp, 2nd instr (missing hex prefix)"
bde43e8d 75 } elseif {[eval expr "$foo2_addr == $stop_addr"]} {
24fe640b
TV
76 pass "stopped at bp, 2nd instr"
77 } else {
78 fail "stopped at bp, 2nd instr (wrong address)"
79 }
80 }
28d41a99
MS
81}
82
83###
84###
85###
86
87# Set reverse execution direction
28d41a99 88
bcd2dc50 89gdb_test_no_output "set exec-dir reverse" "set reverse execution"
28d41a99
MS
90
91# Now step backward and hope to hit the first breakpoint.
92
93set test_msg "stopped at bp in reverse, 1st instr"
94gdb_test_multiple "step" "$test_msg" {
95 -re "Breakpoint $decimal, ($hex) in foo.*$gdb_prompt $" {
96 set stop_addr $expect_out(1,string)
bde43e8d 97 if {[eval expr "$foo1_addr == $stop_addr"]} {
28d41a99
MS
98 pass "$test_msg"
99 } else {
100 fail "$test_msg (wrong address)"
101 }
102 }
103 -re "Breakpoint $decimal, foo.*$gdb_prompt $" {
ec9f1212
MS
104 gdb_test "print \$pc == $foo1_addr" \
105 "$decimal = 1" \
106 "$test_msg"
28d41a99
MS
107 }
108}