]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.reverse/func-map-to-same-line.exp
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.reverse / func-map-to-same-line.exp
1 # Copyright 2023-2024 Free Software Foundation, Inc.
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 reverse stepping.
17 # Lots of code borrowed from "step-test.exp".
18
19 # This test checks to make sure there is no regression failures for
20 # the reverse-next command when stepping back over two functions in
21 # the same line.
22
23 require supports_reverse
24
25 # This test uses the gcc no-column-info command which was added in gcc 7.1.
26
27 proc run_tests {} {
28 global testfile
29
30 clean_restart ${testfile}
31
32 if { ![runto_main] } {
33 return
34 }
35
36 with_test_prefix "next-test" {
37 gdb_test_no_output "record" "turn on process record"
38
39 # This regression test verifies the reverse-step and reverse-next
40 # commands work properly when executing backwards thru a source line
41 # containing two function calls on the same source line, i.e.
42 # func1 (); func2 ();. This test is compiled so the dwarf info
43 # does not contain the line table information.
44
45 # Test 1, reverse-next command
46 # Set breakpoint at the line after the function calls.
47 set bp_start_reverse_test [gdb_get_line_number "START REVERSE TEST"]
48
49 gdb_breakpoint $bp_start_reverse_test temporary
50
51 # Continue to break point for reverse-next test.
52 # Command definition: reverse-next [count]
53 # Run backward to the beginning of the previous line executed in
54 # the current (innermost) stack frame. If the line contains
55 # function calls, they will be “un-executed” without stopping.
56 # Starting from the first line of a function, reverse-next will
57 # take you back to the caller of that function, before the
58 # function was called, just as the normal next command would take
59 # you from the last line of a function back to its return to its
60 # caller 2.
61
62 gdb_continue_to_breakpoint \
63 "stopped at command reverse-next test start location" \
64 ".*$bp_start_reverse_test\r\n.*"
65
66 # The reverse-next should step all the way back to the beginning of
67 # the line, i.e. at the beginning of the func1 call.
68 gdb_test "reverse-next" ".*func1 \\(\\); func2 \\(\\);.*" \
69 " reverse-next to line with two functions"
70
71 # We should be stopped at the first instruction of the line. A
72 # reverse-step should step back and stop at the beginning of the
73 # previous line b = 2, i.e. not in func1 ().
74 gdb_test "reverse-stepi" ".*b = 2;.*" \
75 "reverse-stepi to previous line b = 2"
76 }
77
78 # Setup for test 2
79 clean_restart ${testfile}
80
81 if { ![runto_main] } {
82 return
83 }
84
85 with_test_prefix "step-test" {
86 gdb_test_no_output "record" "turn on process record"
87
88 # Test 2, reverse-step command
89 # Set breakpoint at the line after the function calls.
90 gdb_breakpoint $bp_start_reverse_test temporary
91
92 # Continue to the start of the reverse-step test.
93 # Command definition: reverse-step [count]
94 # Run the program backward until control reaches the start of a
95 # different source line; then stop it, and return control to gdb.
96 # Like the step command, reverse-step will only stop at the
97 # beginning of a source line. It “un-executes” the previously
98 # executed source line. If the previous source line included calls
99 # to debuggable functions, reverse-step will step (backward) into
100 # the called function, stopping at the beginning of the last
101 # statement in the called function (typically a return statement).
102 # Also, as with the step command, if non-debuggable functions are
103 # called, reverse-step will run thru them backward without
104 # stopping.
105
106 gdb_continue_to_breakpoint \
107 "stopped at command reverse-step test start location" \
108 ".*$bp_start_reverse_test\r\n.*"
109
110 # The first reverse step should take us call of func2 ().
111 gdb_test "reverse-step" ".*END FUNC2.*" \
112 "reverse-step into func2 "
113
114 # The second reverse step should take us into func1 ().
115 gdb_test "reverse-step" ".*END FUNC1.*" \
116 "reverse-step into func1 "
117
118 # The third reverse step should take us call of func1 ().
119 gdb_test "reverse-step" ".*func1 \\(\\); func2 \\(\\);.*" \
120 "reverse-step to line func1(); func2(), at call for func1 "
121 # We should be stopped at the first instruction of the line. A
122 # reversee stepi should take us to b = 2 ().
123 gdb_test "reverse-stepi" ".*b = 2;.*" \
124 "reverse-stepi to line b = 2 "
125 }
126 }
127
128 standard_testfile .c
129
130 # test with and without gcc column info enabled
131 foreach_with_prefix column_info_flag {column-info no-column-info} {
132 set options [list debug $column_info_flag]
133
134 if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile} \
135 $options]} {
136 return -1
137 }
138
139 run_tests
140 }