1 /* Copyright 2006, 2007, 2008, 2009 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 3 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, see <http://www.gnu.org/licenses/>.
17 void reference_update_tests ()
19 /*: BEGIN: reference_update :*/
21 /*: mi_create_varobj "RX" "rx" "create varobj for rx" :*/
23 /*: mi_varobj_update RX {RX} "update RX (1)"
24 mi_check_varobj_value RX 167 "check RX: expect 167"
27 /*: mi_varobj_update RX {RX} "update RX (2)"
28 mi_check_varobj_value RX 567 "check RX: expect 567"
31 /*: mi_varobj_update RX {} "update RX (3)"
32 mi_delete_varobj RX "delete RX"
34 /* Dummy assignment to keep 'x' in scope. */
37 /*: END: reference_update :*/
40 struct S
{ int i
; int j
; };
43 int base_in_reference_test (S2
& s2
)
45 /*: BEGIN: base_in_reference :*/
48 mi_create_varobj "S2" "s2" "create varobj for s2"
49 mi_list_varobj_children "S2" {
51 } "list children of s2"
52 mi_list_varobj_children "S2.S" {
53 {"S2.S.public" "public" "2"}
54 } "list children of s2.s"
55 mi_list_varobj_children "S2.S.public" {
56 {"S2.S.public.i" "i" "0" "int"}
57 {"S2.S.public.j" "j" "0" "int"}
58 } "list children of s2.s.public"
60 mi_check_varobj_value "S2.S.public.i" "67" "check S2.S.public.i"
61 mi_check_varobj_value "S2.S.public.j" "89" "check S2.S.public.j"
62 mi_delete_varobj S2 "delete S2"
65 /*: END: base_in_reference :*/
68 void base_in_reference_test_main ()
73 base_in_reference_test (s
);
76 int reference_to_pointer ()
78 /*: BEGIN: reference_to_pointer :*/
79 S s
, *ptr_s
, *& rptr_s
= ptr_s
;
84 mi_create_varobj RPTR rptr_s "create varobj for rptr_s"
86 mi_list_varobj_children RPTR {{RPTR.public public 2}} \
87 "list public child of RPTR"
89 mi_list_varobj_children RPTR.public \
90 {{RPTR.public.i i 0 int}
91 {RPTR.public.j j 0 int}} "list children of reference to pointer"
93 mi_check_varobj_value RPTR.public.i 67 "check i member"
94 mi_check_varobj_value RPTR.public.j 89 "check j member"
95 mi_delete_varobj RPTR "delete RPTR"
98 /*: END: reference_to_pointer :*/
101 int reference_to_struct ()
103 /*: BEGIN: reference_to_struct :*/
107 mi_create_varobj S s "create varobj for s"
108 mi_create_varobj R r "create varobj for s"
109 mi_gdb_test "-var-show-attributes S" \
110 "\\^done,attr=\"noneditable\"" \
111 "check attributes of S"
112 mi_gdb_test "-var-show-attributes R" \
113 "\\^done,attr=\"noneditable\"" \
114 "check attributes of R"
117 /*: mi_varobj_update * [] "-var-update should not list structure varobjs"
120 /*: END: reference_to_struct :*/
133 struct Derived
: public Base1
, public Base2
138 /* Test for the -var-info-path-expression command. Although
139 said command is not specific to C++, it's of more importance
140 to C++ than to C, so we test it in mi-var-cp test. */
141 int path_expression ()
143 /*: BEGIN: path_expression :*/
146 /*: mi_create_varobj IP ip "create varobj for ip"
147 mi_list_varobj_children IP {{IP.\\*ip \\*ip 0 int}} "list children of IP"
148 mi_gdb_test "-var-info-path-expression IP.*ip" \
149 "\\^done,path_expr=\"\\*\\(ip\\)\"" \
150 "-var-info-path-expression IP.*ip"
154 /*: mi_create_varobj DP dp "create varobj for dp"
155 mi_list_varobj_children DP \
156 {{DP.Base1 Base1 1 Base1} \
157 {DP.Base2 Base2 1 Base2} \
158 {DP.public public 1}} "list children of DP"
159 mi_gdb_test "-var-info-path-expression DP.Base1" \
160 "\\^done,path_expr=\"\\(\\*\\(Base1\\*\\) dp\\)\"" \
161 "-var-info-path-expression DP.Base1"
162 mi_list_varobj_children DP.public { \
163 {DP.public.i i 0 int} \
164 } "list children of DP.public"
165 mi_gdb_test "-var-info-path-expression DP.public.i" \
166 "\\^done,path_expr=\"\\(\\(dp\\)->i\\)\"" \
167 "-var-info-path-expression DP.public.i"
168 mi_list_varobj_children DP.Base1 { \
169 {DP.Base1.public public 1} \
170 } "list children of DP.Base1"
171 mi_list_varobj_children DP.Base1.public { \
172 {DP.Base1.public.i i 0 int} \
173 } "list children of DP.Base1.public"
174 mi_gdb_test "-var-info-path-expression DP.Base1.public.i" \
175 "\\^done,path_expr=\"\\(\\(\\(\\*\\(Base1\\*\\) dp\\)\\).i\\)\"" \
176 "-var-info-path-expression DP.Base1.public.i"
178 mi_gdb_test "-var-info-path-expression DP.public" \
179 "\\^done,path_expr=\"\"" \
180 "-var-info-path-expression DP.public"
182 mi_create_varobj D d "create varobj for d"
183 mi_list_varobj_children D \
184 {{D.Base1 Base1 1 Base1} \
185 {D.Base2 Base2 1 Base2} \
186 {D.public public 1}} "list children of D"
187 mi_gdb_test "-var-info-path-expression D.Base1" \
188 "\\^done,path_expr=\"\\(\\(Base1\\) d\\)\"" \
189 "-var-info-path-expression D.Base1"
191 int array
[4] = {1,2,3};
193 /*: mi_create_varobj A array "create varobj for array"
194 mi_list_varobj_children A { \
198 {A.3 3 0 int}} "list children of A"
199 mi_gdb_test "-var-info-path-expression A.2" \
200 "\\^done,path_expr=\"\\(array\\)\\\[2\\\]\"" \
201 "-var-info-path-expression A.2"
205 /*: END: path_expression :*/
210 reference_update_tests ();
211 base_in_reference_test_main ();
212 reference_to_pointer ();
213 reference_to_struct ();
This page took 0.052976 seconds and 4 git commands to generate.