gdb/ChangeLog:
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / prelink.exp
1 # Copyright 2006 Free Software Foundation, Inc.
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
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
16
17 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-gdb@prep.ai.mit.edu
19
20 # This file was written by Alexandre Oliva <aoliva@redhat.com>
21
22 if $tracelevel then {
23 strace $tracelevel
24 }
25
26 set prms_id 0
27 set bug_id 0
28
29 # are we on a target board
30 if ![isnative] then {
31 return
32 }
33
34 if [get_compiler_info "ignored"] {
35 return -1
36 }
37
38 if {$gcc_compiled == 0} {
39 return -1
40 }
41
42 set testfile "prelink"
43 set srcfile ${testfile}.c
44 set binfile ${objdir}/${subdir}/${testfile}
45
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
50 return -1
51 }
52
53 if {[catch "system \"prelink -NR ${libfile}\""] != 0} {
54 # Maybe we don't have prelink.
55 return -1
56 }
57
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}"]] != ""} {
61 return -1;
62 }
63
64 set found 0
65 set coredir "${objdir}/${subdir}/coredir.[getpid]"
66 file mkdir $coredir
67 catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\""
68
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"
72 set found 1
73 }
74 }
75 # Check for "core.PID".
76 if { $found == 0 } {
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"
81 set found 1
82 }
83 }
84
85 catch "system \"prelink -u ${libfile}\""
86 catch "system \"prelink -NR ${libfile}\""
87
88 # Try to clean up after ourselves.
89 remote_file build delete [file join $coredir coremmap.data]
90 remote_exec build "rmdir $coredir"
91
92 if { $found == 0 } {
93 warning "can't generate a core file - prelink tests suppressed - check ulimit -c"
94 return 0
95 }
96
97 # Start with a fresh gdb
98
99 gdb_exit
100 gdb_start
101 gdb_reinitialize_dir $srcdir/$subdir
102 gdb_load ${binfile}
103
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"
108 gdb_expect {
109 -re "warning: \.dynamic section.*not at the expected address" {
110 pass "changed base address"
111 }
112 -re ".*$gdb_prompt $" { fail "changed base address" }
113 timeout { fail "(timeout) changed base address" }
114 }
115 gdb_expect {
116 -re "warning: difference.*caused by prelink, adjusting" {
117 pass "prelink adjustment"
118 }
119 -re ".*$gdb_prompt $" { fail "prelink adjustment" }
120 timeout { fail "(timeout) prelink adjustment" }
121 }
122 set timeout $oldtimeout
123 verbose "Timeout is now $timeout seconds" 2
124
125 gdb_exit
126
127 return 0
128
This page took 0.040618 seconds and 5 git commands to generate.