1 # Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
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.
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.
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.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # Test essential Machine interface (MI) operations
22 # Verify that, using the MI, we can create, update, delete variables.
26 load_lib mi-support.exp
34 set testfile "var-cmd"
35 set srcfile ${testfile}.c
36 set binfile ${objdir}/${subdir}/${testfile}
37 if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
38 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
42 mi_gdb_reinitialize_dir $srcdir/$subdir
43 mi_gdb_load ${binfile}
45 mi_runto do_block_tests
47 # Test: c_variable-3.2
48 # Desc: create cb and foo
49 mi_gdb_test "-var-create cb * cb" \
50 "\\^done,name=\"cb\",numchild=\"0\",type=\"int\"" \
51 "create local variable cb"
53 mi_gdb_test "-var-create foo * foo" \
54 "&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
55 "create local variable foo"
57 # step to "foo = 123;"
58 mi_step_to "do_block_tests" "" "var-cmd.c" "158" "step at do_block_test"
61 # Be paranoid and assume 3.2 created foo
62 mi_gdb_test "-var-delete foo" \
63 "&\"Variable object not found\\\\n\".*\\^error,msg=\"Variable object not found\"" \
67 # Test: c_variable-3.3
69 mi_gdb_test "-var-create foo * foo" \
70 "\\^done,name=\"foo\",numchild=\"0\",type=\"int\"" \
71 "create local variable foo"
73 # step to "foo2 = 123;"
74 mi_step_to "do_block_tests" "" "var-cmd.c" "161" "step at do_block_test"
76 # Test: c_variable-3.4
77 # Desc: check foo, cb changed
78 mi_gdb_test "-var-update *" \
79 "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
80 "update all vars: cb foo changed"
82 # step to "foo = 321;"
83 mi_step_to "do_block_tests" "" "var-cmd.c" "164" "step at do_block_test"
85 # Test: c_variable-3.5
86 # Desc: create inner block foo
87 mi_gdb_test "-var-create inner_foo * foo" \
88 "\\^done,name=\"inner_foo\",numchild=\"0\",type=\"int\"" \
89 "create local variable inner_foo"
92 mi_step_to "do_block_tests" "" "var-cmd.c" "166" "step at do_block_test"
94 # Test: c_variable-3.6
96 mi_gdb_test "-var-create foo2 * foo2" \
97 "\\^done,name=\"foo2\",numchild=\"0\",type=\"int\"" \
98 "create local variable foo2"
100 # Test: c_variable-3.7
101 # Desc: check that outer foo in scope and inner foo out of scope
102 # Note: also a known gdb problem
104 mi_gdb_test "-var-update inner_foo" \
105 "\\^done,changelist=\{FIXME\}" \
106 "update inner_foo: should be out of scope: KNOWN PROBLEM"
110 mi_gdb_test "-var-evaluate-expression inner_foo" \
111 "\\^done,value=\{FIXME\}" \
112 "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
115 mi_gdb_test "-var-update foo" \
116 "\\^done,changelist=\\\[\\\]" \
117 "update foo: did not change"
119 mi_gdb_test "-var-delete inner_foo" \
120 "\\^done,ndeleted=\"1\"" \
121 "delete var inner_foo"
124 mi_step_to "do_block_tests" "" "var-cmd.c" "168" "step at do_block_test"
126 # Test: c_variable-3.8
127 # Desc: check that foo2 out of scope (known gdb problem)
129 mi_gdb_test "-var-update foo2" \
130 "\\^done,changelist=\{FIXME\}" \
131 "update foo2: should be out of scope: KNOWN PROBLEM"
135 mi_step_to "do_block_tests" "" "var-cmd.c" "171" "step at do_block_test"
137 # Test: c_variable-3.9
138 # Desc: check that only cb is in scope (known gdb problem)
140 mi_gdb_test "-var-update foo2" \
141 "\\^done,changelist=\\\[FIXME\\\]" \
142 "update foo2 should be out of scope: KNOWN PROBLEM"
145 mi_gdb_test "-var-update foo" \
146 "\\^done,changelist=\{FIXME\}" \
147 "update foo should be out of scope: KNOWN PROBLEM"
149 mi_gdb_test "-var-update cb" \
150 "\\^done,changelist=\\\[\\\]" \
153 # Test: c_variable-3.10
154 # Desc: names of editable variables
155 #gdbtk_test c_variable-3.10 {names of editable variables} {
157 #} {{foo cb foo2} {}}
159 # Done with block tests
160 mi_gdb_test "-var-delete foo" \
161 "\\^done,ndeleted=\"1\"" \
164 mi_gdb_test "-var-delete foo2" \
165 "\\^done,ndeleted=\"1\"" \
168 mi_gdb_test "-var-delete cb" \
169 "\\^done,ndeleted=\"1\"" \