]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.mi/mi-var-block.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.mi / mi-var-block.exp
CommitLineData
6aba47ca 1# Copyright 1999, 2000, 2001, 2002, 2004, 2007 Free Software Foundation, Inc.
fb40c209
AC
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 2 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, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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
47mi_gdb_test "-var-create cb * cb" \
48 "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \
49 "create local variable cb"
50
51mi_gdb_test "-var-create foo * foo" \
73a93a32 52 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
fb40c209
AC
53 "create local variable foo"
54
55# step to "foo = 123;"
469aff8e
MC
56mi_step_to "do_block_tests" "" "var-cmd.c" \
57 [gdb_get_line_number "foo = 123;"] \
58 "step at do_block_test"
fb40c209
AC
59
60
61# Be paranoid and assume 3.2 created foo
62mi_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
69mi_gdb_test "-var-create foo * foo" \
70 "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \
71 "create local variable foo"
72
73# step to "foo2 = 123;"
469aff8e
MC
74mi_step_to "do_block_tests" "" "var-cmd.c" \
75 [gdb_get_line_number "foo2 = 123;"] \
76 "step at do_block_test"
fb40c209
AC
77
78# Test: c_variable-3.4
79# Desc: check foo, cb changed
80mi_gdb_test "-var-update *" \
93cae4bf 81 "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
fb40c209
AC
82 "update all vars: cb foo changed"
83
84# step to "foo = 321;"
469aff8e
MC
85mi_step_to "do_block_tests" "" "var-cmd.c" \
86 [gdb_get_line_number "foo = 321;"] \
87 "step at do_block_test"
fb40c209
AC
88
89# Test: c_variable-3.5
90# Desc: create inner block foo
91mi_gdb_test "-var-create inner_foo * foo" \
92 "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \
93 "create local variable inner_foo"
94
95# step to "foo2 = 0;"
469aff8e
MC
96mi_step_to "do_block_tests" "" "var-cmd.c" \
97 [gdb_get_line_number "foo2 = 0;"] \
98 "step at do_block_test"
fb40c209
AC
99
100# Test: c_variable-3.6
101# Desc: create foo2
102mi_gdb_test "-var-create foo2 * foo2" \
103 "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \
104 "create local variable foo2"
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
109setup_xfail *-*-*
110mi_gdb_test "-var-update inner_foo" \
111 "\\^done,changelist=\{FIXME\}" \
112 "update inner_foo: should be out of scope: KNOWN PROBLEM"
113clear_xfail *-*-*
114
115setup_xfail *-*-*
116mi_gdb_test "-var-evaluate-expression inner_foo" \
117 "\\^done,value=\{FIXME\}" \
118 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
119clear_xfail *-*-*
120
121mi_gdb_test "-var-update foo" \
93cae4bf 122 "\\^done,changelist=\\\[\\\]" \
fb40c209
AC
123 "update foo: did not change"
124
125mi_gdb_test "-var-delete inner_foo" \
126 "\\^done,ndeleted=\"1\"" \
127 "delete var inner_foo"
128
129# step to "foo = 0;"
469aff8e
MC
130mi_step_to "do_block_tests" "" "var-cmd.c" \
131 [gdb_get_line_number "foo = 0;"] \
132 "step at do_block_test"
fb40c209
AC
133
134# Test: c_variable-3.8
135# Desc: check that foo2 out of scope (known gdb problem)
136setup_xfail *-*-*
137mi_gdb_test "-var-update foo2" \
138 "\\^done,changelist=\{FIXME\}" \
139 "update foo2: should be out of scope: KNOWN PROBLEM"
140clear_xfail *-*-*
141
142# step to "cb = 21;"
469aff8e
MC
143mi_step_to "do_block_tests" "" "var-cmd.c" \
144 [gdb_get_line_number "cb = 21;"] \
145 "step at do_block_test"
fb40c209
AC
146
147# Test: c_variable-3.9
148# Desc: check that only cb is in scope (known gdb problem)
149setup_xfail *-*-*
150mi_gdb_test "-var-update foo2" \
93cae4bf 151 "\\^done,changelist=\\\[FIXME\\\]" \
fb40c209
AC
152 "update foo2 should be out of scope: KNOWN PROBLEM"
153clear_xfail *-*-*
154setup_xfail *-*-*
155mi_gdb_test "-var-update foo" \
156 "\\^done,changelist=\{FIXME\}" \
157 "update foo should be out of scope: KNOWN PROBLEM"
158clear_xfail *-*-*
159mi_gdb_test "-var-update cb" \
93cae4bf 160 "\\^done,changelist=\\\[\\\]" \
fb40c209
AC
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
170mi_gdb_test "-var-delete foo" \
171 "\\^done,ndeleted=\"1\"" \
172 "delete var foo"
173
174mi_gdb_test "-var-delete foo2" \
175 "\\^done,ndeleted=\"1\"" \
176 "delete var foo2"
177
178mi_gdb_test "-var-delete cb" \
179 "\\^done,ndeleted=\"1\"" \
180 "delete var cb"
181
182mi_gdb_exit
183return 0