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