]>
Commit | Line | Data |
---|---|---|
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 | ||
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" | |
cc10cae3 AO |
43 | |
44 | set libsrcfile ${testfile}-lib.c | |
45 | set libfile ${objdir}/${subdir}/${testfile}.so | |
46 | if { [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 | 51 | if {[catch "system \"prelink -qNR ${libfile}\""] != 0} { |
cc10cae3 AO |
52 | # Maybe we don't have prelink. |
53 | return -1 | |
54 | } | |
55 | ||
56 | set srcfile ${testfile}.c | |
5f4a23d9 | 57 | set binfile ${objdir}/${subdir}/${testfile}t |
cc10cae3 AO |
58 | if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} { |
59 | return -1; | |
60 | } | |
61 | ||
62 | set found 0 | |
63 | set coredir "${objdir}/${subdir}/coredir.[getpid]" | |
64 | file mkdir $coredir | |
65 | catch "system \"(cd ${coredir}; ulimit -c unlimited; ${binfile}; true) >/dev/null 2>&1\"" | |
66 | ||
67 | foreach 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". | |
74 | if { $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. |
84 | remote_file build delete [file join $coredir coremmap.data] | |
85 | remote_exec build "rmdir $coredir" | |
86 | ||
87 | if { $found == 0 } { | |
88 | warning "can't generate a core file - prelink tests suppressed - check ulimit -c" | |
89 | return 0 | |
90 | } | |
91 | ||
5f4a23d9 AO |
92 | if {[catch "system \"prelink -uN ${libfile}\""] != 0} { |
93 | untested "${libfile} was not prelinked, maybe system libraries are not prelinked?" | |
94 | return 0 | |
95 | } | |
96 | catch "system \"prelink -qNR ${libfile}\"" | |
97 | ||
cc10cae3 AO |
98 | # Start with a fresh gdb |
99 | ||
100 | gdb_exit | |
101 | gdb_start | |
102 | gdb_reinitialize_dir $srcdir/$subdir | |
103 | gdb_load ${binfile} | |
104 | ||
5f4a23d9 | 105 | set test "prelink" |
831004b7 | 106 | global gdb_prompt |
5f4a23d9 | 107 | gdb_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 | |
113 | gdb_exit | |
114 | ||
115 | return 0 | |
116 |