1 |
24 |
jeremybenn |
# Copyright 1999, 2000, 2001, 2002, 2004, 2007, 2008
|
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 .
|
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}/${testfile}
|
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_gdb_test "-var-create cb * cb" \
|
48 |
|
|
"\\^done,name=\"cb\",numchild=\"0\",value=\".*\",type=\"int\"" \
|
49 |
|
|
"create local variable cb"
|
50 |
|
|
|
51 |
|
|
mi_gdb_test "-var-create foo * foo" \
|
52 |
|
|
"&\"mi_cmd_var_create: unable to create variable object\\\\n\".*\\^error,msg=\"mi_cmd_var_create: unable to create variable object\"" \
|
53 |
|
|
"create local variable foo"
|
54 |
|
|
|
55 |
|
|
# step to "foo = 123;"
|
56 |
|
|
mi_step_to "do_block_tests" "" "var-cmd.c" \
|
57 |
|
|
[gdb_get_line_number "foo = 123;"] \
|
58 |
|
|
"step at do_block_test"
|
59 |
|
|
|
60 |
|
|
|
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\"" \
|
64 |
|
|
"delete var foo"
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
# Test: c_variable-3.3
|
68 |
|
|
# Desc: create foo
|
69 |
|
|
mi_gdb_test "-var-create foo * foo" \
|
70 |
|
|
"\\^done,name=\"foo\",numchild=\"0\",value=\".*\",type=\"int\"" \
|
71 |
|
|
"create local variable foo"
|
72 |
|
|
|
73 |
|
|
# step to "foo2 = 123;"
|
74 |
|
|
mi_step_to "do_block_tests" "" "var-cmd.c" \
|
75 |
|
|
[gdb_get_line_number "foo2 = 123;"] \
|
76 |
|
|
"step at do_block_test"
|
77 |
|
|
|
78 |
|
|
# Test: c_variable-3.4
|
79 |
|
|
# Desc: check foo, cb changed
|
80 |
|
|
mi_gdb_test "-var-update *" \
|
81 |
|
|
"\\^done,changelist=\\\[\{name=\"foo\",in_scope=\"true\",type_changed=\"false\"\},\{name=\"cb\",in_scope=\"true\",type_changed=\"false\"\}\\\]" \
|
82 |
|
|
"update all vars: cb foo changed"
|
83 |
|
|
|
84 |
|
|
# step to "foo = 321;"
|
85 |
|
|
mi_step_to "do_block_tests" "" "var-cmd.c" \
|
86 |
|
|
[gdb_get_line_number "foo = 321;"] \
|
87 |
|
|
"step at do_block_test"
|
88 |
|
|
|
89 |
|
|
# Test: c_variable-3.5
|
90 |
|
|
# Desc: create inner block foo
|
91 |
|
|
mi_gdb_test "-var-create inner_foo * foo" \
|
92 |
|
|
"\\^done,name=\"inner_foo\",numchild=\"0\",value=\".*\",type=\"int\"" \
|
93 |
|
|
"create local variable inner_foo"
|
94 |
|
|
|
95 |
|
|
# step to "foo2 = 0;"
|
96 |
|
|
mi_step_to "do_block_tests" "" "var-cmd.c" \
|
97 |
|
|
[gdb_get_line_number "foo2 = 0;"] \
|
98 |
|
|
"step at do_block_test"
|
99 |
|
|
|
100 |
|
|
# Test: c_variable-3.6
|
101 |
|
|
# Desc: create foo2
|
102 |
|
|
mi_gdb_test "-var-create foo2 * foo2" \
|
103 |
|
|
"\\^done,name=\"foo2\",numchild=\"0\",value=\".*\",type=\"int\"" \
|
104 |
|
|
"create local variable foo2"
|
105 |
|
|
|
106 |
|
|
# Test: c_variable-3.7
|
107 |
|
|
# Desc: check that outer foo in scope and inner foo out of scope
|
108 |
|
|
# Note: also a known gdb problem
|
109 |
|
|
setup_xfail *-*-*
|
110 |
|
|
mi_gdb_test "-var-update inner_foo" \
|
111 |
|
|
"\\^done,changelist=\{FIXME\}" \
|
112 |
|
|
"update inner_foo: should be out of scope: KNOWN PROBLEM"
|
113 |
|
|
clear_xfail *-*-*
|
114 |
|
|
|
115 |
|
|
setup_xfail *-*-*
|
116 |
|
|
mi_gdb_test "-var-evaluate-expression inner_foo" \
|
117 |
|
|
"\\^done,value=\{FIXME\}" \
|
118 |
|
|
"evaluate inner_foo: should be out of scope: KNOWN PROBLEM"
|
119 |
|
|
clear_xfail *-*-*
|
120 |
|
|
|
121 |
|
|
mi_gdb_test "-var-update foo" \
|
122 |
|
|
"\\^done,changelist=\\\[\\\]" \
|
123 |
|
|
"update foo: did not change"
|
124 |
|
|
|
125 |
|
|
mi_gdb_test "-var-delete inner_foo" \
|
126 |
|
|
"\\^done,ndeleted=\"1\"" \
|
127 |
|
|
"delete var inner_foo"
|
128 |
|
|
|
129 |
|
|
# step to "foo = 0;"
|
130 |
|
|
mi_step_to "do_block_tests" "" "var-cmd.c" \
|
131 |
|
|
[gdb_get_line_number "foo = 0;"] \
|
132 |
|
|
"step at do_block_test"
|
133 |
|
|
|
134 |
|
|
# Test: c_variable-3.8
|
135 |
|
|
# Desc: check that foo2 out of scope (known gdb problem)
|
136 |
|
|
setup_xfail *-*-*
|
137 |
|
|
mi_gdb_test "-var-update foo2" \
|
138 |
|
|
"\\^done,changelist=\{FIXME\}" \
|
139 |
|
|
"update foo2: should be out of scope: KNOWN PROBLEM"
|
140 |
|
|
clear_xfail *-*-*
|
141 |
|
|
|
142 |
|
|
# step to "cb = 21;"
|
143 |
|
|
mi_step_to "do_block_tests" "" "var-cmd.c" \
|
144 |
|
|
[gdb_get_line_number "cb = 21;"] \
|
145 |
|
|
"step at do_block_test"
|
146 |
|
|
|
147 |
|
|
# Test: c_variable-3.9
|
148 |
|
|
# Desc: check that only cb is in scope (known gdb problem)
|
149 |
|
|
setup_xfail *-*-*
|
150 |
|
|
mi_gdb_test "-var-update foo2" \
|
151 |
|
|
"\\^done,changelist=\\\[FIXME\\\]" \
|
152 |
|
|
"update foo2 should be out of scope: KNOWN PROBLEM"
|
153 |
|
|
clear_xfail *-*-*
|
154 |
|
|
setup_xfail *-*-*
|
155 |
|
|
mi_gdb_test "-var-update foo" \
|
156 |
|
|
"\\^done,changelist=\{FIXME\}" \
|
157 |
|
|
"update foo should be out of scope: KNOWN PROBLEM"
|
158 |
|
|
clear_xfail *-*-*
|
159 |
|
|
mi_gdb_test "-var-update cb" \
|
160 |
|
|
"\\^done,changelist=\\\[\\\]" \
|
161 |
|
|
"update cb"
|
162 |
|
|
|
163 |
|
|
# Test: c_variable-3.10
|
164 |
|
|
# Desc: names of editable variables
|
165 |
|
|
#gdbtk_test c_variable-3.10 {names of editable variables} {
|
166 |
|
|
# editable_variables
|
167 |
|
|
#} {{foo cb foo2} {}}
|
168 |
|
|
|
169 |
|
|
# Done with block tests
|
170 |
|
|
mi_gdb_test "-var-delete foo" \
|
171 |
|
|
"\\^done,ndeleted=\"1\"" \
|
172 |
|
|
"delete var foo"
|
173 |
|
|
|
174 |
|
|
mi_gdb_test "-var-delete foo2" \
|
175 |
|
|
"\\^done,ndeleted=\"1\"" \
|
176 |
|
|
"delete var foo2"
|
177 |
|
|
|
178 |
|
|
mi_gdb_test "-var-delete cb" \
|
179 |
|
|
"\\^done,ndeleted=\"1\"" \
|
180 |
|
|
"delete var cb"
|
181 |
|
|
|
182 |
|
|
mi_gdb_exit
|
183 |
|
|
return 0
|