blob: 3b06bc4043daf7b6451b133e45b1f3f03ede478f [file] [log] [blame]
# Copyright 2005 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.
# Testing the coalescing of C++ inline functions from header files. These
# functions are emitted in each source file that include the header,
# non-inlined when -O0 is used, and coalesced into a single copy by the
# static linker. The static linker also tries to remove all of the debug
# information except one copy when it coalesces these. If that debug
# information defines a type that is later used by gdb, that results in
# <incomplete type> errors.
# When an inline function in a header file returns a type, that type is
# encoded in the FUN stab. With -gused, if this is the first occurence of
# that type, gcc can emit the definition of that type in the middle of the FUN
# stab.
# When the static linker coalesces the multiple copies of that "inline"
# function to a single copy, it strips the FUN stabs in all compilation units
# but one. If those other CUs use the type that was previously defined in
# the FUN stabs, all those variables will now be <incomplete type> when
# debugging.
if $tracelevel then {
strace $tracelevel
}
#
# test running programs
#
set prms_id 0
set bug_id 0
set testfile "coalesced1"
set srcfile1 "${testfile}a.cc"
set objfile1 "${testfile}a.o"
set srcfile2 "${testfile}b.cc"
set objfile2 "${testfile}b.o"
set binfile "${objdir}/${subdir}/${testfile}"
set additional_flags "additional_flags=-gstabs+ -feliminate-unused-debug-symbols"
if [target_info exists darwin64] {
verbose "This test file not applicable for x86-64, skipping."
return
}
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 coalesced1a"]" "Breakpoint 1 at $hex: file.*, line.*\\." "Set breakpoint on line 'good place to stop in coalesced1a'"
set srcfile $srcfile2
gdb_test "break $srcfile:[gdb_get_line_number "good place to stop in coalesced1b"]" "Breakpoint 2 at $hex: file.*, line.*\\." "Set breakpoint on line 'good place to stop in coalesced1b'"
gdb_test "run" "Starting program: $binfile *\r\n\Reading symbols for shared libraries \(\[.+\]\)+ done.*Breakpoint 1, main.*" "run to breakpoint in coalesced1a"
gdb_test "print mmmmm" ".*$decimal = 5" "print contents of 'mmmmm' in coalesced1a.cc"
gdb_test "cont" "Continuing.*Breakpoint 2.*" "run to breakpoint in coalesced1b"
gdb_test "print mmmmm" ".*$decimal = 5" "print contents of 'mmmmm' in coalesced1b.cc"
gdb_exit
return 0