diff options
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/prelink-lib.c | 34 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/prelink.c | 30 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/prelink.exp | 128 |
4 files changed, 197 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index d271dd5ff38..45f07116f39 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-02-28 Alexandre Oliva <aoliva@redhat.com> + + * gdb.base/prelink.exp: New test. + * gdb.base/prelink.c, gdb.base/prelink-lib.c: New sources. + 2006-02-24 Wu Zhou <woodzltc@cn.ibm.com> * gdb.fortran/derived-type.f90: New file. diff --git a/gdb/testsuite/gdb.base/prelink-lib.c b/gdb/testsuite/gdb.base/prelink-lib.c new file mode 100644 index 00000000000..2a712ba434d --- /dev/null +++ b/gdb/testsuite/gdb.base/prelink-lib.c @@ -0,0 +1,34 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2006 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +int +g (void (*p)(void)) +{ + p (); +} + +void +f(void (*p)(void)) { + g (p); +} + +void (*h (void)) (void (*p)(void)) +{ + return f; +} diff --git a/gdb/testsuite/gdb.base/prelink.c b/gdb/testsuite/gdb.base/prelink.c new file mode 100644 index 00000000000..c63d35b2b75 --- /dev/null +++ b/gdb/testsuite/gdb.base/prelink.c @@ -0,0 +1,30 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2006 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <stdio.h> + +extern void (*h (void)) (void (*)(void)); + +int +main (void) +{ + void (*f) (void (*)(void)) = h (); + printf ("%p\n", f); + f (0); +} diff --git a/gdb/testsuite/gdb.base/prelink.exp b/gdb/testsuite/gdb.base/prelink.exp new file mode 100644 index 00000000000..c26d20e278f --- /dev/null +++ b/gdb/testsuite/gdb.base/prelink.exp @@ -0,0 +1,128 @@ +# Copyright 2006 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 2 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, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@prep.ai.mit.edu + +# This file was written by Alexandre Oliva <aoliva@redhat.com> + +if $tracelevel then { + strace $tracelevel + } + +set prms_id 0 +set bug_id 0 + +# are we on a target board +if ![isnative] then { + return +} + +if [get_compiler_info "ignored"] { + return -1 +} + +if {$gcc_compiled == 0} { + return -1 +} + +set testfile "prelink" +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} + +set libsrcfile ${testfile}-lib.c +set libfile ${objdir}/${subdir}/${testfile}.so +if { [gdb_compile "${srcdir}/${subdir}/${libsrcfile}" "${libfile}" executable [list debug "additional_flags=-fpic -shared -nodefaultlibs"]] != ""} { + # If creating the shared library fails, maybe we don't have the right tools + return -1 +} + +if {[catch "system \"prelink -NR ${libfile}\""] != 0} { + # Maybe we don't have prelink. + return -1 +} + +set srcfile ${testfile}.c +set binfile ${objdir}/${subdir}/${testfile} +if { [gdb_compile "${srcdir}/${subdir}/${srcfile} ${libfile}" "${binfile}" executable [list debug "additional_flags=-Wl,-rpath,${objdir}/${subdir}"]] != ""} { + return -1; +} + +set found 0 +set coredir "${objdir}/${subdir}/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 ${objdir}/${subdir}/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 ${objdir}/${subdir}/prelink.core" + set found 1 + } +} + +catch "system \"prelink -u ${libfile}\"" +catch "system \"prelink -NR ${libfile}\"" + +# 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 +} + +# Start with a fresh gdb + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +set oldtimeout $timeout +set timeout [expr "$timeout + 60"] +verbose "Timeout is now $timeout seconds" 2 +send_gdb "core-file $objdir/$subdir/prelink.core\n" +gdb_expect { + -re "warning: \.dynamic section.*not at the expected address" { + pass "changed base address" + } + -re ".*$gdb_prompt $" { fail "changed base address" } + timeout { fail "(timeout) changed base address" } +} +gdb_expect { + -re "warning: difference.*caused by prelink, adjusting" { + pass "prelink adjustment" + } + -re ".*$gdb_prompt $" { fail "prelink adjustment" } + timeout { fail "(timeout) prelink adjustment" } +} +set timeout $oldtimeout +verbose "Timeout is now $timeout seconds" 2 + +gdb_exit + +return 0 + |