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