1 # Copyright 2012 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 if { [skip_cplus_tests] } { continue }
18 load_lib mi-support.exp
26 set testfile mi-var-rtti
27 set srcfile "$testfile.cc"
28 set executable ${testfile}
29 set binfile $objdir/$subdir/$testfile
32 if [build_executable $testfile.exp $executable $srcfile $opts] {
36 mi_gdb_load ${binfile}
38 mi_prepare_inline_tests $srcfile
40 # Enable using RTTI to determine real types of the objects
41 proc set_print_object {state testname} {
42 mi_gdb_test "-interpreter-exec console \"set print object ${state}\"" \
44 "-interpreter-exec console \"set print object ${state}\" in $testname"
47 proc check_derived_children_without_rtti {varobj_name var_name testname} {
48 mi_list_varobj_children ${varobj_name} "
49 { ${varobj_name}.public public 1 }
50 " "list children of ${var_name} (without RTTI) in $testname"
51 mi_list_varobj_children "${varobj_name}.public" "
52 { ${varobj_name}.public.A A 0 int }
53 " "list children of ${var_name}.public (without RTTI) in $testname"
56 proc check_derived_content_without_rtti {varobj_name var_name testname} {
57 mi_check_varobj_value ${varobj_name}.public.A 1 \
58 "check ${var_name}->A (without RTTI) in $testname"
61 proc check_derived_without_rtti {varobj_name var_name testname} {
62 check_derived_children_without_rtti ${varobj_name} ${var_name} ${testname}
63 check_derived_content_without_rtti ${varobj_name} ${var_name} ${testname}
66 proc check_new_derived_without_rtti {var_name var_type testname} {
68 mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \
69 "create varobj for ${var_name} (without RTTI) in ${testname}"
70 check_derived_without_rtti ${varobj_name} ${var_name} ${testname}
71 mi_delete_varobj ${varobj_name} \
72 "delete varobj for ${var_name} (without RTTI) in ${testname}"
75 proc check_derived_children_with_rtti {varobj_name var_name testname} {
76 mi_list_varobj_children ${varobj_name} "
77 { ${varobj_name}.Base Base 1 Base }
78 { ${varobj_name}.public public 2 }
79 " "list children of ${var_name} (with RTTI) in $testname"
80 mi_list_varobj_children "${varobj_name}.Base" "
81 { ${varobj_name}.Base.public public 1 }
82 " "list children of ${var_name}.Base (with RTTI) in $testname"
83 mi_list_varobj_children "${varobj_name}.Base.public" "
84 { ${varobj_name}.Base.public.A A 0 int }
85 " "list children of ${var_name}.Base.public (with RTTI) in $testname"
86 mi_list_varobj_children "${varobj_name}.public" "
87 { ${varobj_name}.public.B B 0 int }
88 { ${varobj_name}.public.C C 0 int }
89 " "list children of ${var_name}.public (with RTTI) in $testname"
92 proc check_derived_content_with_rtti {varobj_name var_name testname} {
93 mi_check_varobj_value ${varobj_name}.Base.public.A 1 \
94 "check ${var_name}->A (with RTTI) in $testname"
95 mi_check_varobj_value ${varobj_name}.public.B 2 \
96 "check ${var_name}->B (with RTTI) in $testname"
97 mi_check_varobj_value ${varobj_name}.public.C 3 \
98 "check ${var_name}->C (with RTTI) in $testname"
101 proc check_derived_with_rtti {varobj_name var_name testname} {
102 check_derived_children_with_rtti ${varobj_name} ${var_name} $testname
103 check_derived_content_with_rtti ${varobj_name} ${var_name} $testname
106 proc check_new_derived_with_rtti {var_name var_type testname} {
108 mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \
109 "create varobj for ${var_name} (with RTTI) in $testname"
110 check_derived_with_rtti ${varobj_name} ${var_name} $testname
111 mi_delete_varobj ${varobj_name} \
112 "delete varobj for ${var_name} (with RTTI) in $testname"
115 mi_run_inline_test use_rtti_for_ptr
116 mi_run_inline_test use_rtti_for_ref
117 mi_run_inline_test use_rtti_for_ptr_child
118 mi_run_inline_test use_rtti_for_ref_child
119 mi_run_inline_test use_rtti_with_multiple_inheritence
120 mi_run_inline_test type_update_when_use_rtti
121 mi_run_inline_test skip_type_update_when_not_use_rtti