Commit | Line | Data |
---|---|---|
fa19b4e5 MS |
1 | # Copyright 2009\r |
2 | # Free Software Foundation, Inc.\r | |
3 | \r | |
4 | # This program is free software; you can redistribute it and/or modify\r | |
5 | # it under the terms of the GNU General Public License as published by\r | |
6 | # the Free Software Foundation; either version 3 of the License, or\r | |
7 | # (at your option) any later version.\r | |
8 | #\r | |
9 | # This program is distributed in the hope that it will be useful,\r | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of\r | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r | |
12 | # GNU General Public License for more details.\r | |
13 | #\r | |
14 | # You should have received a copy of the GNU General Public License\r | |
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>.\r | |
16 | \r | |
17 | # Test Machine interface (MI) operations\r | |
18 | # Verify that, using the MI, we can run a simple program in both forward\r | |
19 | # and reverse directions with the following execution commands:\r | |
20 | # - exec-continue\r | |
21 | # - exec-finish\r | |
22 | # - exec-next\r | |
23 | # - exec-step\r | |
24 | # - exec-next-instruction\r | |
25 | # - exec-step-instruction\r | |
26 | \r | |
27 | # The goal is not to test gdb functionality, which is done by other tests,\r | |
28 | # but to verify the correct output response to MI operations.\r | |
29 | #\r | |
30 | \r | |
31 | if ![target_info exists gdb,can_reverse] {\r | |
32 | return\r | |
33 | }\r | |
34 | \r | |
35 | load_lib mi-support.exp\r | |
36 | set MIFLAGS "-i=mi"\r | |
37 | \r | |
38 | gdb_exit\r | |
39 | if [mi_gdb_start] {\r | |
40 | continue\r | |
41 | }\r | |
42 | \r | |
43 | set testfile "basics"\r | |
44 | set srcfile ${testfile}.c\r | |
45 | set binfile ${objdir}/${subdir}/mi2-reverse\r | |
46 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {\r | |
47 | untested mi2-reverse.exp\r | |
48 | return -1\r | |
49 | }\r | |
50 | \r | |
51 | mi_run_to_main\r | |
52 | \r | |
53 | if [target_info exists gdb,use_precord] {\r | |
54 | # Activate process record/replay\r | |
55 | if [mi_gdb_test "-interpreter-exec console record" \\r | |
56 | {\^done} "Turn on process record"] {\r | |
57 | warning "Fail to activate process record/replay, tests in this group will not be performed.\n";\r | |
58 | return -1\r | |
59 | }\r | |
60 | }\r | |
61 | \r | |
62 | # Locate line numbers in basics.c.\r | |
63 | set line_callee4_head [gdb_get_line_number "callee4 ("]\r | |
64 | set line_callee4_body [expr $line_callee4_head + 2]\r | |
65 | set line_callee3_head [gdb_get_line_number "callee3 ("]\r | |
66 | set line_callee3_body [expr $line_callee3_head + 2]\r | |
67 | set line_callee3_close [expr $line_callee3_head + 3]\r | |
68 | set line_callee2_head [gdb_get_line_number "callee2 ("]\r | |
69 | set line_callee2_body [expr $line_callee2_head + 2]\r | |
70 | set line_callee2_close [expr $line_callee2_head + 3]\r | |
71 | set line_callee1_head [gdb_get_line_number "callee1 ("]\r | |
72 | set line_callee1_body [expr $line_callee1_head + 2]\r | |
73 | set line_callee1_close [expr $line_callee1_head + 3]\r | |
74 | set line_callme_head [gdb_get_line_number "callme"]\r | |
75 | set line_callme_body [expr $line_callme_head + 2]\r | |
76 | set line_main_head [gdb_get_line_number "main ("]\r | |
77 | set line_main_body [expr $line_main_head + 2]\r | |
78 | set line_main_hello [gdb_get_line_number "Hello, World!"]\r | |
79 | set line_main_callme_1 [gdb_get_line_number "callme (1"]\r | |
80 | \r | |
81 | # Forward execute to the callme() function, so that we can\r | |
82 | # execute backward from there.\r | |
83 | mi_continue_to callme\r | |
84 | mi_delete_breakpoints\r | |
85 | \r | |
86 | proc test_controlled_execution_reverse {} {\r | |
87 | global mi_gdb_prompt\r | |
88 | global srcfile\r | |
89 | global hex\r | |
90 | \r | |
91 | global line_callee4_head line_callee4_body\r | |
92 | global line_callee3_head line_callee3_body line_callee3_close\r | |
93 | global line_callee2_head line_callee2_body line_callee2_close\r | |
94 | global line_callee1_head line_callee1_body line_callee1_close\r | |
95 | global line_main_head line_main_body\r | |
96 | global line_main_hello line_main_callme_1\r | |
97 | \r | |
98 | # Test exec-reverse-finish\r | |
99 | \r | |
100 | mi_execute_to "exec-finish --reverse" \\r | |
101 | "end-stepping-range" "main" "" \\r | |
102 | "basics.c" $line_main_callme_1 "" \\r | |
103 | "reverse finish from callme"\r | |
104 | \r | |
105 | # Test exec-reverse-next\r | |
106 | # It takes two steps to get back to the previous line,\r | |
107 | # as the first step moves us to the start of the current line,\r | |
108 | # and the one after that moves back to the previous line.\r | |
109 | \r | |
110 | mi_execute_to "exec-next --reverse 2" \\r | |
111 | "end-stepping-range" "main" "" \\r | |
112 | "basics.c" $line_main_hello "" \\r | |
113 | "reverse next to get over the call to do_nothing"\r | |
114 | \r | |
115 | # Test exec-reverse-step\r | |
116 | \r | |
117 | mi_execute_to "exec-step --reverse" \\r | |
118 | "end-stepping-range" "callee1" \\r | |
119 | "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\},\{name=\"fltarg\",value=\"3.5\"\}" \\r | |
120 | "basics.c" $line_callee1_close "" \\r | |
121 | "reverse step to callee1"\r | |
122 | \r | |
123 | mi_execute_to "exec-step --reverse" \\r | |
124 | "end-stepping-range" "callee2" \\r | |
125 | "\{name=\"intarg\",value=\"2\"\},\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \\r | |
126 | "basics.c" $line_callee2_close "" \\r | |
127 | "reverse step to callee2"\r | |
128 | \r | |
129 | mi_execute_to "exec-step --reverse" \\r | |
130 | "end-stepping-range" "callee3" \\r | |
131 | "\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \\r | |
132 | "basics.c" $line_callee3_close "" \\r | |
133 | "reverse step to callee3"\r | |
134 | \r | |
135 | mi_execute_to "exec-step --reverse" \\r | |
136 | "end-stepping-range" "callee4" "" \\r | |
137 | "basics.c" "\[0-9\]+" "" \\r | |
138 | "reverse step to callee4"\r | |
139 | \r | |
140 | # Test exec-reverse-[step|next]-instruction\r | |
141 | \r | |
142 | mi_execute_to "exec-step-instruction --reverse" \\r | |
143 | "end-stepping-range" "callee4" "" \\r | |
144 | "basics.c" "\[0-9\]+" "" \\r | |
145 | "reverse-step-instruction at callee4"\r | |
146 | \r | |
147 | mi_execute_to "exec-next-instruction --reverse" \\r | |
148 | "end-stepping-range" "callee4" "" \\r | |
149 | "basics.c" "\[0-9\]+" "" \\r | |
150 | "reverse-next-instruction at callee4"\r | |
151 | \r | |
152 | # Test exec-reverse-continue\r | |
153 | \r | |
154 | mi_create_breakpoint "-t basics.c:$line_callee3_head" \\r | |
155 | 3 del callee3 ".*basics.c" $line_callee3_head $hex \\r | |
156 | "insert temp breakpoint at basics.c:$line_callee3_head"\r | |
157 | \r | |
158 | mi_execute_to "exec-continue --reverse" \\r | |
159 | "breakpoint-hit" "callee3" \\r | |
160 | "\{name=\"strarg\",value=\"$hex \\\\\"A string argument\.\\\\\"\"\}" \\r | |
161 | "basics.c" "\[0-9\]+" \\r | |
162 | { "" "disp=\"del\""} \\r | |
163 | "reverse-continue at callee3"\r | |
164 | \r | |
165 | mi_execute_to "exec-continue --reverse" \\r | |
166 | "" "main" "" \\r | |
167 | "basics.c" $line_main_body "" \\r | |
168 | "reverse-continue at main"\r | |
169 | }\r | |
170 | \r | |
171 | test_controlled_execution_reverse\r | |
172 | \r | |
173 | mi_gdb_exit\r | |
174 | return 0\r |