Replace --private with --private-headers for objdump.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.python / py-mi.exp
CommitLineData
7b6bb8da 1# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
b6313243
TT
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# This file is part of the GDB testsuite. It tests Python-based
17# pretty-printing for MI.
18
19load_lib mi-support.exp
20set MIFLAGS "-i=mi2"
21
22gdb_exit
23if [mi_gdb_start] {
24 continue
25}
26
5172aecb 27set testfile "py-prettyprint"
b6313243 28set srcfile ${testfile}.c
7d6d51d5 29set binfile ${objdir}/${subdir}/py-mi
b6313243
TT
30if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug additional_flags=-DMI}] != "" } {
31 untested mi2-var-child.exp
32 return -1
33}
34
35mi_delete_breakpoints
36mi_gdb_reinitialize_dir $srcdir/$subdir
37mi_gdb_load ${binfile}
38
39if {[lsearch -exact [mi_get_features] python] < 0} {
40 unsupported "python support is disabled"
41 return -1
42}
43
44mi_runto main
45
f24fce77
NF
46set remote_python_file [remote_download host ${srcdir}/${subdir}/${testfile}.py]
47
48mi_gdb_test "python execfile ('${remote_python_file}')" ""
b6313243
TT
49
50mi_continue_to_line [gdb_get_line_number {MI breakpoint here} ${testfile}.c] \
51 "step to breakpoint"
52
0cc7d26f
TT
53mi_create_dynamic_varobj container c \
54 "create container varobj, no pretty-printing"
55
56mi_list_varobj_children container {
57 { container.name name 1 string }
58 { container.len len 0 int }
59 { container.elements elements 1 "int ." }
60} "examine container children=0, no pretty-printing"
61
62mi_delete_varobj container "delete varobj"
63
79f283fe
PM
64mi_create_dynamic_varobj nscont nstype \
65 "create nscont varobj, no pretty-printing"
66
67mi_list_varobj_children nscont {
68 { nscont.len len 0 int }
69 { nscont.elements elements 1 "int ." }
70} "examine nscont children=0, no pretty-printing"
71
72mi_delete_varobj nscont "delete varobj"
73
0cc7d26f
TT
74mi_gdb_test "-enable-pretty-printing" ""
75
76mi_create_varobj_checked string string_1 \
77 "struct string_repr" \
78 "create string_1 varobj"
79
be759fcf
PM
80mi_create_varobj_checked lstring estring \
81 "struct lazystring" \
82 "create estring varobj"
83
0cc7d26f
TT
84mi_gdb_test "-data-evaluate-expression \"string_1 = string_2\"" ".*" \
85 "assign string_1 from string_2"
86
87mi_gdb_test "-var-update string" \
88 "\\^done,changelist=\\\[{name=\"string\",in_scope=\"true\",type_changed=\"false\",dynamic=\"1\",has_more=\"0\"}\\\]" \
89 "update string varobj after assignment"
90
91mi_create_dynamic_varobj container c \
92 "create container varobj"
b6313243
TT
93
94mi_list_varobj_children container {
95} "examine container children=0"
96
97mi_next "next over update 1"
98
0cc7d26f
TT
99mi_varobj_update_dynamic container "varobj update 1" {
100 type_changed false new_num_children 1 dynamic 1 has_more 0
101} {
102} {
103 { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
104}
b6313243
TT
105
106mi_next "next over update 2"
107
0cc7d26f
TT
108mi_varobj_update_dynamic container "varobj update 2" {
109 type_changed false new_num_children 2 dynamic 1 has_more 0
110} {
111} {
112 { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
113}
b6313243
TT
114
115mi_gdb_test "-var-set-visualizer container None" \
116 "\\^done" \
117 "clear visualizer"
118
119mi_gdb_test "-var-update container" \
120 "\\^done,changelist=\\\[\\\]" \
121 "varobj update after clearing"
122
123mi_gdb_test "-var-set-visualizer container gdb.default_visualizer" \
124 "\\^done" \
125 "choose default visualizer"
126
0cc7d26f
TT
127mi_varobj_update_dynamic container "varobj update after choosing default" {
128 type_changed false new_num_children 2 dynamic 1 has_more 0
129} {
130} {
131 { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
132 { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
133}
b6313243
TT
134
135mi_gdb_test "-var-set-visualizer container ContainerPrinter" \
136 "\\^done" \
137 "choose visualizer using expression"
138
0cc7d26f
TT
139mi_varobj_update_dynamic container \
140 "varobj update after choosing via expression" {
141 type_changed false new_num_children 2 dynamic 1 has_more 0
142 } {
143 } {
144 { name {container.\[0\]} exp {\[0\]} numchild 0 type int thread-id 1 }
145 { name {container.\[1\]} exp {\[1\]} numchild 0 type int thread-id 1 }
146 }
147
148mi_list_varobj_children_range container 1 2 2 {
149 { {container.\[1\]} {\[1\]} 0 int }
150} "list varobj children after selecting child range"
151
152mi_list_varobj_children_range container -1 -1 2 {
b6313243
TT
153 { {container.\[0\]} {\[0\]} 0 int }
154 { {container.\[1\]} {\[1\]} 0 int }
0cc7d26f
TT
155} "list varobj children after resetting child range"
156
157mi_next "next over update 3"
158
159mi_gdb_test "-var-set-update-range container 0 1" \
160 "\\^done" \
161 "set update range"
162
163# This should truncate the list.
164mi_list_varobj_children container {
165 { {container.\[0\]} {\[0\]} 0 int }
166} "list children after setting update range"
167
168# This should return just the items in [1,2).
169mi_list_varobj_children_range container 1 2 2 {
170 { {container.\[1\]} {\[1\]} 0 int }
171} "list selected children after setting range"
172
173# This should not be affected by the previous list-children request.
174mi_list_varobj_children container {
175 { {container.\[0\]} {\[0\]} 0 int }
176} "list children after listing selected range"
177
178mi_next "next over update 4"
179
180# This should only show the first child, because the update range has
181# been set.
182mi_varobj_update_dynamic container \
183 "update after next with restricted range" {
184 type_changed false new_num_children 1 dynamic 1 has_more 1
185 } {
186 { name {container.\[0\]} in_scope true type_changed false dynamic 1 has_more 0 }
187 } {
188 }
189
190mi_gdb_test "-var-set-update-range container 3 4" \
191 "\\^done" \
192 "set update range with non-zero start"
193
194# Elements were updated but should not be reported.
195mi_varobj_update_dynamic container \
196 "update varobj with change outside selected range" {
197 type_changed false new_num_children 3 dynamic 1 has_more 0
198 } {
199 } {
200 }
201
202mi_next "next over update 5"
203
204# Regression test: examine an object that has no children, then update
205# it to ensure that we don't print the children.
206mi_create_dynamic_varobj container2 c2 \
207 "create second container varobj"
208
209mi_gdb_test "-var-update container2" \
210 "\\^done,changelist=.." \
211 "update varobj, no children requested"
212
213mi_next "next over update 6"
214
215# Now container2 has an element -- and an update should mention that
216# it has_more. But, because we did not request children, we still
217# should not actually see them.
218mi_varobj_update_dynamic container2 \
219 "update varobj 2, no children requested" {
220 type_changed false dynamic 1 has_more 1
221 } {} {}
222
223mi_continue_to_line \
224 [gdb_get_line_number {MI outer breakpoint here} ${testfile}.c] \
225 "step to outer breakpoint"
226
227mi_create_dynamic_varobj outer outer \
228 "create outer varobj"
229
230mi_list_varobj_children outer {
231 { outer.s s 2 "struct substruct" }
232 { outer.x x 0 "int" }
233} "list children of outer"
234
235mi_list_varobj_children outer.s {
236 { outer.s.a a 0 int }
237 { outer.s.b b 0 int }
238} "list children of outer.s"
239
240mi_next "next over outer update"
241
242mi_gdb_test "-var-update outer" \
243 ".done,changelist=.{name=\"outer.s.a\",in_scope=\"true\",type_changed=\"false\",dynamic=\"1\",has_more=\"0\"}." \
244 "update after updating element of outer"
b6313243
TT
245
246mi_continue_to_line \
247 [gdb_get_line_number {Another MI breakpoint} ${testfile}.c] \
248 "step to second breakpoint"
249
250mi_varobj_update_with_type_change container int 0 "update after type change"
f24fce77 251
79f283fe
PM
252
253mi_continue_to_line \
254 [gdb_get_line_number {break to inspect struct and union} ${testfile}.c] \
255 "step to outer breakpoint"
256
257mi_create_dynamic_varobj nscont nstype \
258 "create nstype varobj"
259
260mi_list_varobj_children nscont {
261 { {nscont.\[0\]} {\[0\]} 0 int }
262 { {nscont.\[1\]} {\[1\]} 0 int }
263} "list children after setting update range"
264
265mi_gdb_test "-var-set-visualizer nscont None" \
266 "\\^done" \
267 "clear visualizer"
268
269mi_gdb_test "-var-update nscont" \
270 "\\^done,changelist=\\\[\\\]" \
271 "varobj update after clearing"
272
273mi_gdb_test "-var-set-visualizer nscont gdb.default_visualizer" \
274 "\\^done" \
275 "choose default visualizer"
276
a4c8e806
TT
277mi_gdb_test "python exception_flag = True" ""
278
279mi_create_dynamic_varobj nstype2 nstype2 \
280 "create nstype2 varobj"
281
282mi_list_varobj_children nstype2 {
283 { {nstype2.<error at 0>} {<error at 0>} 6 {char \[6\]} }
284} "list children after setting exception flag"
285
d65aec65
PM
286# C++ MI tests
287gdb_exit
288if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" \
289 executable {debug c++ additional_flags=-DMI}] != "" } {
290 untested "Couldn't compile ${srcfile} in c++ mode"
291 return -1
292}
293
294if [mi_gdb_start] {
295 continue
296}
297mi_delete_breakpoints
298mi_gdb_reinitialize_dir $srcdir/$subdir
299mi_gdb_load ${binfile}
300
301if {[lsearch -exact [mi_get_features] python] < 0} {
302 unsupported "python support is disabled"
303 return -1
304}
305
306mi_runto main
307mi_continue_to_line \
308 [gdb_get_line_number {break to inspect struct and union} ${testfile}.c] \
309 "step to breakpoint"
310
311# Test python/12531. Install visualizer on a cplus_fake_child.
312mi_create_varobj fake fake \
313 "create fake varobj"
314
315mi_list_varobj_children fake {
316 { fake.private private 1 }
317} "list children of fake"
318
319mi_list_varobj_children fake.private {
320 { fake.private.sname sname 0 int }
321} "list children fake.private"
322
323mi_gdb_test "-var-set-visualizer fake.private gdb.default_visualizer" \
324 "\\^done" "Install visualizer on a cplus_fake_child"
325
f24fce77 326remote_file host delete ${remote_python_file}
This page took 0.259754 seconds and 4 git commands to generate.