1 # Copyright 1999, 2000, 2001, 2002, 2003, 2004, 2007
2 # Free Software Foundation, Inc.
4 # This Program Is Free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # Test essential Machine interface (MI) operations
20 # Verify that, using the MI, we can create, update, delete variables.
24 load_lib mi-support.exp
32 set testfile "var-cmd"
33 set srcfile ${testfile}.c
34 set binfile ${objdir}/${subdir}/${testfile}
35 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
36 untested mi2-var-block.exp
41 mi_gdb_reinitialize_dir $srcdir/$subdir
42 mi_gdb_load ${binfile}
44 mi_runto do_block_tests
46 # Test: c_variable-3.2
47 # Desc: create cb and foo
48 mi_create_varobj cb cb "create local variable cb"
50 mi_gdb_test "-var-create foo * foo" \
51 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
52 "create local variable foo"
54 # step to "foo = 123;"
55 mi_step_to "do_block_tests" "" "var-cmd.c" \
56 [gdb_get_line_number "foo = 123;"] \
57 "step at do_block_test"
60 # Be paranoid and assume 3.2 created foo
61 mi_gdb_test "-var-delete foo" \
62 "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \
66 # Test: c_variable-3.3
68 mi_create_varobj foo foo "create local variable foo"
70 # step to "foo2 = 123;"
71 mi_step_to "do_block_tests" "" "var-cmd.c" \
72 [gdb_get_line_number "foo2 = 123;"] \
73 "step at do_block_test"
75 # Test: c_variable-3.4
76 # Desc: check foo, cb changed
77 mi_gdb_test "-var-update *" \
78 "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
79 "update all vars: cb foo changed"
81 # step to "foo = 321;"
82 mi_step_to "do_block_tests" "" "var-cmd.c" \
83 [gdb_get_line_number "foo = 321;"] \
84 "step at do_block_test"
86 # Test: c_variable-3.5
87 # Desc: create inner block foo
88 mi_create_varobj inner_foo foo "create local variable inner_foo"
91 mi_step_to "do_block_tests" "" "var-cmd.c" \
92 [gdb_get_line_number "foo2 = 0;"] \
93 "step at do_block_test"
95 # Test: c_variable-3.6
97 mi_create_varobj foo2 foo2 "create local variable foo2"
99 # Test: c_variable-3.7
100 # Desc: check that outer foo in scope and inner foo out of scope
101 # Note: also a known gdb problem
103 mi_gdb_test "-var-update inner_foo" \
104 "\\^done,changelist=\{FIXME\}" \
105 "update inner_foo: should be out of scope: KNOWN PROBLEM"
109 mi_gdb_test "-var-evaluate-expression inner_foo" \
110 "\\^done,value=\{FIXME\}" \
111 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
114 mi_gdb_test "-var-update foo" \
115 "\\^done,changelist=\\\[\\\]" \
116 "update foo: did not change"
118 mi_gdb_test "-var-delete inner_foo" \
119 "\\^done,ndeleted=\"1\"" \
120 "delete var inner_foo"
123 mi_step_to "do_block_tests" "" "var-cmd.c" \
124 [gdb_get_line_number "foo = 0;"] \
125 "step at do_block_test"
127 # Test: c_variable-3.8
128 # Desc: check that foo2 out of scope (known gdb problem)
130 mi_gdb_test "-var-update foo2" \
131 "\\^done,changelist=\{FIXME\}" \
132 "update foo2: should be out of scope: KNOWN PROBLEM"
136 mi_step_to "do_block_tests" "" "var-cmd.c" \
137 [gdb_get_line_number "cb = 21;"] \
138 "step at do_block_test"
140 # Test: c_variable-3.9
141 # Desc: check that only cb is in scope (known gdb problem)
143 mi_gdb_test "-var-update foo2" \
144 "\\^done,changelist=\\\[FIXME\\\]" \
145 "update foo2 should be out of scope: KNOWN PROBLEM"
148 mi_gdb_test "-var-update foo" \
149 "\\^done,changelist=\{FIXME\}" \
150 "update foo should be out of scope: KNOWN PROBLEM"
152 mi_gdb_test "-var-update cb" \
153 "\\^done,changelist=\\\[\\\]" \
156 # Test: c_variable-3.10
157 # Desc: names of editable variables
158 #gdbtk_test c_variable-3.10 {names of editable variables} {
160 #} {{foo cb foo2} {}}
162 # Done with block tests
163 mi_gdb_test "-var-delete foo" \
164 "\\^done,ndeleted=\"1\"" \
167 mi_gdb_test "-var-delete foo2" \
168 "\\^done,ndeleted=\"1\"" \
171 mi_gdb_test "-var-delete cb" \
172 "\\^done,ndeleted=\"1\"" \