Imported Upstream version 7.8
[platform/upstream/gdb.git] / gdb / testsuite / gdb.mi / mi-var-block.exp
1 # Copyright 1999-2014 Free Software Foundation, Inc.
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 3 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, see <http://www.gnu.org/licenses/>.
15
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
23 set MIFLAGS "-i=mi"
24
25 gdb_exit
26 if [mi_gdb_start] {
27     continue
28 }
29
30 standard_testfile var-cmd.c
31
32 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
33     untested mi-var-block.exp
34     return -1
35 }
36
37 mi_delete_breakpoints
38 mi_gdb_reinitialize_dir $srcdir/$subdir
39 mi_gdb_load ${binfile}
40
41 mi_runto do_block_tests
42
43 # Test: c_variable-3.2
44 # Desc: create cb and foo
45 mi_create_varobj "cb" "cb" "create local variable cb"
46
47 mi_gdb_test "-var-create foo * foo" \
48        "\\^error,msg=\"-var-create: unable to create variable object\"" \
49        "try to create local variable foo"
50
51 # step to "foo = 123;"
52 mi_step_to "do_block_tests" "" "var-cmd.c" \
53     [gdb_get_line_number "foo = 123;"] \
54     "step at do_block_test 1"
55
56
57 # Be paranoid and assume 3.2 created foo
58 mi_gdb_test "-var-delete foo" \
59         "\\^error,msg=\"Variable object not found\"" \
60         "delete var foo 1"
61
62
63 # Test: c_variable-3.3
64 # Desc: create foo
65 mi_create_varobj "foo" "foo" "create local variable foo"
66
67 # step to "foo2 = 123;"
68 mi_step_to "do_block_tests" "" "var-cmd.c" \
69     [gdb_get_line_number "foo2 = 123;"] \
70     "step at do_block_test 2"
71
72 # Test: c_variable-3.4
73 # Desc: check foo, cb changed
74 mi_gdb_test "-var-update *" \
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\"\}\\\]" \
76         "update all vars: cb foo changed"
77
78 # step to "foo = 321;"
79 mi_step_to "do_block_tests" "" "var-cmd.c" \
80     [gdb_get_line_number "foo = 321;"] \
81     "step at do_block_test 3"
82
83 # Test: c_variable-3.5
84 # Desc: create inner block foo
85 mi_create_varobj "inner_foo" "foo" "create local variable inner_foo"
86
87 # step to "foo2 = 0;"
88 mi_step_to "do_block_tests" "" "var-cmd.c" \
89     [gdb_get_line_number "foo2 = 0;"] \
90     "step at do_block_test 4"
91
92 # Test: c_variable-3.6
93 # Desc: create foo2
94 mi_create_varobj "foo2" "foo2" "create local variable foo2"
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" \
112         "\\^done,changelist=\\\[\\\]" \
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;"
120 mi_step_to "do_block_tests" "" "var-cmd.c" \
121     [gdb_get_line_number "foo = 0;"] \
122     "step at do_block_test 5"
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;"
133 mi_step_to "do_block_tests" "" "var-cmd.c" \
134     [gdb_get_line_number "cb = 21;"] \
135     "step at do_block_test 6"
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" \
141         "\\^done,changelist=\\\[FIXME\\\]" \
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" \
150         "\\^done,changelist=\\\[\\\]" \
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\"" \
162         "delete var foo 2"
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