You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

463 lines
16 KiB

http://sourceware.org/ml/gdb-cvs/2013-06/msg00019.html
### src/gdb/testsuite/ChangeLog 2013/05/30 00:25:16 1.3682
### src/gdb/testsuite/ChangeLog 2013/06/04 13:23:31 1.3683
## -1,3 +1,19 @@
+2013-06-04 Jan Kratochvil <jan.kratochvil@redhat.com>
+ Gary Benson <gbenson@redhat.com>
+
+ * lib/gdb.exp (build_executable_from_specs): Use gdb_compile_pthread,
+ gdb_compile_shlib or gdb_compile_shlib_pthreads where appropriate.
+ * lib/prelink-support.exp (build_executable_own_libs): Allow INTERP
+ to be set to "no" to indicate that no ld.so copy should be made.
+ * gdb.base/break-interp.exp (solib_bp): New constant.
+ (reach_1): Use the above instead of "_dl_debug_state".
+ (test_attach): Likewise.
+ (test_ld): Likewise.
+ * gdb.threads/dlopen-libpthread.exp: New file.
+ * gdb.threads/dlopen-libpthread.c: Likewise.
+ * gdb.threads/dlopen-libpthread-lib.c: Likewise.
+ * gdb.base/solib-corrupted.exp: Disable test if GDB is using probes.
+
2013-05-30 Yao Qi <yao@codesourcery.com>
* gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed):
Index: gdb-7.6/gdb/testsuite/gdb.base/break-interp.exp
===================================================================
--- gdb-7.6.orig/gdb/testsuite/gdb.base/break-interp.exp 2013-06-10 14:29:24.815123941 +0200
+++ gdb-7.6/gdb/testsuite/gdb.base/break-interp.exp 2013-06-10 14:30:18.086102375 +0200
@@ -109,12 +109,19 @@ proc strip_debug {dest} {
}
}
+# The marker function for the standard runtime linker interface is
+# _dl_debug_state. The probes-based interface has no specific marker
+# function; the probe we will stop on (init_start) is in dl_main so we
+# check for that.
+
+set solib_bp {(_dl_debug_state|dl_main)}
+
# Implementation of reach.
proc reach_1 {func command displacement} {
- global gdb_prompt expect_out
+ global gdb_prompt expect_out solib_bp
- if {$func == "_dl_debug_state"} {
+ if {$func == $solib_bp} {
# Breakpoint on _dl_debug_state can have problems due to its overlap
# with the existing internal breakpoint from GDB.
gdb_test_no_output "set stop-on-solib-events 1"
@@ -142,21 +149,21 @@ proc reach_1 {func command displacement}
exp_continue
}
-re "Breakpoint \[0-9\]+, \\.?(__GI_)?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
- if {$func == "_dl_debug_state"} {
+ if {$func == $solib_bp} {
fail $test
} else {
pass $test
}
}
-re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?(__GI_)?$func \\(\\).*\r\n$gdb_prompt $" {
- if {$func == "_dl_debug_state"} {
+ if {$func == $solib_bp} {
fail $test
} else {
pass $test
}
}
-re "Stopped due to (spurious )?shared library event.*\r\n$gdb_prompt $" {
- if {$func == "_dl_debug_state"} {
+ if {$func == $solib_bp} {
if {$debug_state_count == 0} {
# First stop does not yet relocate the _start function
# descriptor on ppc64.
@@ -175,7 +182,7 @@ proc reach_1 {func command displacement}
fail $test_displacement
}
- if {$func == "_dl_debug_state"} {
+ if {$func == $solib_bp} {
gdb_test_no_output "set stop-on-solib-events 0"
}
}
@@ -357,7 +364,7 @@ proc test_attach {file displacement {rel
}
proc test_ld {file ifmain trynosym displacement} {
- global srcdir subdir gdb_prompt expect_out inferior_exited_re
+ global srcdir subdir gdb_prompt expect_out inferior_exited_re solib_bp
# First test normal `file'-command loaded $FILE with symbols.
@@ -385,9 +392,9 @@ proc test_ld {file ifmain trynosym displ
gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test"
}
- reach "_dl_debug_state" "run" $displacement
+ reach $solib_bp "run" $displacement
- gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?_dl_debug_state\\M.*" "dl bt"
+ gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt"
if $ifmain {
reach "main" continue "NONE"
@@ -399,7 +406,7 @@ proc test_ld {file ifmain trynosym displ
# Try re-run if the new PIE displacement takes effect.
gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y"
- reach "_dl_debug_state" "run" $displacement
+ reach $solib_bp "run" $displacement
if $ifmain {
test_core $file $displacement
@@ -431,7 +438,7 @@ proc test_ld {file ifmain trynosym displ
gdb_test "exec-file $file" "exec-file $escapedfile" "load"
if $ifmain {
- reach "_dl_debug_state" run $displacement
+ reach $solib_bp run $displacement
# Use two separate gdb_test_multiple statements to avoid timeouts due
# to slow processing of wildcard capturing long output
Index: gdb-7.6/gdb/testsuite/gdb.base/solib-corrupted.exp
===================================================================
--- gdb-7.6.orig/gdb/testsuite/gdb.base/solib-corrupted.exp 2013-06-10 14:29:24.816123941 +0200
+++ gdb-7.6/gdb/testsuite/gdb.base/solib-corrupted.exp 2013-06-10 14:30:18.086102375 +0200
@@ -36,6 +36,33 @@ if ![runto_main] {
return
}
+# With probes interface GDB no longer scans the inferior library list so its
+# corruption cannot be tested. There is no way to disable the probes
+# interface.
+
+set probes { init_start init_complete map_start reloc_complete unmap_start
+ unmap_complete }
+set test "info probes"
+gdb_test_multiple $test $test {
+ -re "^rtld\[ \t\]+(?:rtld_)?(\[a-z_\]+)\[ \t\]" {
+ set idx [lsearch -exact $probes $expect_out(1,string)]
+ if { $idx >= 0 } {
+ set probes [lreplace $probes $idx $idx]
+ }
+ exp_continue
+ }
+ -re "^\[^\r\n\]*\r\n" {
+ exp_continue
+ }
+ -re "^$gdb_prompt $" {
+ }
+}
+if { [llength $probes] == 0 } {
+ xfail $test
+ untested "GDB is using probes"
+ return
+}
+
gdb_test "info sharedlibrary" "From * To .*" "normal list"
# GDB checks there for matching L_PREV.
Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2013-06-10 14:30:18.086102375 +0200
@@ -0,0 +1,40 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011-2013 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 3 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, see <http://www.gnu.org/licenses/>. */
+
+#include <pthread.h>
+#include <assert.h>
+
+static void *
+tfunc (void *arg)
+{
+ void (*notifyp) (void) = arg;
+
+ notifyp ();
+}
+
+void
+f (void (*notifyp) (void))
+{
+ pthread_t t;
+ int i;
+
+ i = pthread_create (&t, NULL, tfunc, notifyp);
+ assert (i == 0);
+
+ i = pthread_join (t, NULL);
+ assert (i == 0);
+}
Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.c
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2013-06-10 14:30:18.087102375 +0200
@@ -0,0 +1,46 @@
+/* This testcase is part of GDB, the GNU debugger.
+
+ Copyright 2011-2013 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 3 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, see <http://www.gnu.org/licenses/>. */
+
+#include <dlfcn.h>
+#include <stddef.h>
+#include <assert.h>
+
+static const char *volatile filename;
+
+static void
+notify (void)
+{
+ filename = NULL; /* notify-here */
+}
+
+int
+main (void)
+{
+ void *h;
+ void (*fp) (void (*) (void));
+
+ assert (filename != NULL);
+ h = dlopen (filename, RTLD_LAZY);
+ assert (h != NULL);
+
+ fp = dlsym (h, "f");
+ assert (fp != NULL);
+
+ fp (notify);
+
+ return 0;
+}
Index: gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.exp
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ gdb-7.6/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2013-06-10 14:30:18.087102375 +0200
@@ -0,0 +1,74 @@
+# Copyright 2011-2013 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 3 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, see <http://www.gnu.org/licenses/>.
+
+if {![istarget *-linux*] || [skip_shlib_tests]} {
+ return 0
+}
+
+load_lib prelink-support.exp
+
+set testfile "dlopen-libpthread"
+set srcmainfile ${testfile}.c
+set srclibfile ${testfile}-lib.c
+set executable ${testfile}
+set binfile_lib ${objdir}/${subdir}/${executable}.so
+set binfile ${objdir}/${subdir}/${executable}
+set lib_dlopen [shlib_target_file ${executable}.so]
+
+# Use build_executable_own_libs as prelinked libpthread.so can produce false
+# PASS - it is OK if GDB processes it still before relocation.
+
+set relink_args [build_executable_own_libs ${testfile}.exp ${executable}.so $srclibfile {debug shlib_pthreads} no]
+if {$relink_args == "" || ![prelink_no $relink_args]
+ || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug shlib_load}] } {
+ return -1
+}
+gdb_load_shlibs $binfile_lib
+
+if { ![runto_main] } {
+ return -1
+}
+
+set test "info probes all rtld rtld_map_complete"
+gdb_test_multiple $test $test {
+ -re "\[ \t\]rtld_map_complete\[ \t\]+0x\[0-9a-f\]+.*\r\n$gdb_prompt $" {
+ pass $test
+ }
+ -re "No probes matched\\.\r\n$gdb_prompt $" {
+ xfail $test
+ untested ${testfile}.exp
+ return
+ }
+}
+
+set test "libpthread.so not found"
+gdb_test_multiple "info sharedlibrary" $test {
+ -re "/libpthread\\.so.*\r\n$gdb_prompt $" {
+ fail $test
+ }
+ -re "/libc\\.so.*\r\n$gdb_prompt $" {
+ pass $test
+ }
+}
+
+gdb_test "set variable filename=\"$lib_dlopen\""
+
+gdb_breakpoint "notify"
+
+# The error was:
+# Cannot find new threads: generic error
+gdb_continue_to_breakpoint "notify" ".* notify-here .*"
+
+gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found"
Index: gdb-7.6/gdb/testsuite/lib/gdb.exp
===================================================================
--- gdb-7.6.orig/gdb/testsuite/lib/gdb.exp 2013-06-10 14:29:24.819123940 +0200
+++ gdb-7.6/gdb/testsuite/lib/gdb.exp 2013-06-10 14:30:44.654092140 +0200
@@ -4011,22 +4011,6 @@ proc build_executable_from_specs {testna
set binfile [standard_output_file $executable]
- set objects {}
- set i 0
- foreach {s local_options} $args {
- if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } {
- untested $testname
- return -1
- }
- lappend objects "${binfile}${i}.o"
- incr i
- }
-
- if { [gdb_compile $objects "${binfile}" executable $options] != "" } {
- untested $testname
- return -1
- }
-
set info_options ""
if { [lsearch -exact $options "c++"] >= 0 } {
set info_options "c++"
@@ -4034,6 +4018,42 @@ proc build_executable_from_specs {testna
if [get_compiler_info ${info_options}] {
return -1
}
+
+ set binfile [standard_output_file $executable]
+
+ set func gdb_compile
+ set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads)$}]
+ if {$func_index != -1} {
+ set func "${func}_[lindex $options $func_index]"
+ }
+
+ # gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd
+ # parameter. They also requires $sources while gdb_compile and
+ # gdb_compile_pthreads require $objects. Moreover they ignore any options.
+ if [string match gdb_compile_shlib* $func] {
+ set sources_path {}
+ foreach {s local_options} $args {
+ lappend sources_path "${srcdir}/${subdir}/${s}"
+ }
+ set ret [$func $sources_path "${binfile}" $options]
+ } else {
+ set objects {}
+ set i 0
+ foreach {s local_options} $args {
+ if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } {
+ untested $testname
+ return -1
+ }
+ lappend objects "${binfile}${i}.o"
+ incr i
+ }
+ set ret [$func $objects "${binfile}" executable $options]
+ }
+ if { $ret != "" } {
+ untested $testname
+ return -1
+ }
+
return 0
}
Index: gdb-7.6/gdb/testsuite/lib/prelink-support.exp
===================================================================
--- gdb-7.6.orig/gdb/testsuite/lib/prelink-support.exp 2013-06-10 14:29:24.819123940 +0200
+++ gdb-7.6/gdb/testsuite/lib/prelink-support.exp 2013-06-10 14:30:18.089102374 +0200
@@ -95,8 +95,9 @@ proc file_copy {src dest} {
# Wrap function build_executable so that the resulting executable is fully
# self-sufficient (without dependencies on system libraries). Parameter
# INTERP may be used to specify a loader (ld.so) to be used that is
-# different from the default system one. Libraries on which the executable
-# depends are copied into directory DIR. Default DIR value to
+# different from the default system one. INTERP can be set to "no" if no ld.so
+# copy should be made. Libraries on which the executable depends are copied
+# into directory DIR. Default DIR value to
# `${objdir}/${subdir}/${EXECUTABLE}.d'.
#
# In case of success, return a string containing the arguments to be used
@@ -151,8 +152,15 @@ proc build_executable_own_libs {testname
if {$interp == ""} {
set interp_system [section_get $binfile .interp]
- set interp ${dir}/[file tail $interp_system]
- file_copy $interp_system $interp
+ if {$interp_system == ""} {
+ fail "$test could not find .interp"
+ } else {
+ set interp ${dir}/[file tail $interp_system]
+ file_copy $interp_system $interp
+ }
+ }
+ if {$interp == "no"} {
+ set interp ""
}
set dests {}
@@ -164,13 +172,19 @@ proc build_executable_own_libs {testname
# Do not lappend it so that "-rpath $dir" overrides any possible "-rpath"s
# specified by the caller to be able to link it for ldd" above.
- set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp,-rpath,$dir"]
+ set options [linsert $options 0 "ldflags=-Wl,-rpath,$dir"]
+ if {$interp != ""} {
+ set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp"]
+ }
if {[build_executable $testname $executable $sources $options] == -1} {
return ""
}
- set prelink_args "--dynamic-linker=$interp --ld-library-path=$dir $binfile $interp [concat $dests]"
+ set prelink_args "--ld-library-path=$dir $binfile [concat $dests]"
+ if {$interp != ""} {
+ set prelink_args "--dynamic-linker=$interp $prelink_args $interp"
+ }
return $prelink_args
}