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