merge from gcc
[external/binutils.git] / gdb / testsuite / gdb.mi / mi-var-block.exp
1 # Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
3 #
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 3 of the License, or
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
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Test essential Machine interface (MI) operations
18 #
19 # Verify that, using the MI, we can create, update, delete variables.
20 #
21
22
23 load_lib mi-support.exp
24 set MIFLAGS "-i=mi"
25
26 gdb_exit
27 if [mi_gdb_start] {
28     continue
29 }
30
31 set testfile "var-cmd"
32 set srcfile ${testfile}.c
33 set binfile ${objdir}/${subdir}/mi-var-block
34 if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DFAKEARGV}] != "" } {
35     untested mi-var-block.exp
36     return -1
37 }
38
39 mi_delete_breakpoints
40 mi_gdb_reinitialize_dir $srcdir/$subdir
41 mi_gdb_load ${binfile}
42
43 mi_runto do_block_tests
44
45 # Test: c_variable-3.2
46 # Desc: create cb and foo
47 mi_create_varobj "cb" "cb" "create local variable cb"
48
49 mi_gdb_test "-var-create foo * foo" \
50        "\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
51        "try to create local variable foo"
52
53 # step to "foo = 123;"
54 mi_step_to "do_block_tests" "" "var-cmd.c" \
55     [gdb_get_line_number "foo = 123;"] \
56     "step at do_block_test"
57
58
59 # Be paranoid and assume 3.2 created foo
60 mi_gdb_test "-var-delete foo" \
61         "\\^error,msg=\"Variable object not found\"" \
62         "delete var foo"
63
64
65 # Test: c_variable-3.3
66 # Desc: create foo
67 mi_create_varobj "foo" "foo" "create local variable foo"
68
69 # step to "foo2 = 123;"
70 mi_step_to "do_block_tests" "" "var-cmd.c" \
71     [gdb_get_line_number "foo2 = 123;"] \
72     "step at do_block_test"
73
74 # Test: c_variable-3.4
75 # Desc: check foo, cb changed
76 mi_gdb_test "-var-update *" \
77         "\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\",has_more=\"0\"\}\\\]" \
78         "update all vars: cb foo changed"
79
80 # step to "foo = 321;"
81 mi_step_to "do_block_tests" "" "var-cmd.c" \
82     [gdb_get_line_number "foo = 321;"] \
83     "step at do_block_test"
84
85 # Test: c_variable-3.5
86 # Desc: create inner block foo
87 mi_create_varobj "inner_foo" "foo" "create local variable inner_foo"
88
89 # step to "foo2 = 0;"
90 mi_step_to "do_block_tests" "" "var-cmd.c" \
91     [gdb_get_line_number "foo2 = 0;"] \
92     "step at do_block_test"
93
94 # Test: c_variable-3.6
95 # Desc: create foo2
96 mi_create_varobj "foo2" "foo2" "create local variable foo2"
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
101 setup_xfail *-*-*
102 mi_gdb_test "-var-update inner_foo" \
103         "\\^done,changelist=\{FIXME\}" \
104         "update inner_foo: should be out of scope: KNOWN PROBLEM"
105 clear_xfail *-*-*
106
107 setup_xfail *-*-*
108 mi_gdb_test "-var-evaluate-expression inner_foo" \
109         "\\^done,value=\{FIXME\}" \
110         "evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
111 clear_xfail *-*-*
112
113 mi_gdb_test "-var-update foo" \
114         "\\^done,changelist=\\\[\\\]" \
115         "update foo: did not change"
116
117 mi_gdb_test "-var-delete inner_foo" \
118         "\\^done,ndeleted=\"1\"" \
119         "delete var inner_foo"
120
121 # step to "foo = 0;"
122 mi_step_to "do_block_tests" "" "var-cmd.c" \
123     [gdb_get_line_number "foo = 0;"] \
124     "step at do_block_test"
125
126 # Test: c_variable-3.8
127 # Desc: check that foo2 out of scope (known gdb problem)
128 setup_xfail *-*-*
129 mi_gdb_test "-var-update foo2" \
130         "\\^done,changelist=\{FIXME\}" \
131         "update foo2: should be out of scope: KNOWN PROBLEM"
132 clear_xfail *-*-*
133
134 # step to "cb = 21;"
135 mi_step_to "do_block_tests" "" "var-cmd.c" \
136     [gdb_get_line_number "cb = 21;"] \
137     "step at do_block_test"
138
139 # Test: c_variable-3.9
140 # Desc: check that only cb is in scope (known gdb problem)
141 setup_xfail *-*-*
142 mi_gdb_test "-var-update foo2" \
143         "\\^done,changelist=\\\[FIXME\\\]" \
144         "update foo2 should be out of scope: KNOWN PROBLEM"
145 clear_xfail *-*-*
146 setup_xfail *-*-*
147 mi_gdb_test "-var-update foo" \
148         "\\^done,changelist=\{FIXME\}" \
149         "update foo should be out of scope: KNOWN PROBLEM"
150 clear_xfail *-*-*
151 mi_gdb_test "-var-update cb" \
152         "\\^done,changelist=\\\[\\\]" \
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
162 mi_gdb_test "-var-delete foo" \
163         "\\^done,ndeleted=\"1\"" \
164         "delete var foo"
165
166 mi_gdb_test "-var-delete foo2" \
167         "\\^done,ndeleted=\"1\"" \
168         "delete var foo2"
169
170 mi_gdb_test "-var-delete cb" \
171         "\\^done,ndeleted=\"1\"" \
172         "delete var cb"
173
174 mi_gdb_exit
175 return 0