2014-12-05 Luis Machado gdb/testsuite * gdb.cp/typeid.exp (do_typeid_tests): Do not test type id printing unless the symbols are available. diff --git a/gdb/testsuite/gdb.cp/typeid.exp b/gdb/testsuite/gdb.cp/typeid.exp index 9963a8a..54552d4 100644 --- a/gdb/testsuite/gdb.cp/typeid.exp +++ b/gdb/testsuite/gdb.cp/typeid.exp @@ -25,20 +25,34 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile {debug c++}]} { proc do_typeid_tests {started} { global hex + global gdb_prompt + set symbol_found 1 + + # Try to access one of the symbols to make sure it is available. Some + # architectures put the symbols on relocatable sections, which means + # they will not be accessible before the inferior is running. + gdb_test_multiple "print 'typeinfo for int'" "" { + -re "No symbol \"typeinfo for int\" in current context.*$gdb_prompt $" { + set symbol_found 0 + } + -re ".*$gdb_prompt $" { + } + } # We might see the standard type or gdb's internal type. set type_re "(std::type_info|struct gdb_gnu_v3_type_info)" + if {$symbol_found == 1} { + foreach simple_var {i cp ccp ca b} { + gdb_test "print &typeid($simple_var)" \ + " = \\($type_re \\*\\) $hex.*" - foreach simple_var {i cp ccp ca b} { - gdb_test "print &typeid($simple_var)" \ - " = \\($type_re \\*\\) $hex.*" - - # Note that we test pointer equality rather than object - # equality here. That is because std::type_info's operator== - # is not present in the libstdc++ .so. - gdb_test "print &typeid($simple_var) == &typeid(typeof($simple_var))" \ - " = true" + # Note that we test pointer equality rather than object + # equality here. That is because std::type_info's operator== + # is not present in the libstdc++ .so. + gdb_test "print &typeid($simple_var) == &typeid(typeof($simple_var))" \ + " = true" + } } # typeid for these is Derived. Don't try these tests until the