Add method/format information to =record-started
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-reverse.exp
CommitLineData
618f726f 1# Copyright 2009-2016 Free Software Foundation, Inc.
8a980b44
PA
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# Test Machine interface (MI) operations
17# Verify that, using the MI, we can run a simple program in both forward
18# and reverse directions with the following execution commands:
19# - exec-continue
20# - exec-finish
21# - exec-next
22# - exec-step
23# - exec-next-instruction
24# - exec-step-instruction
25
26# The goal is not to test gdb functionality, which is done by other tests,
27# but to verify the correct output response to MI operations.
28#
29
979ade8b 30if ![supports_reverse] {
8a980b44
PA
31 return
32}
33
34load_lib mi-support.exp
35set MIFLAGS "-i=mi"
36
37gdb_exit
38if [mi_gdb_start] {
39 continue
40}
41
298a9cf0
TT
42standard_testfile basics.c
43
9357e021 44if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
8a980b44
PA
45 untested ${testfile}.exp
46 return -1
47}
48
49mi_run_to_main
50
979ade8b 51if [supports_process_record] {
8a980b44
PA
52 # Activate process record/replay
53 if [mi_gdb_test "-interpreter-exec console record" \
15544bd9 54 "=record-started,thread-group=\"i1\"\r\n\\^done" \
82a90ccf 55 "Turn on process record"] {
4ec70201 56 warning "Fail to activate process record/replay, tests in this group will not be performed.\n"
8a980b44
PA
57 return -1
58 }
59}
60
61# Locate line numbers in basics.c.
62set line_callee4_head [gdb_get_line_number "callee4 ("]
63set line_callee4_body [expr $line_callee4_head + 2]
64set line_callee3_head [gdb_get_line_number "callee3 ("]
65set line_callee3_body [expr $line_callee3_head + 2]
66set line_callee3_close [expr $line_callee3_head + 3]
67set line_callee2_head [gdb_get_line_number "callee2 ("]
68set line_callee2_body [expr $line_callee2_head + 2]
69set line_callee2_close [expr $line_callee2_head + 3]
70set line_callee1_head [gdb_get_line_number "callee1 ("]
71set line_callee1_body [expr $line_callee1_head + 2]
72set line_callee1_close [expr $line_callee1_head + 3]
73set line_callme_head [gdb_get_line_number "callme"]
74set line_callme_body [expr $line_callme_head + 2]
75set line_main_head [gdb_get_line_number "main ("]
76set line_main_body [expr $line_main_head + 2]
77set line_main_hello [gdb_get_line_number "Hello, World!"]
78set line_main_callme_1 [gdb_get_line_number "callme (1"]
79
80# Forward execute to the callme() function, so that we can
81# execute backward from there.
82mi_continue_to callme
83mi_delete_breakpoints
84
85proc test_controlled_execution_reverse {} {
86 global mi_gdb_prompt
87 global srcfile
88 global hex
89
90 global line_callee4_head line_callee4_body
91 global line_callee3_head line_callee3_body line_callee3_close
92 global line_callee2_head line_callee2_body line_callee2_close
93 global line_callee1_head line_callee1_body line_callee1_close
94 global line_main_head line_main_body
95 global line_main_hello line_main_callme_1
96
97 # Test exec-reverse-finish
98
99 mi_execute_to "exec-finish --reverse" \
100 "end-stepping-range" "main" "" \
101 "basics.c" $line_main_callme_1 "" \
102 "reverse finish from callme"
103
104 # Test exec-reverse-next
105 # It takes two steps to get back to the previous line,
106 # as the first step moves us to the start of the current line,
107 # and the one after that moves back to the previous line.
108
109 mi_execute_to "exec-next --reverse 2" \
110 "end-stepping-range" "main" "" \
111 "basics.c" $line_main_hello "" \
112 "reverse next to get over the call to do_nothing"
113
114 # Test exec-reverse-step
115
116 mi_execute_to "exec-step --reverse" \
117 "end-stepping-range" "callee1" \
118 "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}" \
119 "basics.c" $line_callee1_close "" \
120 "reverse step to callee1"
121
122 mi_execute_to "exec-step --reverse" \
123 "end-stepping-range" "callee2" \
124 "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
125 "basics.c" $line_callee2_close "" \
126 "reverse step to callee2"
127
128 mi_execute_to "exec-step --reverse" \
129 "end-stepping-range" "callee3" \
130 "\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
131 "basics.c" $line_callee3_close "" \
132 "reverse step to callee3"
133
134 mi_execute_to "exec-step --reverse" \
135 "end-stepping-range" "callee4" "" \
136 "basics.c" "\[0-9\]+" "" \
137 "reverse step to callee4"
138
139 # Test exec-reverse-[step|next]-instruction
140
141 mi_execute_to "exec-step-instruction --reverse" \
142 "end-stepping-range" "callee4" "" \
143 "basics.c" "\[0-9\]+" "" \
144 "reverse-step-instruction at callee4"
145
146 mi_execute_to "exec-next-instruction --reverse" \
147 "end-stepping-range" "callee4" "" \
148 "basics.c" "\[0-9\]+" "" \
149 "reverse-next-instruction at callee4"
150
151 # Test exec-reverse-continue
152
153 mi_create_breakpoint "-t basics.c:$line_callee3_head" \
4b48d439
KS
154 "insert temp breakpoint at basics.c:$line_callee3_head" \
155 -number 3 -disp del -func callee3 -file ".*basics.c" \
156 -line $line_callee3_head
8a980b44
PA
157
158 mi_execute_to "exec-continue --reverse" \
159 "breakpoint-hit" "callee3" \
160 "\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
161 "basics.c" "\[0-9\]+" \
162 { "" "disp=\"del\""} \
163 "reverse-continue at callee3"
164
165 mi_execute_to "exec-continue --reverse" \
166 "" "main" "" \
167 "basics.c" $line_main_body "" \
168 "reverse-continue at main"
169}
170
171test_controlled_execution_reverse
172
173mi_gdb_exit
174return 0
This page took 0.784455 seconds and 4 git commands to generate.