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