Commit | Line | Data |
---|---|---|
fb40c209 AC |
1 | # Copyright (C) 1999 2000 s Solutions |
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 2 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, write to the Free Software | |
15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
16 | ||
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-gdb@prep.ai.mit.edu | |
19 | ||
20 | # Test essential Machine interface (MI) operations | |
21 | # | |
22 | # Verify that, using the MI, we can create, update, delete variables. | |
23 | # | |
24 | ||
25 | ||
26 | load_lib mi-support.exp | |
b30bf9ee | 27 | set MIFLAGS "-i=mi" |
fb40c209 AC |
28 | |
29 | gdb_exit | |
30 | if [mi_gdb_start] { | |
31 | continue | |
32 | } | |
33 | ||
34 | set testfile "var-cmd" | |
35 | set srcfile ${testfile}.c | |
36 | set binfile ${objdir}/${subdir}/${testfile} | |
37 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
38 | gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." | |
39 | } | |
40 | ||
41 | mi_delete_breakpoints | |
42 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
43 | mi_gdb_load ${binfile} | |
44 | ||
45 | mi_gdb_test "200-break-insert do_block_tests" \ | |
46 | "200\\^done,bkpt=\{number=\"1\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"do_block_tests\",file=\".*var-cmd.c\",line=\"154\",times=\"0\"\}" \ | |
47 | "break-insert operation" | |
48 | ||
49 | mi_run_cmd | |
50 | # The running part has been checked already by mi_run_cmd | |
51 | gdb_expect { | |
68c81b54 | 52 | -re "\[\r\n\]*000\\*stopped,reason=\"breakpoint-hit\",bkptno=\"1\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"154\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
53 | pass "run to do_block_tests" |
54 | } | |
55 | -re ".*$mi_gdb_prompt$" {fail "run to do_block_tests (2)"} | |
56 | timeout {fail "run to do_block_tests (timeout 2)"} | |
57 | } | |
58 | ||
59 | # Test: c_variable-3.2 | |
60 | # Desc: create cb and foo | |
61 | mi_gdb_test "-var-create cb * cb" \ | |
62 | "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \ | |
63 | "create local variable cb" | |
64 | ||
65 | mi_gdb_test "-var-create foo * foo" \ | |
73a93a32 | 66 | "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ |
fb40c209 AC |
67 | "create local variable foo" |
68 | ||
69 | # step to "foo = 123;" | |
70 | send_gdb "-exec-step\n" | |
71 | gdb_expect { | |
68c81b54 | 72 | -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"158\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
73 | pass "step at do_block_tests" |
74 | } | |
75 | timeout { | |
76 | fail "step at do_block_tests (timeout)" | |
77 | } | |
78 | } | |
79 | ||
80 | ||
81 | # Be paranoid and assume 3.2 created foo | |
82 | mi_gdb_test "-var-delete foo" \ | |
83 | "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \ | |
84 | "delete var foo" | |
85 | ||
86 | ||
87 | # Test: c_variable-3.3 | |
88 | # Desc: create foo | |
89 | mi_gdb_test "-var-create foo * foo" \ | |
90 | "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \ | |
91 | "create local variable foo" | |
92 | ||
93 | # step to "foo2 = 123;" | |
94 | send_gdb "-exec-step\n" | |
95 | gdb_expect { | |
68c81b54 | 96 | -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"161\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
97 | pass "step at do_block_tests" |
98 | } | |
99 | timeout { | |
100 | fail "step at do_block_tests (timeout)" | |
101 | } | |
102 | } | |
103 | ||
104 | # Test: c_variable-3.4 | |
105 | # Desc: check foo, cb changed | |
106 | mi_gdb_test "-var-update *" \ | |
73a93a32 | 107 | "\\^done,changelist=\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}" \ |
fb40c209 AC |
108 | "update all vars: cb foo changed" |
109 | ||
110 | # step to "foo = 321;" | |
111 | send_gdb "-exec-step\n" | |
112 | gdb_expect { | |
68c81b54 | 113 | -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"164\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
114 | pass "step at do_block_tests" |
115 | } | |
116 | timeout { | |
117 | fail "step at do_block_tests (timeout)" | |
118 | } | |
119 | } | |
120 | ||
121 | # Test: c_variable-3.5 | |
122 | # Desc: create inner block foo | |
123 | mi_gdb_test "-var-create inner_foo * foo" \ | |
124 | "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \ | |
125 | "create local variable inner_foo" | |
126 | ||
127 | # step to "foo2 = 0;" | |
128 | send_gdb "-exec-step\n" | |
129 | gdb_expect { | |
68c81b54 | 130 | -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"166\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
131 | pass "step at do_block_tests" |
132 | } | |
133 | timeout { fail "step at do_block_tests (timeout)" } | |
134 | } | |
135 | ||
136 | # Test: c_variable-3.6 | |
137 | # Desc: create foo2 | |
138 | mi_gdb_test "-var-create foo2 * foo2" \ | |
139 | "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \ | |
140 | "create local variable foo2" | |
141 | ||
142 | # Test: c_variable-3.7 | |
143 | # Desc: check that outer foo in scope and inner foo out of scope | |
144 | # Note: also a known gdb problem | |
145 | setup_xfail *-*-* | |
146 | mi_gdb_test "-var-update inner_foo" \ | |
147 | "\\^done,changelist=\{FIXME\}" \ | |
148 | "update inner_foo: should be out of scope: KNOWN PROBLEM" | |
149 | clear_xfail *-*-* | |
150 | ||
151 | setup_xfail *-*-* | |
152 | mi_gdb_test "-var-evaluate-expression inner_foo" \ | |
153 | "\\^done,value=\{FIXME\}" \ | |
154 | "evaluate inner_foo: should be out of scope: KNOWN PROBLEM" | |
155 | clear_xfail *-*-* | |
156 | ||
157 | mi_gdb_test "-var-update foo" \ | |
158 | "\\^done,changelist=\{\}" \ | |
159 | "update foo: did not change" | |
160 | ||
161 | mi_gdb_test "-var-delete inner_foo" \ | |
162 | "\\^done,ndeleted=\"1\"" \ | |
163 | "delete var inner_foo" | |
164 | ||
165 | # step to "foo = 0;" | |
166 | send_gdb "-exec-step\n" | |
167 | gdb_expect { | |
68c81b54 | 168 | -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"168\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
169 | pass "step at do_block_tests" |
170 | } | |
171 | timeout { fail "step at do_block_tests (timeout)" } | |
172 | } | |
173 | ||
174 | # Test: c_variable-3.8 | |
175 | # Desc: check that foo2 out of scope (known gdb problem) | |
176 | setup_xfail *-*-* | |
177 | mi_gdb_test "-var-update foo2" \ | |
178 | "\\^done,changelist=\{FIXME\}" \ | |
179 | "update foo2: should be out of scope: KNOWN PROBLEM" | |
180 | clear_xfail *-*-* | |
181 | ||
182 | # step to "cb = 21;" | |
183 | send_gdb "-exec-step\n" | |
184 | gdb_expect { | |
68c81b54 | 185 | -re "\\^running\r\n${mi_gdb_prompt}\\*stopped,reason=\"end-stepping-range\",thread-id=\"0\",frame=\{addr=\"$hex\",func=\"do_block_tests\",args=\\\[\\\],file=\".*var-cmd.c\",line=\"171\"\}\r\n$mi_gdb_prompt$" { |
fb40c209 AC |
186 | pass "step at do_block_tests" |
187 | } | |
188 | timeout { fail "step at do_block_tests (timeout)" } | |
189 | } | |
190 | ||
191 | ||
192 | # Test: c_variable-3.9 | |
193 | # Desc: check that only cb is in scope (known gdb problem) | |
194 | setup_xfail *-*-* | |
195 | mi_gdb_test "-var-update foo2" \ | |
196 | "\\^done,changelist=\{FIXME\}" \ | |
197 | "update foo2 should be out of scope: KNOWN PROBLEM" | |
198 | clear_xfail *-*-* | |
199 | setup_xfail *-*-* | |
200 | mi_gdb_test "-var-update foo" \ | |
201 | "\\^done,changelist=\{FIXME\}" \ | |
202 | "update foo should be out of scope: KNOWN PROBLEM" | |
203 | clear_xfail *-*-* | |
204 | mi_gdb_test "-var-update cb" \ | |
205 | "\\^done,changelist=\{\}" \ | |
206 | "update cb" | |
207 | ||
208 | # Test: c_variable-3.10 | |
209 | # Desc: names of editable variables | |
210 | #gdbtk_test c_variable-3.10 {names of editable variables} { | |
211 | # editable_variables | |
212 | #} {{foo cb foo2} {}} | |
213 | ||
214 | # Done with block tests | |
215 | mi_gdb_test "-var-delete foo" \ | |
216 | "\\^done,ndeleted=\"1\"" \ | |
217 | "delete var foo" | |
218 | ||
219 | mi_gdb_test "-var-delete foo2" \ | |
220 | "\\^done,ndeleted=\"1\"" \ | |
221 | "delete var foo2" | |
222 | ||
223 | mi_gdb_test "-var-delete cb" \ | |
224 | "\\^done,ndeleted=\"1\"" \ | |
225 | "delete var cb" | |
226 | ||
227 | mi_gdb_exit | |
228 | return 0 |