gdb/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-block.exp
CommitLineData
9b254dd1
DJ
1# Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008
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
23load_lib mi-support.exp
b30bf9ee 24set MIFLAGS "-i=mi"
fb40c209
AC
25
26gdb_exit
27if [mi_gdb_start] {
28 continue
29}
30
31set testfile "var-cmd"
32set srcfile ${testfile}.c
33set binfile ${objdir}/${subdir}/${testfile}
34if { [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
39mi_delete_breakpoints
40mi_gdb_reinitialize_dir $srcdir/$subdir
41mi_gdb_load ${binfile}
42
6afa27b0 43mi_runto do_block_tests
fb40c209
AC
44
45# Test: c_variable-3.2
46# Desc: create cb and foo
9e8e3afe 47mi_create_varobj "cb" "cb" "create local variable cb"
fb40c209
AC
48
49mi_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
54mi_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
60mi_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 67mi_create_varobj "foo" "foo" "create local variable foo"
fb40c209
AC
68
69# step to "foo2 = 123;"
469aff8e
MC
70mi_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
76mi_gdb_test "-var-update *" \
93cae4bf 77 "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
fb40c209
AC
78 "update all vars: cb foo changed"
79
80# step to "foo = 321;"
469aff8e
MC
81mi_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 87mi_create_varobj "inner_foo" "foo" "create local variable inner_foo"
fb40c209
AC
88
89# step to "foo2 = 0;"
469aff8e
MC
90mi_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 96mi_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
101setup_xfail *-*-*
102mi_gdb_test "-var-update inner_foo" \
103 "\\^done,changelist=\{FIXME\}" \
104 "update inner_foo: should be out of scope: KNOWN PROBLEM"
105clear_xfail *-*-*
106
107setup_xfail *-*-*
108mi_gdb_test "-var-evaluate-expression inner_foo" \
109 "\\^done,value=\{FIXME\}" \
110 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
111clear_xfail *-*-*
112
113mi_gdb_test "-var-update foo" \
93cae4bf 114 "\\^done,changelist=\\\[\\\]" \
fb40c209
AC
115 "update foo: did not change"
116
117mi_gdb_test "-var-delete inner_foo" \
118 "\\^done,ndeleted=\"1\"" \
119 "delete var inner_foo"
120
121# step to "foo = 0;"
469aff8e
MC
122mi_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)
128setup_xfail *-*-*
129mi_gdb_test "-var-update foo2" \
130 "\\^done,changelist=\{FIXME\}" \
131 "update foo2: should be out of scope: KNOWN PROBLEM"
132clear_xfail *-*-*
133
134# step to "cb = 21;"
469aff8e
MC
135mi_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)
141setup_xfail *-*-*
142mi_gdb_test "-var-update foo2" \
93cae4bf 143 "\\^done,changelist=\\\[FIXME\\\]" \
fb40c209
AC
144 "update foo2 should be out of scope: KNOWN PROBLEM"
145clear_xfail *-*-*
146setup_xfail *-*-*
147mi_gdb_test "-var-update foo" \
148 "\\^done,changelist=\{FIXME\}" \
149 "update foo should be out of scope: KNOWN PROBLEM"
150clear_xfail *-*-*
151mi_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
162mi_gdb_test "-var-delete foo" \
163 "\\^done,ndeleted=\"1\"" \
164 "delete var foo"
165
166mi_gdb_test "-var-delete foo2" \
167 "\\^done,ndeleted=\"1\"" \
168 "delete var foo2"
169
170mi_gdb_test "-var-delete cb" \
171 "\\^done,ndeleted=\"1\"" \
172 "delete var cb"
173
174mi_gdb_exit
175return 0
This page took 0.730849 seconds and 4 git commands to generate.