Automatic date update in version.in
[binutils-gdb.git] / gdb / testsuite / gdb.reverse / consecutive-precsave.exp
blob134d85be512dfa68c553bed7912017f9811c5bfd
1 #   Copyright 2008-2024 Free Software Foundation, Inc.
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.
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.
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/>.
16 # This file is part of the GDB testsuite.  It tests stepping over
17 # consecutive instructions in a process record logfile.
19 # This test suitable only for process record-replay
20 require supports_process_record
22 standard_testfile consecutive-reverse.c
23 set precsave [standard_output_file consecutive.precsave]
25 if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
26     return -1
29 runto_main
31 # Activate process record/replay
32 gdb_test_no_output "record" "turn on process record"
34 set is_stmt [is_stmt_addresses $srcfile]
36 set end_location  [gdb_get_line_number "end of main"  ]
37 gdb_test "break $end_location" \
38     "Breakpoint $decimal at .*$srcfile, line $end_location\." \
39     "breakpoint at end of main"
41 gdb_test "continue" "Breakpoint .* end of main .*" "run to end of main"
43 gdb_test "record save $precsave" \
44     "Saved core file $precsave with execution log\."  \
45     "save process recfile"
47 gdb_test "kill" "" "kill process, prepare to debug log file" \
48     "Kill the program being debugged\\? \\(y or n\\) " "y"
50 gdb_test "record restore $precsave" \
51     "Restored records from core file .*" \
52     "reload precord save file"
54 gdb_breakpoint foo
55 gdb_test "continue" "Breakpoint $decimal, foo .*" \
56         "continue to breakpoint in foo"
58 set foo1_addr 0
59 set foo2_addr 0
60 set stop_addr 0
62 gdb_test_multiple "x /2i \$pc" "get breakpoint address for foo" {
63     global hex
64     global foo1_addr
65     global foo2_addr
66     global gdb_prompt
68     -re "=> ($hex).*\[\r\n\]+   ($hex).*$gdb_prompt $" {
69         set foo1_addr $expect_out(1,string)
70         set foo2_addr $expect_out(2,string)
71         pass "get breakpoint address for foo"
72     }
75 gdb_test "break \*$foo2_addr" "Breakpoint $decimal at $foo2_addr: file .*" \
76         "set bp, 2nd instr"
78 set testmsg "stopped at bp, 2nd instr"
79 gdb_test_multiple "step" $testmsg {
80     -re -wrap "Breakpoint $decimal, ($hex) in foo.*" {
81         set stop_addr $expect_out(1,string)
82         if {[eval expr "$foo2_addr == $stop_addr"]} {
83             pass "stopped at bp, 2nd instr"
84         } else {
85             fail "stopped at bp, 2nd instr (wrong address)"
86         }
87     }
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)"
93        } elseif {[eval expr "$foo2_addr == $stop_addr"]} {
94            pass "stopped at bp, 2nd instr"
95        } else {
96            fail "stopped at bp, 2nd instr (wrong address)"
97        }
98     }
105 # Set reverse execution direction
107 gdb_test_no_output "set exec-dir reverse" "set reverse execution"
109 # Now step backward and hope to hit the first breakpoint.
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)
115         if {[eval expr "$foo1_addr == $stop_addr"]} {
116             pass "$test_msg"
117         } else {
118             fail "$test_msg (wrong address)"
119         }
120     }
121     -re "Breakpoint $decimal, foo.*$gdb_prompt $" {
122         gdb_test "print \$pc == $foo1_addr" \
123             "$decimal = 1" \
124             "$test_msg"
125     }