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