]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/prelink.exp
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / prelink.exp
CommitLineData
6aba47ca 1# Copyright 2006, 2007 Free Software Foundation, Inc.
cc10cae3
AO
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
5f4a23d9 15# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
cc10cae3
AO
16
17# Please email any bugs, comments, and/or additions to this file to:
5f4a23d9 18# bug-gdb@gnu.org
cc10cae3
AO
19
20# This file was written by Alexandre Oliva <aoliva@redhat.com>
21
22if $tracelevel then {
23 strace $tracelevel
24 }
25
26set prms_id 0
27set bug_id 0
28
29# are we on a target board
30if ![isnative] then {
31 return
32}
33
34if [get_compiler_info "ignored"] {
35 return -1
36}
37
38if {$gcc_compiled == 0} {
39 return -1
40}
41
42set testfile "prelink"
cc10cae3
AO
43
44set libsrcfile ${testfile}-lib.c
45set libfile ${objdir}/${subdir}/${testfile}.so
46if { [gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" executable [list debug "additional_flags=-fpic -shared -nodefaultlibs"]] != ""} {
47 # If creating the shared library fails, maybe we don't have the right tools
48 return -1
49}
50
5f4a23d9 51if {[catch "system \"prelink -qNR ${libfile}\""] != 0} {
cc10cae3
AO
52 # Maybe we don't have prelink.
53 return -1
54}
55
56set srcfile ${testfile}.c
5f4a23d9 57set binfile ${objdir}/${subdir}/${testfile}t
cc10cae3
AO
58if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} {
59 return -1;
60}
61
62set found 0
63set coredir "${objdir}/${subdir}/coredir.[getpid]"
64file mkdir $coredir
65catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
66
67foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
68 if [remote_file build exists $i] {
69 remote_exec build "mv $i ${objdir}/${subdir}/prelink.core"
70 set found 1
71 }
72}
73# Check for "core.PID".
74if { $found == 0 } {
75 set names [glob -nocomplain -directory $coredir core.*]
76 if {[llength $names] == 1} {
77 set corefile [file join $coredir [lindex $names 0]]
78 remote_exec build "mv $corefile ${objdir}/${subdir}/prelink.core"
79 set found 1
80 }
81}
82
cc10cae3
AO
83# Try to clean up after ourselves.
84remote_file build delete [file join $coredir coremmap.data]
85remote_exec build "rmdir $coredir"
86
87if { $found == 0 } {
88 warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
89 return 0
90}
91
5f4a23d9
AO
92if {[catch "system \"prelink -uN ${libfile}\""] != 0} {
93 untested "${libfile} was not prelinked, maybe system libraries are not prelinked?"
94 return 0
95}
96catch "system \"prelink -qNR ${libfile}\""
97
cc10cae3
AO
98# Start with a fresh gdb
99
100gdb_exit
101gdb_start
102gdb_reinitialize_dir $srcdir/$subdir
103gdb_load ${binfile}
104
5f4a23d9 105set test "prelink"
831004b7 106global gdb_prompt
5f4a23d9 107gdb_test_multiple "core-file $objdir/$subdir/prelink.core" "$test" {
831004b7 108 -re "warning: \.dynamic section.*not at the expected address.*warning: difference.*caused by prelink, adjusting expectations.*$gdb_prompt $" {
5f4a23d9 109 pass "$test"
cc10cae3 110 }
cc10cae3 111}
cc10cae3
AO
112
113gdb_exit
114
115return 0
116