1 # Copyright 2006 Free Software Foundation, Inc.
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.
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.
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
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
20 # This file was written by Alexandre Oliva <aoliva@redhat.com>
29 # are we on a target board
34 if [get_compiler_info "ignored"] {
38 if {$gcc_compiled == 0} {
42 set testfile "prelink"
43 set srcfile ${testfile}.c
44 set binfile ${objdir}/${subdir}/${testfile}
46 set libsrcfile ${testfile}-lib.c
47 set libfile ${objdir}/${subdir}/${testfile}.so
48 if { [gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" executable [list debug "additional_flags=-fpic -shared -nodefaultlibs"]] != ""} {
49 # If creating the shared library fails, maybe we don't have the right tools
53 if {[catch "system \"prelink -NR ${libfile}\""] != 0} {
54 # Maybe we don't have prelink.
58 set srcfile ${testfile}.c
59 set binfile ${objdir}/${subdir}/${testfile}
60 if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} {
65 set coredir "${objdir}/${subdir}/coredir.[getpid]"
67 catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
69 foreach i "${coredir}/core ${coredir}/core.coremaker.c ${binfile}.core" {
70 if [remote_file build exists $i] {
71 remote_exec build "mv $i ${objdir}/${subdir}/prelink.core"
75 # Check for "core.PID".
77 set names [glob -nocomplain -directory $coredir core.*]
78 if {[llength $names] == 1} {
79 set corefile [file join $coredir [lindex $names 0]]
80 remote_exec build "mv $corefile ${objdir}/${subdir}/prelink.core"
85 catch "system \"prelink -u ${libfile}\""
86 catch "system \"prelink -NR ${libfile}\""
88 # Try to clean up after ourselves.
89 remote_file build delete [file join $coredir coremmap.data]
90 remote_exec build "rmdir $coredir"
93 warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
97 # Start with a fresh gdb
101 gdb_reinitialize_dir $srcdir/$subdir
104 set oldtimeout $timeout
105 set timeout [expr "$timeout + 60"]
106 verbose "Timeout is now $timeout seconds" 2
107 send_gdb "core-file $objdir/$subdir/prelink.core\n"
109 -re "warning: \.dynamic section.*not at the expected address" {
110 pass "changed base address"
112 -re ".*$gdb_prompt $" { fail "changed base address" }
113 timeout { fail "(timeout) changed base address" }
116 -re "warning: difference.*caused by prelink, adjusting" {
117 pass "prelink adjustment"
119 -re ".*$gdb_prompt $" { fail "prelink adjustment" }
120 timeout { fail "(timeout) prelink adjustment" }
122 set timeout $oldtimeout
123 verbose "Timeout is now $timeout seconds" 2