1 commit 5bfdc32cd3bf373c3b02e1fd864ed8ceab0292b2
2 Author: Jan Kratochvil <jan.kratochvil@redhat.com>
3 Date: Mon Aug 8 12:08:53 2011 +0200
7 Index: gdb-7.4.50.20120714/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c
8 ===================================================================
9 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
10 +++ gdb-7.4.50.20120714/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2012-07-15 08:51:38.238701282 +0200
12 +/* This testcase is part of GDB, the GNU debugger.
14 + Copyright 2011 Free Software Foundation, Inc.
16 + This program is free software; you can redistribute it and/or modify
17 + it under the terms of the GNU General Public License as published by
18 + the Free Software Foundation; either version 3 of the License, or
19 + (at your option) any later version.
21 + This program is distributed in the hope that it will be useful,
22 + but WITHOUT ANY WARRANTY; without even the implied warranty of
23 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 + GNU General Public License for more details.
26 + You should have received a copy of the GNU General Public License
27 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
35 + void (*notifyp) (void) = arg;
41 +f (void (*notifyp) (void))
46 + i = pthread_create (&t, NULL, tfunc, notifyp);
49 + i = pthread_join (t, NULL);
52 Index: gdb-7.4.50.20120714/gdb/testsuite/gdb.threads/dlopen-libpthread.c
53 ===================================================================
54 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
55 +++ gdb-7.4.50.20120714/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2012-07-15 08:51:38.239701277 +0200
57 +/* This testcase is part of GDB, the GNU debugger.
59 + Copyright 2011 Free Software Foundation, Inc.
61 + This program is free software; you can redistribute it and/or modify
62 + it under the terms of the GNU General Public License as published by
63 + the Free Software Foundation; either version 3 of the License, or
64 + (at your option) any later version.
66 + This program is distributed in the hope that it will be useful,
67 + but WITHOUT ANY WARRANTY; without even the implied warranty of
68 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
69 + GNU General Public License for more details.
71 + You should have received a copy of the GNU General Public License
72 + along with this program. If not, see <http://www.gnu.org/licenses/>. */
78 +static const char *volatile filename;
83 + filename = NULL; /* notify-here */
90 + void (*fp) (void (*) (void));
92 + assert (filename != NULL);
93 + h = dlopen (filename, RTLD_LAZY);
96 + fp = dlsym (h, "f");
97 + assert (fp != NULL);
103 Index: gdb-7.4.50.20120714/gdb/testsuite/gdb.threads/dlopen-libpthread.exp
104 ===================================================================
105 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
106 +++ gdb-7.4.50.20120714/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2012-07-15 09:08:01.760258588 +0200
108 +# Copyright 2011 Free Software Foundation, Inc.
110 +# This program is free software; you can redistribute it and/or modify
111 +# it under the terms of the GNU General Public License as published by
112 +# the Free Software Foundation; either version 3 of the License, or
113 +# (at your option) any later version.
115 +# This program is distributed in the hope that it will be useful,
116 +# but WITHOUT ANY WARRANTY; without even the implied warranty of
117 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
118 +# GNU General Public License for more details.
120 +# You should have received a copy of the GNU General Public License
121 +# along with this program. If not, see <http://www.gnu.org/licenses/>.
123 +if {![istarget *-linux*] || [skip_shlib_tests]} {
127 +load_lib prelink-support.exp
129 +set testfile "dlopen-libpthread"
130 +set srcmainfile ${testfile}.c
131 +set srclibfile ${testfile}-lib.c
132 +set executable ${testfile}
133 +set binfile_lib ${objdir}/${subdir}/${executable}.so
134 +set binfile ${objdir}/${subdir}/${executable}
135 +set lib_dlopen [shlib_target_file ${executable}.so]
137 +# Use build_executable_own_libs as prelinked libpthread.so can produce false
138 +# PASS - it is OK if GDB processes it still before relocation.
140 +set relink_args [build_executable_own_libs ${testfile}.exp ${executable}.so $srclibfile {debug shlib_pthreads} no]
141 +if {$relink_args == "" || ![prelink_no $relink_args]
142 + || [prepare_for_testing ${testfile}.exp ${executable} ${srcmainfile} {debug shlib_load}] } {
145 +gdb_load_shlibs $binfile_lib
147 +if { ![runto_main] } {
151 +set test "info probes all rtld rtld_map_complete"
152 +gdb_test_multiple $test $test {
153 + -re "\[ \t\]rtld_map_complete\[ \t\]+0x\[0-9a-f\]+.*\r\n$gdb_prompt $" {
156 + -re "No probes matched\\.\r\n$gdb_prompt $" {
158 + untested ${testfile}.exp
163 +set test "libpthread.so not found"
164 +gdb_test_multiple "info sharedlibrary" $test {
165 + -re "/libpthread\\.so.*\r\n$gdb_prompt $" {
168 + -re "/libc\\.so.*\r\n$gdb_prompt $" {
173 +gdb_test "set variable filename=\"$lib_dlopen\""
175 +gdb_breakpoint "notify"
178 +# Cannot find new threads: generic error
179 +gdb_continue_to_breakpoint "notify" ".* notify-here .*"
181 +gdb_test "info sharedlibrary" {/libpthread\.so.*} "libpthread.so found"
182 Index: gdb-7.4.50.20120714/gdb/testsuite/lib/gdb.exp
183 ===================================================================
184 --- gdb-7.4.50.20120714.orig/gdb/testsuite/lib/gdb.exp 2012-07-15 08:51:36.803709222 +0200
185 +++ gdb-7.4.50.20120714/gdb/testsuite/lib/gdb.exp 2012-07-15 09:02:41.983028197 +0200
186 @@ -3774,22 +3774,6 @@ proc build_executable_from_specs {testna
188 set binfile [standard_output_file $executable]
192 - foreach {s local_options} $args {
193 - if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } {
197 - lappend objects "${binfile}${i}.o"
201 - if { [gdb_compile $objects "${binfile}" executable $options] != "" } {
207 if { [lsearch -exact $options "c++"] >= 0 } {
208 set info_options "c++"
209 @@ -3797,6 +3781,42 @@ proc build_executable_from_specs {testna
210 if [get_compiler_info ${info_options}] {
214 + set binfile [standard_output_file $executable]
216 + set func gdb_compile
217 + set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads)$}]
218 + if {$func_index != -1} {
219 + set func "${func}_[lindex $options $func_index]"
222 + # gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd
223 + # parameter. They also requires $sources while gdb_compile and
224 + # gdb_compile_pthreads require $objects. Moreover they ignore any options.
225 + if [string match gdb_compile_shlib* $func] {
226 + set sources_path {}
227 + foreach {s local_options} $args {
228 + lappend sources_path "${srcdir}/${subdir}/${s}"
230 + set ret [$func $sources_path "${binfile}" $options]
234 + foreach {s local_options} $args {
235 + if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } {
239 + lappend objects "${binfile}${i}.o"
242 + set ret [$func $objects "${binfile}" executable $options]
244 + if { $ret != "" } {
252 Index: gdb-7.4.50.20120714/gdb/testsuite/lib/prelink-support.exp
253 ===================================================================
254 --- gdb-7.4.50.20120714.orig/gdb/testsuite/lib/prelink-support.exp 2012-01-04 09:27:56.000000000 +0100
255 +++ gdb-7.4.50.20120714/gdb/testsuite/lib/prelink-support.exp 2012-07-15 08:51:38.243701254 +0200
256 @@ -95,8 +95,9 @@ proc file_copy {src dest} {
257 # Wrap function build_executable so that the resulting executable is fully
258 # self-sufficient (without dependencies on system libraries). Parameter
259 # INTERP may be used to specify a loader (ld.so) to be used that is
260 -# different from the default system one. Libraries on which the executable
261 -# depends are copied into directory DIR. Default DIR value to
262 +# different from the default system one. INTERP can be set to "no" if no ld.so
263 +# copy should be made. Libraries on which the executable depends are copied
264 +# into directory DIR. Default DIR value to
265 # `${objdir}/${subdir}/${EXECUTABLE}.d'.
267 # In case of success, return a string containing the arguments to be used
268 @@ -151,8 +152,15 @@ proc build_executable_own_libs {testname
271 set interp_system [section_get $binfile .interp]
272 - set interp ${dir}/[file tail $interp_system]
273 - file_copy $interp_system $interp
274 + if {$interp_system == ""} {
275 + fail "$test could not find .interp"
277 + set interp ${dir}/[file tail $interp_system]
278 + file_copy $interp_system $interp
281 + if {$interp == "no"} {
286 @@ -164,13 +172,19 @@ proc build_executable_own_libs {testname
288 # Do not lappend it so that "-rpath $dir" overrides any possible "-rpath"s
289 # specified by the caller to be able to link it for ldd" above.
290 - set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp,-rpath,$dir"]
291 + set options [linsert $options 0 "ldflags=-Wl,-rpath,$dir"]
292 + if {$interp != ""} {
293 + set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp"]
296 if {[build_executable $testname $executable $sources $options] == -1} {
300 - set prelink_args "--dynamic-linker=$interp --ld-library-path=$dir $binfile $interp [concat $dests]"
301 + set prelink_args "--ld-library-path=$dir $binfile [concat $dests]"
302 + if {$interp != ""} {
303 + set prelink_args "--dynamic-linker=$interp $prelink_args $interp"