| # Copyright 2006 Free Software Foundation, Inc. |
| |
| # This program is free software; you can redistribute it and/or modify |
| # it under the terms of the GNU General Public License as published by |
| # the Free Software Foundation; either version 2 of the License, or |
| # (at your option) any later version. |
| # |
| # This program is distributed in the hope that it will be useful, |
| # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| # GNU General Public License for more details. |
| # |
| # You should have received a copy of the GNU General Public License |
| # along with this program; if not, write to the Free Software |
| # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| |
| |
| # When compiling with DWARF, gcc only emits the debug definition of a class in |
| # the compilation unit where it is defined if the class has a virtual ctor/dtor. |
| # We can take advantage of that when we process the DWARF debug map in the |
| # executable to note which CU has the class definition. Then when the user |
| # examines an object of that class w/o visiting the defining CU, gdb finds the |
| # type in the psymtab list and expands the defining CU's symtab, picking up the |
| # definition. |
| |
| # In short, test that gdb knows the definition of class test1abcdefg without |
| # previously expanding the psymtab for single-def-classdef.cc. |
| |
| |
| if $tracelevel then { |
| strace $tracelevel |
| } |
| |
| # |
| # test running programs |
| # |
| |
| set prms_id 0 |
| set bug_id 0 |
| |
| set testfile "single-def" |
| set srcfile1 "${testfile}-main.cc" |
| set objfile1 "${testfile}-main.o" |
| set srcfile2 "${testfile}-classdef.cc" |
| set objfile2 "${testfile}-classdef.o" |
| set binfile "${objdir}/${subdir}/${testfile}" |
| |
| if { [gdb_compile "$srcdir/$subdir/$srcfile1" "$objdir/$subdir/$objfile1" object {debug c++}] != "" } { |
| gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
| } |
| |
| if { [gdb_compile "$srcdir/$subdir/$srcfile2" "$objdir/$subdir/$objfile2" object {debug c++}] != "" } { |
| gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
| } |
| |
| if { [gdb_compile "$objdir/$subdir/$objfile1 $objdir/$subdir/$objfile2" "${binfile}" executable {debug c++}] != "" } { |
| gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail." |
| } |
| |
| if [get_compiler_info ${binfile} "c++"] { |
| return -1 |
| } |
| |
| |
| |
| # Start with a fresh gdb |
| gdb_exit |
| gdb_start |
| gdb_reinitialize_dir $srcdir/$subdir |
| gdb_file_cmd "${binfile}" |
| |
| send_gdb "set width 0\n" |
| gdb_expect -re "$gdb_prompt $" |
| |
| set srcfile $srcfile1 |
| gdb_test "break $srcfile:[gdb_get_line_number "good place to stop in single-def-main"]" "Breakpoint 1 at $hex: file.*, line.*\\." "Set breakpoint on line 'good place to stop in single-def-main'" |
| |
| gdb_test "run" "Starting program: $binfile *\r\n\Reading symbols for shared libraries \(\[.+\]\)+ done.*Breakpoint 1, main.*" "run to breakpoint in single-def-main" |
| |
| gdb_test "p t1" ".*_vptr\\\$test1abcdefg =.*m_uint.*" "examine a test1abcdefg object without visiting single-def-classdef.cc" |
| |
| |
| |
| gdb_exit |
| return 0 |
| |
| |