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