xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.mi/mi-var-rtti.exp (revision d90047b5d07facf36e6c01dcc0bded8997ce9cc2)
1# Copyright 2012-2017 Free Software Foundation, Inc.
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
16if { [skip_cplus_tests] } { continue }
17
18load_lib mi-support.exp
19set MIFLAGS "-i=mi"
20
21gdb_exit
22if [mi_gdb_start] {
23    continue
24}
25
26standard_testfile .cc
27set opts {debug c++}
28
29if [build_executable $testfile.exp $testfile $srcfile $opts] {
30    return -1
31}
32
33mi_gdb_load ${binfile}
34
35mi_prepare_inline_tests $srcfile
36
37# Enable using RTTI to determine real types of the objects
38proc set_print_object {state testname} {
39    mi_gdb_test "-interpreter-exec console \"set print object ${state}\"" \
40	"(.*=cmd-param-changed,param=\"print object\",value=\"${state}\".*|)\\^done" \
41        "-interpreter-exec console \"set print object ${state}\" in $testname"
42}
43
44proc check_derived_children_without_rtti {varobj_name var_name testname} {
45    mi_list_varobj_children ${varobj_name} "
46        { ${varobj_name}.public public 1 }
47    " "list children of ${var_name} (without RTTI) in $testname"
48    mi_list_varobj_children "${varobj_name}.public" "
49        { ${varobj_name}.public.A A 0 int }
50    " "list children of ${var_name}.public (without RTTI) in $testname"
51}
52
53proc check_derived_content_without_rtti {varobj_name var_name testname} {
54    mi_check_varobj_value ${varobj_name}.public.A 1 \
55        "check ${var_name}->A (without RTTI) in $testname"
56}
57
58proc check_derived_without_rtti {varobj_name var_name testname} {
59    check_derived_children_without_rtti ${varobj_name} ${var_name} ${testname}
60    check_derived_content_without_rtti ${varobj_name} ${var_name} ${testname}
61}
62
63proc check_new_derived_without_rtti {var_name var_type testname} {
64    set varobj_name VAR
65    mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \
66        "create varobj for ${var_name} (without RTTI) in ${testname}"
67    check_derived_without_rtti ${varobj_name} ${var_name} ${testname}
68    mi_delete_varobj ${varobj_name} \
69        "delete varobj for ${var_name} (without RTTI) in ${testname}"
70}
71
72proc check_derived_children_with_rtti {varobj_name var_name testname} {
73    mi_list_varobj_children ${varobj_name} "
74        { ${varobj_name}.Base Base 1 Base }
75        { ${varobj_name}.public public 2 }
76    " "list children of ${var_name} (with RTTI) in $testname"
77    mi_list_varobj_children "${varobj_name}.Base" "
78        { ${varobj_name}.Base.public public 1 }
79    " "list children of ${var_name}.Base (with RTTI) in $testname"
80    mi_list_varobj_children "${varobj_name}.Base.public" "
81        { ${varobj_name}.Base.public.A A 0 int }
82    " "list children of ${var_name}.Base.public (with RTTI) in $testname"
83    mi_list_varobj_children "${varobj_name}.public" "
84        { ${varobj_name}.public.B B 0 int }
85        { ${varobj_name}.public.C C 0 int }
86    " "list children of ${var_name}.public (with RTTI) in $testname"
87}
88
89proc check_derived_content_with_rtti {varobj_name var_name testname} {
90    mi_check_varobj_value ${varobj_name}.Base.public.A 1 \
91        "check ${var_name}->A (with RTTI) in $testname"
92    mi_check_varobj_value ${varobj_name}.public.B 2 \
93        "check ${var_name}->B (with RTTI) in $testname"
94    mi_check_varobj_value ${varobj_name}.public.C 3 \
95        "check ${var_name}->C (with RTTI) in $testname"
96}
97
98proc check_derived_with_rtti {varobj_name var_name testname} {
99    check_derived_children_with_rtti ${varobj_name} ${var_name} $testname
100    check_derived_content_with_rtti ${varobj_name} ${var_name} $testname
101}
102
103proc check_new_derived_with_rtti {var_name var_type testname} {
104    set varobj_name VAR
105    mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \
106        "create varobj for ${var_name} (with RTTI) in $testname"
107    check_derived_with_rtti ${varobj_name} ${var_name} $testname
108    mi_delete_varobj ${varobj_name} \
109        "delete varobj for ${var_name} (with RTTI) in $testname"
110}
111
112mi_run_inline_test use_rtti_for_ptr
113mi_run_inline_test use_rtti_for_ref
114mi_run_inline_test use_rtti_for_ptr_child
115mi_run_inline_test use_rtti_for_ref_child
116mi_run_inline_test use_rtti_with_multiple_inheritence
117mi_run_inline_test type_update_when_use_rtti
118mi_run_inline_test skip_type_update_when_not_use_rtti
119
120mi_gdb_exit
121return 0
122