1 # Copyright 2012-2024 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/>.
16 require allow_cplus_tests
18 load_lib mi-support.exp
24 if [build_executable $testfile.exp $testfile $srcfile $opts] {
28 if {[mi_clean_restart $binfile]} {
32 mi_prepare_inline_tests $srcfile
34 # Enable using RTTI to determine real types of the objects
35 proc set_print_object {state testname} {
36 mi_gdb_test "-interpreter-exec console \"set print object ${state}\"" \
37 "(.*=cmd-param-changed,param=\"print object\",value=\"${state}\".*|)\\^done" \
38 "-interpreter-exec console \"set print object ${state}\" in $testname"
41 proc check_derived_children_without_rtti {varobj_name var_name testname} {
42 mi_list_varobj_children ${varobj_name} "
43 { ${varobj_name}.public public 1 }
44 " "list children of ${var_name} (without RTTI) in $testname"
45 mi_list_varobj_children "${varobj_name}.public" "
46 { ${varobj_name}.public.A A 0 int }
47 " "list children of ${var_name}.public (without RTTI) in $testname"
50 proc check_derived_content_without_rtti {varobj_name var_name testname} {
51 mi_check_varobj_value ${varobj_name}.public.A 1 \
52 "check ${var_name}->A (without RTTI) in $testname"
55 proc check_derived_without_rtti {varobj_name var_name testname} {
56 check_derived_children_without_rtti ${varobj_name} ${var_name} ${testname}
57 check_derived_content_without_rtti ${varobj_name} ${var_name} ${testname}
60 proc check_new_derived_without_rtti {var_name var_type testname} {
62 mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \
63 "create varobj for ${var_name} (without RTTI) in ${testname}"
64 check_derived_without_rtti ${varobj_name} ${var_name} ${testname}
65 mi_delete_varobj ${varobj_name} \
66 "delete varobj for ${var_name} (without RTTI) in ${testname}"
69 proc check_derived_children_with_rtti {varobj_name var_name testname} {
70 mi_list_varobj_children ${varobj_name} "
71 { ${varobj_name}.Base Base 1 Base }
72 { ${varobj_name}.public public 2 }
73 " "list children of ${var_name} (with RTTI) in $testname"
74 mi_list_varobj_children "${varobj_name}.Base" "
75 { ${varobj_name}.Base.public public 1 }
76 " "list children of ${var_name}.Base (with RTTI) in $testname"
77 mi_list_varobj_children "${varobj_name}.Base.public" "
78 { ${varobj_name}.Base.public.A A 0 int }
79 " "list children of ${var_name}.Base.public (with RTTI) in $testname"
80 mi_list_varobj_children "${varobj_name}.public" "
81 { ${varobj_name}.public.B B 0 int }
82 { ${varobj_name}.public.C C 0 int }
83 " "list children of ${var_name}.public (with RTTI) in $testname"
86 proc check_derived_content_with_rtti {varobj_name var_name testname} {
87 mi_check_varobj_value ${varobj_name}.Base.public.A 1 \
88 "check ${var_name}->A (with RTTI) in $testname"
89 mi_check_varobj_value ${varobj_name}.public.B 2 \
90 "check ${var_name}->B (with RTTI) in $testname"
91 mi_check_varobj_value ${varobj_name}.public.C 3 \
92 "check ${var_name}->C (with RTTI) in $testname"
95 proc check_derived_with_rtti {varobj_name var_name testname} {
96 check_derived_children_with_rtti ${varobj_name} ${var_name} $testname
97 check_derived_content_with_rtti ${varobj_name} ${var_name} $testname
100 proc check_new_derived_with_rtti {var_name var_type testname} {
102 mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \
103 "create varobj for ${var_name} (with RTTI) in $testname"
104 check_derived_with_rtti ${varobj_name} ${var_name} $testname
105 mi_delete_varobj ${varobj_name} \
106 "delete varobj for ${var_name} (with RTTI) in $testname"
112 use_rtti_for_ptr_child
113 use_rtti_for_ref_child
114 use_rtti_with_multiple_inheritence
115 type_update_when_use_rtti
116 skip_type_update_when_not_use_rtti
119 foreach_with_prefix inline_test $inline_tests {
120 if { [mi_run_inline_test $inline_test] < 0 } {