]>
Commit | Line | Data |
---|---|---|
6aba47ca DJ |
1 | # Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2007 |
2 | # Free Software Foundation, Inc. | |
2fcf52f0 AC |
3 | # |
4 | # This Program Is Free software; you can redistribute it and/or modify | |
5 | # it under the terms of the GNU General Public License as published by | |
6 | # the Free Software Foundation; either version 2 of the License, or | |
7 | # (at your option) any later version. | |
8 | # | |
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. | |
13 | # | |
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
2fcf52f0 AC |
18 | # Test essential Machine interface (MI) operations |
19 | # | |
20 | # Verify that, using the MI, we can create, update, delete variables. | |
21 | # | |
22 | ||
23 | ||
24 | load_lib mi-support.exp | |
25 | set MIFLAGS "-i=mi2" | |
26 | ||
27 | gdb_exit | |
28 | if [mi_gdb_start] { | |
29 | continue | |
30 | } | |
31 | ||
32 | set testfile "var-cmd" | |
33 | set srcfile ${testfile}.c | |
34 | set binfile ${objdir}/${subdir}/${testfile} | |
35 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } { | |
b60f0898 JB |
36 | untested mi2-var-block.exp |
37 | return -1 | |
2fcf52f0 AC |
38 | } |
39 | ||
40 | mi_delete_breakpoints | |
41 | mi_gdb_reinitialize_dir $srcdir/$subdir | |
42 | mi_gdb_load ${binfile} | |
43 | ||
44 | mi_runto do_block_tests | |
45 | ||
46 | # Test: c_variable-3.2 | |
47 | # Desc: create cb and foo | |
48 | mi_gdb_test "-var-create cb * cb" \ | |
49 | "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \ | |
50 | "create local variable cb" | |
51 | ||
52 | mi_gdb_test "-var-create foo * foo" \ | |
53 | "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \ | |
54 | "create local variable foo" | |
55 | ||
56 | # step to "foo = 123;" | |
469aff8e MC |
57 | mi_step_to "do_block_tests" "" "var-cmd.c" \ |
58 | [gdb_get_line_number "foo = 123;"] \ | |
59 | "step at do_block_test" | |
2fcf52f0 AC |
60 | |
61 | ||
62 | # Be paranoid and assume 3.2 created foo | |
63 | mi_gdb_test "-var-delete foo" \ | |
64 | "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \ | |
65 | "delete var foo" | |
66 | ||
67 | ||
68 | # Test: c_variable-3.3 | |
69 | # Desc: create foo | |
70 | mi_gdb_test "-var-create foo * foo" \ | |
71 | "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \ | |
72 | "create local variable foo" | |
73 | ||
74 | # step to "foo2 = 123;" | |
469aff8e MC |
75 | mi_step_to "do_block_tests" "" "var-cmd.c" \ |
76 | [gdb_get_line_number "foo2 = 123;"] \ | |
77 | "step at do_block_test" | |
2fcf52f0 AC |
78 | |
79 | # Test: c_variable-3.4 | |
80 | # Desc: check foo, cb changed | |
81 | mi_gdb_test "-var-update *" \ | |
82 | "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \ | |
83 | "update all vars: cb foo changed" | |
84 | ||
85 | # step to "foo = 321;" | |
469aff8e MC |
86 | mi_step_to "do_block_tests" "" "var-cmd.c" \ |
87 | [gdb_get_line_number "foo = 321;"] \ | |
88 | "step at do_block_test" | |
2fcf52f0 AC |
89 | |
90 | # Test: c_variable-3.5 | |
91 | # Desc: create inner block foo | |
92 | mi_gdb_test "-var-create inner_foo * foo" \ | |
93 | "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \ | |
94 | "create local variable inner_foo" | |
95 | ||
96 | # step to "foo2 = 0;" | |
469aff8e MC |
97 | mi_step_to "do_block_tests" "" "var-cmd.c" \ |
98 | [gdb_get_line_number "foo2 = 0;"] \ | |
99 | "step at do_block_test" | |
2fcf52f0 AC |
100 | |
101 | # Test: c_variable-3.6 | |
102 | # Desc: create foo2 | |
103 | mi_gdb_test "-var-create foo2 * foo2" \ | |
104 | "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \ | |
105 | "create local variable foo2" | |
106 | ||
107 | # Test: c_variable-3.7 | |
108 | # Desc: check that outer foo in scope and inner foo out of scope | |
109 | # Note: also a known gdb problem | |
110 | setup_xfail *-*-* | |
111 | mi_gdb_test "-var-update inner_foo" \ | |
112 | "\\^done,changelist=\{FIXME\}" \ | |
113 | "update inner_foo: should be out of scope: KNOWN PROBLEM" | |
114 | clear_xfail *-*-* | |
115 | ||
116 | setup_xfail *-*-* | |
117 | mi_gdb_test "-var-evaluate-expression inner_foo" \ | |
118 | "\\^done,value=\{FIXME\}" \ | |
119 | "evaluate inner_foo: should be out of scope: KNOWN PROBLEM" | |
120 | clear_xfail *-*-* | |
121 | ||
122 | mi_gdb_test "-var-update foo" \ | |
123 | "\\^done,changelist=\\\[\\\]" \ | |
124 | "update foo: did not change" | |
125 | ||
126 | mi_gdb_test "-var-delete inner_foo" \ | |
127 | "\\^done,ndeleted=\"1\"" \ | |
128 | "delete var inner_foo" | |
129 | ||
130 | # step to "foo = 0;" | |
469aff8e MC |
131 | mi_step_to "do_block_tests" "" "var-cmd.c" \ |
132 | [gdb_get_line_number "foo = 0;"] \ | |
133 | "step at do_block_test" | |
2fcf52f0 AC |
134 | |
135 | # Test: c_variable-3.8 | |
136 | # Desc: check that foo2 out of scope (known gdb problem) | |
137 | setup_xfail *-*-* | |
138 | mi_gdb_test "-var-update foo2" \ | |
139 | "\\^done,changelist=\{FIXME\}" \ | |
140 | "update foo2: should be out of scope: KNOWN PROBLEM" | |
141 | clear_xfail *-*-* | |
142 | ||
143 | # step to "cb = 21;" | |
469aff8e MC |
144 | mi_step_to "do_block_tests" "" "var-cmd.c" \ |
145 | [gdb_get_line_number "cb = 21;"] \ | |
146 | "step at do_block_test" | |
2fcf52f0 AC |
147 | |
148 | # Test: c_variable-3.9 | |
149 | # Desc: check that only cb is in scope (known gdb problem) | |
150 | setup_xfail *-*-* | |
151 | mi_gdb_test "-var-update foo2" \ | |
152 | "\\^done,changelist=\\\[FIXME\\\]" \ | |
153 | "update foo2 should be out of scope: KNOWN PROBLEM" | |
154 | clear_xfail *-*-* | |
155 | setup_xfail *-*-* | |
156 | mi_gdb_test "-var-update foo" \ | |
157 | "\\^done,changelist=\{FIXME\}" \ | |
158 | "update foo should be out of scope: KNOWN PROBLEM" | |
159 | clear_xfail *-*-* | |
160 | mi_gdb_test "-var-update cb" \ | |
161 | "\\^done,changelist=\\\[\\\]" \ | |
162 | "update cb" | |
163 | ||
164 | # Test: c_variable-3.10 | |
165 | # Desc: names of editable variables | |
166 | #gdbtk_test c_variable-3.10 {names of editable variables} { | |
167 | # editable_variables | |
168 | #} {{foo cb foo2} {}} | |
169 | ||
170 | # Done with block tests | |
171 | mi_gdb_test "-var-delete foo" \ | |
172 | "\\^done,ndeleted=\"1\"" \ | |
173 | "delete var foo" | |
174 | ||
175 | mi_gdb_test "-var-delete foo2" \ | |
176 | "\\^done,ndeleted=\"1\"" \ | |
177 | "delete var foo2" | |
178 | ||
179 | mi_gdb_test "-var-delete cb" \ | |
180 | "\\^done,ndeleted=\"1\"" \ | |
181 | "delete var cb" | |
182 | ||
183 | mi_gdb_exit | |
184 | return 0 |