Index: gdb/testsuite/ChangeLog =================================================================== RCS file: /cvs/src/src/gdb/testsuite/ChangeLog,v retrieving revision 1.3682 diff -u -r1.3682 ChangeLog --- gdb/testsuite/ChangeLog 30 May 2013 00:25:16 -0000 1.3682 +++ gdb/testsuite/ChangeLog 4 Jun 2013 13:20:02 -0000 @@ -1,3 +1,19 @@ +2013-06-04 Jan Kratochvil + Gary Benson + + * 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 * gdb.mi/mi-cmd-param-changed.exp (test_command_param_changed): Index: gdb/testsuite/lib/gdb.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/gdb.exp,v retrieving revision 1.231 diff -u -r1.231 gdb.exp --- gdb/testsuite/lib/gdb.exp 6 May 2013 22:11:15 -0000 1.231 +++ gdb/testsuite/lib/gdb.exp 4 Jun 2013 13:20:08 -0000 @@ -4051,31 +4051,6 @@ 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 - } - - set pthreads [lsearch -exact $options "pthreads"] - if { $pthreads >= 0 } { - set options [lreplace $options $pthreads $pthreads] - if { [gdb_compile_pthreads $objects "${binfile}" executable $options] != "" } { - untested $testname - return -1 - } - } else { - if { [gdb_compile $objects "${binfile}" executable $options] != "" } { - untested $testname - return -1 - } - } - set info_options "" if { [lsearch -exact $options "c++"] >= 0 } { set info_options "c++" @@ -4083,6 +4058,42 @@ 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/testsuite/lib/prelink-support.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/lib/prelink-support.exp,v retrieving revision 1.6 diff -u -r1.6 prelink-support.exp --- gdb/testsuite/lib/prelink-support.exp 1 Jan 2013 06:41:28 -0000 1.6 +++ gdb/testsuite/lib/prelink-support.exp 4 Jun 2013 13:20:08 -0000 @@ -95,8 +95,9 @@ # 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 @@ 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 @@ # 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 } Index: gdb/testsuite/gdb.base/break-interp.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/break-interp.exp,v retrieving revision 1.40 diff -u -r1.40 break-interp.exp --- gdb/testsuite/gdb.base/break-interp.exp 15 Mar 2013 01:41:28 -0000 1.40 +++ gdb/testsuite/gdb.base/break-interp.exp 4 Jun 2013 13:20:03 -0000 @@ -109,12 +109,19 @@ } } +# 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 @@ 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 @@ fail $test_displacement } - if {$func == "_dl_debug_state"} { + if {$func == $solib_bp} { gdb_test_no_output "set stop-on-solib-events 0" } } @@ -361,7 +368,7 @@ } 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. @@ -389,9 +396,9 @@ 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" @@ -403,7 +410,7 @@ # 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 @@ -435,7 +442,7 @@ 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/testsuite/gdb.threads/dlopen-libpthread.exp =================================================================== RCS file: gdb/testsuite/gdb.threads/dlopen-libpthread.exp diff -N gdb/testsuite/gdb.threads/dlopen-libpthread.exp --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.threads/dlopen-libpthread.exp 4 Jun 2013 13:20:05 -0000 @@ -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 . + +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/testsuite/gdb.threads/dlopen-libpthread.c =================================================================== RCS file: gdb/testsuite/gdb.threads/dlopen-libpthread.c diff -N gdb/testsuite/gdb.threads/dlopen-libpthread.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.threads/dlopen-libpthread.c 4 Jun 2013 13:20:05 -0000 @@ -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 . */ + +#include +#include +#include + +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/testsuite/gdb.threads/dlopen-libpthread-lib.c =================================================================== RCS file: gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c diff -N gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 4 Jun 2013 13:20:05 -0000 @@ -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 . */ + +#include +#include + +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/testsuite/gdb.base/solib-corrupted.exp =================================================================== RCS file: /cvs/src/src/gdb/testsuite/gdb.base/solib-corrupted.exp,v retrieving revision 1.8 diff -u -r1.8 solib-corrupted.exp --- gdb/testsuite/gdb.base/solib-corrupted.exp 1 Jan 2013 06:33:26 -0000 1.8 +++ gdb/testsuite/gdb.base/solib-corrupted.exp 4 Jun 2013 13:20:04 -0000 @@ -36,6 +36,33 @@ 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.