blob: 8d1ba4d2e8ea5a20f7e07219a530466f3209661b [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.
# This test file specifically tests for when the linker emits the debug
# information for the class AFTER the debug information for the executable.
# The debugger is supposed to handle this correctly, and only certain
# linkers reorder things in this way while they're emitting the coalesced
# debug info stuff.
if $tracelevel then {
strace $tracelevel
}
#
# test running programs
#
set prms_id 0
set bug_id 0
set testfile "coalesced2"
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 coalesced2a"]" "Breakpoint 1 at $hex: file.*, line.*\\." "Set breakpoint on line 'good place to stop in coalesced2a'"
set srcfile $srcfile2
gdb_test "break $srcfile:[gdb_get_line_number "good place to stop in coalesced2b"]" "Breakpoint 2 at $hex: file.*, line.*\\." "Set breakpoint on line 'good place to stop in coalesced2b'"
gdb_test "run" "Starting program: $binfile *\r\n\Reading symbols for shared libraries \(\[.+\]\)+ done.*Breakpoint 1, main.*" "run to breakpoint in coalesced2a"
gdb_test "print ddddd" ".*$decimal = 54" "print contents of 'ddddd' in coalesced2a.cc"
gdb_test "cont" "Continuing.*Breakpoint 2.*" "run to breakpoint in coalesced2b"
gdb_test "print ddddd" ".*$decimal = 54" "print contents of 'ddddd' in coalesced2b.cc"
gdb_exit
return 0