daily update
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-reverse.exp
CommitLineData
8a980b44
PA
1# Copyright 2009, 2011-2012 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# 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" \
54 {\^done} "Turn on process record"] {
55 warning "Fail to activate process record/replay, tests in this group will not be performed.\n";
56 return -1
57 }
58}
59
60# Locate line numbers in basics.c.
61set line_callee4_head [gdb_get_line_number "callee4 ("]
62set line_callee4_body [expr $line_callee4_head + 2]
63set line_callee3_head [gdb_get_line_number "callee3 ("]
64set line_callee3_body [expr $line_callee3_head + 2]
65set line_callee3_close [expr $line_callee3_head + 3]
66set line_callee2_head [gdb_get_line_number "callee2 ("]
67set line_callee2_body [expr $line_callee2_head + 2]
68set line_callee2_close [expr $line_callee2_head + 3]
69set line_callee1_head [gdb_get_line_number "callee1 ("]
70set line_callee1_body [expr $line_callee1_head + 2]
71set line_callee1_close [expr $line_callee1_head + 3]
72set line_callme_head [gdb_get_line_number "callme"]
73set line_callme_body [expr $line_callme_head + 2]
74set line_main_head [gdb_get_line_number "main ("]
75set line_main_body [expr $line_main_head + 2]
76set line_main_hello [gdb_get_line_number "Hello, World!"]
77set line_main_callme_1 [gdb_get_line_number "callme (1"]
78
79# Forward execute to the callme() function, so that we can
80# execute backward from there.
81mi_continue_to callme
82mi_delete_breakpoints
83
84proc test_controlled_execution_reverse {} {
85 global mi_gdb_prompt
86 global srcfile
87 global hex
88
89 global line_callee4_head line_callee4_body
90 global line_callee3_head line_callee3_body line_callee3_close
91 global line_callee2_head line_callee2_body line_callee2_close
92 global line_callee1_head line_callee1_body line_callee1_close
93 global line_main_head line_main_body
94 global line_main_hello line_main_callme_1
95
96 # Test exec-reverse-finish
97
98 mi_execute_to "exec-finish --reverse" \
99 "end-stepping-range" "main" "" \
100 "basics.c" $line_main_callme_1 "" \
101 "reverse finish from callme"
102
103 # Test exec-reverse-next
104 # It takes two steps to get back to the previous line,
105 # as the first step moves us to the start of the current line,
106 # and the one after that moves back to the previous line.
107
108 mi_execute_to "exec-next --reverse 2" \
109 "end-stepping-range" "main" "" \
110 "basics.c" $line_main_hello "" \
111 "reverse next to get over the call to do_nothing"
112
113 # Test exec-reverse-step
114
115 mi_execute_to "exec-step --reverse" \
116 "end-stepping-range" "callee1" \
117 "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}" \
118 "basics.c" $line_callee1_close "" \
119 "reverse step to callee1"
120
121 mi_execute_to "exec-step --reverse" \
122 "end-stepping-range" "callee2" \
123 "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
124 "basics.c" $line_callee2_close "" \
125 "reverse step to callee2"
126
127 mi_execute_to "exec-step --reverse" \
128 "end-stepping-range" "callee3" \
129 "\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
130 "basics.c" $line_callee3_close "" \
131 "reverse step to callee3"
132
133 mi_execute_to "exec-step --reverse" \
134 "end-stepping-range" "callee4" "" \
135 "basics.c" "\[0-9\]+" "" \
136 "reverse step to callee4"
137
138 # Test exec-reverse-[step|next]-instruction
139
140 mi_execute_to "exec-step-instruction --reverse" \
141 "end-stepping-range" "callee4" "" \
142 "basics.c" "\[0-9\]+" "" \
143 "reverse-step-instruction at callee4"
144
145 mi_execute_to "exec-next-instruction --reverse" \
146 "end-stepping-range" "callee4" "" \
147 "basics.c" "\[0-9\]+" "" \
148 "reverse-next-instruction at callee4"
149
150 # Test exec-reverse-continue
151
152 mi_create_breakpoint "-t basics.c:$line_callee3_head" \
153 3 del callee3 ".*basics.c" $line_callee3_head $hex \
154 "insert temp breakpoint at basics.c:$line_callee3_head"
155
156 mi_execute_to "exec-continue --reverse" \
157 "breakpoint-hit" "callee3" \
158 "\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \
159 "basics.c" "\[0-9\]+" \
160 { "" "disp=\"del\""} \
161 "reverse-continue at callee3"
162
163 mi_execute_to "exec-continue --reverse" \
164 "" "main" "" \
165 "basics.c" $line_main_body "" \
166 "reverse-continue at main"
167}
168
169test_controlled_execution_reverse
170
171mi_gdb_exit
172return 0
This page took 0.053305 seconds and 4 git commands to generate.