mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-15 04:31:49 +08:00
ef7a6b977b
After this commit the gcc_compiled global is no longer exported from lib/gdb.exp. In theory we could switch over all uses of gcc_compiled to instead call test_compiler_info directly, however, I have instead added a new proc to gdb.exp: 'is_c_compiler_gcc'. I've then updated the testsuite to call this proc instead of using the global. Having a new proc specifically for this task means that we have a single consistent pattern for detecting gcc. By wrapping this logic within a proc that calls test_compiler_info, rather than using the global, means that test scripts don't need to call get_compiler_info before they read the global, simply calling the new proc does everything in one go. As a result I've been able to remove the get_compiler_info calls from all the test scripts that I've touched in this commit. In some of the tests e.g. gdb.dwarf2/*.exp, the $gcc_compiled flag was being checked at the top of the script to decide if the whole script should be skipped or not. In these cases I've called the new proc directly and removed all uses of gcc_compiled. In other cases, e.g. most of the gdb.base scripts, there were many uses of gcc_compiled. In these cases I set a new global gcc_compiled near the top of the script, and leave the rest of the script unchanged. There should be no changes in what is tested after this commit.
110 lines
3.3 KiB
Plaintext
110 lines
3.3 KiB
Plaintext
# Copyright 2006-2022 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
# Please email any bugs, comments, and/or additions to this file to:
|
|
# bug-gdb@gnu.org
|
|
|
|
# This file was written by Alexandre Oliva <aoliva@redhat.com>
|
|
|
|
|
|
if { ![isnative] || [is_remote host] || [skip_shlib_tests]} {
|
|
return
|
|
}
|
|
|
|
if {![is_c_compiler_gcc]} {
|
|
unsupported "gcc compiler is required"
|
|
return -1
|
|
}
|
|
|
|
load_lib prelink-support.exp
|
|
|
|
set testfile "prelink"
|
|
|
|
set libsrcfile ${testfile}-lib.c
|
|
set libfile [standard_output_file ${testfile}.so]
|
|
|
|
# Use -soname so that the new library gets copied by build_executable_own_libs.
|
|
|
|
if { [gdb_compile_shlib "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" [list debug "ldflags=-Wl,-soname,[file tail ${libfile}]"]] != ""} {
|
|
# If creating the shared library fails, maybe we don't have the right tools
|
|
return -1
|
|
}
|
|
|
|
set srcfile ${testfile}.c
|
|
set executable ${testfile}t
|
|
set binfile [standard_output_file ${executable}]
|
|
set prelink_args [build_executable_own_libs ${testfile}.exp $executable $srcfile [list debug "ldflags=-Wl,${libfile},-rpath,[file dirname ${libfile}]"]]
|
|
if {$prelink_args == ""} {
|
|
return -1
|
|
}
|
|
|
|
set test "split debug of executable"
|
|
if [gdb_gnu_strip_debug $binfile] {
|
|
fail $test
|
|
} else {
|
|
pass $test
|
|
}
|
|
|
|
if ![prelink_yes $prelink_args] {
|
|
# Maybe we don't have prelink.
|
|
return -1
|
|
}
|
|
|
|
set found 0
|
|
set coredir "[standard_output_file coredir.[getpid]]"
|
|
file mkdir $coredir
|
|
catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
|
|
|
|
foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
|
|
if [remote_file build exists $i] {
|
|
remote_exec build "mv $i [standard_output_file prelink.core]"
|
|
set found 1
|
|
}
|
|
}
|
|
# Check for "core.PID".
|
|
if { $found == 0 } {
|
|
set names [glob -nocomplain -directory $coredir core.*]
|
|
if {[llength $names] == 1} {
|
|
set corefile [file join $coredir [lindex $names 0]]
|
|
remote_exec build "mv $corefile [standard_output_file prelink.core]"
|
|
set found 1
|
|
}
|
|
}
|
|
|
|
# Try to clean up after ourselves.
|
|
remote_file build delete [file join $coredir coremmap.data]
|
|
remote_exec build "rmdir $coredir"
|
|
|
|
if { $found == 0 } {
|
|
warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
|
|
return 0
|
|
}
|
|
|
|
# Relink $libfile to a different address.
|
|
if ![prelink_yes $prelink_args] {
|
|
return -1
|
|
}
|
|
|
|
# Start with a fresh gdb
|
|
|
|
clean_restart $executable
|
|
|
|
# Print the "adjusting expectations" message.
|
|
gdb_test_no_output "set verbose on"
|
|
|
|
gdb_test "core-file [standard_output_file prelink.core]" "Using PIC \\(Position Independent Code\\) prelink displacement 0x\[^0\]\[0-9a-f\]* for \[^\r\n\]*[file tail ${libfile}].*" "seen displacement message"
|
|
|
|
gdb_test "p &bssvar == bssvarp" " = 1" ".dynbss vs. .bss address shift"
|