1 1.11 christos # Copyright 2012-2024 Free Software Foundation, Inc. 2 1.1 christos 3 1.1 christos # This program is free software; you can redistribute it and/or modify 4 1.1 christos # it under the terms of the GNU General Public License as published by 5 1.1 christos # the Free Software Foundation; either version 3 of the License, or 6 1.1 christos # (at your option) any later version. 7 1.1 christos # 8 1.1 christos # This program is distributed in the hope that it will be useful, 9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 1.1 christos # GNU General Public License for more details. 12 1.1 christos # 13 1.1 christos # You should have received a copy of the GNU General Public License 14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 1.1 christos 16 1.11 christos require allow_cplus_tests 17 1.1 christos 18 1.1 christos load_lib mi-support.exp 19 1.1 christos set MIFLAGS "-i=mi" 20 1.1 christos 21 1.1 christos standard_testfile .cc 22 1.1 christos set opts {debug c++} 23 1.1 christos 24 1.1 christos if [build_executable $testfile.exp $testfile $srcfile $opts] { 25 1.1 christos return -1 26 1.1 christos } 27 1.1 christos 28 1.11 christos if {[mi_clean_restart $binfile]} { 29 1.11 christos return 30 1.11 christos } 31 1.1 christos 32 1.1 christos mi_prepare_inline_tests $srcfile 33 1.1 christos 34 1.1 christos # Enable using RTTI to determine real types of the objects 35 1.1 christos proc set_print_object {state testname} { 36 1.1 christos mi_gdb_test "-interpreter-exec console \"set print object ${state}\"" \ 37 1.1 christos "(.*=cmd-param-changed,param=\"print object\",value=\"${state}\".*|)\\^done" \ 38 1.1 christos "-interpreter-exec console \"set print object ${state}\" in $testname" 39 1.1 christos } 40 1.1 christos 41 1.1 christos proc check_derived_children_without_rtti {varobj_name var_name testname} { 42 1.1 christos mi_list_varobj_children ${varobj_name} " 43 1.1 christos { ${varobj_name}.public public 1 } 44 1.1 christos " "list children of ${var_name} (without RTTI) in $testname" 45 1.1 christos mi_list_varobj_children "${varobj_name}.public" " 46 1.1 christos { ${varobj_name}.public.A A 0 int } 47 1.1 christos " "list children of ${var_name}.public (without RTTI) in $testname" 48 1.1 christos } 49 1.1 christos 50 1.1 christos proc check_derived_content_without_rtti {varobj_name var_name testname} { 51 1.1 christos mi_check_varobj_value ${varobj_name}.public.A 1 \ 52 1.1 christos "check ${var_name}->A (without RTTI) in $testname" 53 1.1 christos } 54 1.1 christos 55 1.1 christos proc check_derived_without_rtti {varobj_name var_name testname} { 56 1.1 christos check_derived_children_without_rtti ${varobj_name} ${var_name} ${testname} 57 1.1 christos check_derived_content_without_rtti ${varobj_name} ${var_name} ${testname} 58 1.1 christos } 59 1.1 christos 60 1.1 christos proc check_new_derived_without_rtti {var_name var_type testname} { 61 1.1 christos set varobj_name VAR 62 1.1 christos mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \ 63 1.1 christos "create varobj for ${var_name} (without RTTI) in ${testname}" 64 1.1 christos check_derived_without_rtti ${varobj_name} ${var_name} ${testname} 65 1.1 christos mi_delete_varobj ${varobj_name} \ 66 1.1 christos "delete varobj for ${var_name} (without RTTI) in ${testname}" 67 1.1 christos } 68 1.1 christos 69 1.1 christos proc check_derived_children_with_rtti {varobj_name var_name testname} { 70 1.1 christos mi_list_varobj_children ${varobj_name} " 71 1.1 christos { ${varobj_name}.Base Base 1 Base } 72 1.1 christos { ${varobj_name}.public public 2 } 73 1.1 christos " "list children of ${var_name} (with RTTI) in $testname" 74 1.1 christos mi_list_varobj_children "${varobj_name}.Base" " 75 1.1 christos { ${varobj_name}.Base.public public 1 } 76 1.1 christos " "list children of ${var_name}.Base (with RTTI) in $testname" 77 1.1 christos mi_list_varobj_children "${varobj_name}.Base.public" " 78 1.1 christos { ${varobj_name}.Base.public.A A 0 int } 79 1.1 christos " "list children of ${var_name}.Base.public (with RTTI) in $testname" 80 1.1 christos mi_list_varobj_children "${varobj_name}.public" " 81 1.1 christos { ${varobj_name}.public.B B 0 int } 82 1.1 christos { ${varobj_name}.public.C C 0 int } 83 1.1 christos " "list children of ${var_name}.public (with RTTI) in $testname" 84 1.1 christos } 85 1.1 christos 86 1.1 christos proc check_derived_content_with_rtti {varobj_name var_name testname} { 87 1.1 christos mi_check_varobj_value ${varobj_name}.Base.public.A 1 \ 88 1.1 christos "check ${var_name}->A (with RTTI) in $testname" 89 1.1 christos mi_check_varobj_value ${varobj_name}.public.B 2 \ 90 1.1 christos "check ${var_name}->B (with RTTI) in $testname" 91 1.1 christos mi_check_varobj_value ${varobj_name}.public.C 3 \ 92 1.1 christos "check ${var_name}->C (with RTTI) in $testname" 93 1.1 christos } 94 1.1 christos 95 1.1 christos proc check_derived_with_rtti {varobj_name var_name testname} { 96 1.1 christos check_derived_children_with_rtti ${varobj_name} ${var_name} $testname 97 1.1 christos check_derived_content_with_rtti ${varobj_name} ${var_name} $testname 98 1.1 christos } 99 1.1 christos 100 1.1 christos proc check_new_derived_with_rtti {var_name var_type testname} { 101 1.1 christos set varobj_name VAR 102 1.1 christos mi_create_varobj_checked ${varobj_name} ${var_name} ${var_type} \ 103 1.1 christos "create varobj for ${var_name} (with RTTI) in $testname" 104 1.1 christos check_derived_with_rtti ${varobj_name} ${var_name} $testname 105 1.1 christos mi_delete_varobj ${varobj_name} \ 106 1.1 christos "delete varobj for ${var_name} (with RTTI) in $testname" 107 1.1 christos } 108 1.1 christos 109 1.10 christos set inline_tests { 110 1.10 christos use_rtti_for_ptr 111 1.10 christos use_rtti_for_ref 112 1.10 christos use_rtti_for_ptr_child 113 1.10 christos use_rtti_for_ref_child 114 1.10 christos use_rtti_with_multiple_inheritence 115 1.10 christos type_update_when_use_rtti 116 1.10 christos skip_type_update_when_not_use_rtti 117 1.10 christos } 118 1.10 christos 119 1.10 christos foreach_with_prefix inline_test $inline_tests { 120 1.10 christos if { [mi_run_inline_test $inline_test] < 0 } { 121 1.10 christos return -1 122 1.10 christos } 123 1.10 christos } 124 1.1 christos 125 1.1 christos mi_gdb_exit 126