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.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c
8 ===================================================================
9 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
10 +++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread-lib.c 2011-08-10 18:30:56.000000000 +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.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.c
53 ===================================================================
54 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
55 +++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.c 2011-08-10 18:30:56.000000000 +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.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.exp
104 ===================================================================
105 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
106 +++ gdb-7.3.50.20110722/gdb/testsuite/gdb.threads/dlopen-libpthread.exp 2011-08-10 18:30:56.000000000 +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 "print _dl_debug_notify"
152 +gdb_test_multiple $test $test {
153 + -re " 0x\[0-9a-f\]+ <_dl_debug_notify>\r\n$gdb_prompt $" {
156 + -re "No symbol \"_dl_debug_notify\" in current context\\.\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.3.50.20110722/gdb/testsuite/lib/gdb.exp
183 ===================================================================
184 --- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/gdb.exp 2011-08-10 18:30:55.000000000 +0200
185 +++ gdb-7.3.50.20110722/gdb/testsuite/lib/gdb.exp 2011-08-10 18:30:56.000000000 +0200
186 @@ -3563,30 +3563,49 @@ proc build_executable { testname executa
187 set sources ${executable}.c
190 - set binfile ${objdir}/${subdir}/${executable}
193 - for {set i 0} "\$i<[llength $sources]" {incr i} {
194 - set s [lindex $sources $i]
195 - if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $options] != "" } {
199 - lappend objects "${binfile}${i}.o"
200 + # get_compiler_info by gdb_compile_shlib and gdb_compile_shlib_pthreads.
201 + set info_options ""
202 + if { [lsearch -exact $options "c++"] >= 0 } {
203 + set info_options "c++"
206 - if { [gdb_compile $objects "${binfile}" executable $options] != "" } {
208 + if [get_compiler_info binfile_unused ${info_options}] {
212 - set info_options ""
213 - if { [lsearch -exact $options "c++"] >= 0 } {
214 - set info_options "c++"
215 + set binfile ${objdir}/${subdir}/${executable}
217 + set func gdb_compile
218 + set func_index [lsearch -regexp $options {^(pthreads|shlib|shlib_pthreads)$}]
219 + if {$func_index != -1} {
220 + set func "${func}_[lindex $options $func_index]"
222 - if [get_compiler_info ${binfile} ${info_options}] {
224 + # gdb_compile_shlib and gdb_compile_shlib_pthreads do not use the 3rd
225 + # parameter. They also requires $sources while gdb_compile and
226 + # gdb_compile_pthreads require $objects.
227 + if [string match gdb_compile_shlib* $func] {
228 + set sources_path {}
229 + foreach s $sources {
230 + lappend sources_path "${srcdir}/${subdir}/${s}"
232 + set ret [$func $sources_path "${binfile}" $options]
235 + for {set i 0} "\$i<[llength $sources]" {incr i} {
236 + set s [lindex $sources $i]
237 + if { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $options] != "" } {
241 + lappend objects "${binfile}${i}.o"
243 + set ret [$func $objects "${binfile}" executable $options]
245 + if { $ret != "" } {
253 Index: gdb-7.3.50.20110722/gdb/testsuite/lib/prelink-support.exp
254 ===================================================================
255 --- gdb-7.3.50.20110722.orig/gdb/testsuite/lib/prelink-support.exp 2011-01-01 16:33:52.000000000 +0100
256 +++ gdb-7.3.50.20110722/gdb/testsuite/lib/prelink-support.exp 2011-08-10 19:25:41.000000000 +0200
257 @@ -95,8 +95,9 @@ proc file_copy {src dest} {
258 # Wrap function build_executable so that the resulting executable is fully
259 # self-sufficient (without dependencies on system libraries). Parameter
260 # INTERP may be used to specify a loader (ld.so) to be used that is
261 -# different from the default system one. Libraries on which the executable
262 -# depends are copied into directory DIR. Default DIR value to
263 +# different from the default system one. INTERP can be set to "no" if no ld.so
264 +# copy should be made. Libraries on which the executable depends are copied
265 +# into directory DIR. Default DIR value to
266 # `${objdir}/${subdir}/${EXECUTABLE}.d'.
268 # In case of success, return a string containing the arguments to be used
269 @@ -151,8 +152,15 @@ proc build_executable_own_libs {testname
272 set interp_system [section_get $binfile .interp]
273 - set interp ${dir}/[file tail $interp_system]
274 - file_copy $interp_system $interp
275 + if {$interp_system == ""} {
276 + fail "$test could not find .interp"
278 + set interp ${dir}/[file tail $interp_system]
279 + file_copy $interp_system $interp
282 + if {$interp == "no"} {
287 @@ -164,13 +172,19 @@ proc build_executable_own_libs {testname
289 # Do not lappend it so that "-rpath $dir" overrides any possible "-rpath"s
290 # specified by the caller to be able to link it for ldd" above.
291 - set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp,-rpath,$dir"]
292 + set options [linsert $options 0 "ldflags=-Wl,-rpath,$dir"]
293 + if {$interp != ""} {
294 + set options [linsert $options 0 "ldflags=-Wl,--dynamic-linker,$interp"]
297 if {[build_executable $testname $executable $sources $options] == -1} {
301 - set prelink_args "--dynamic-linker=$interp --ld-library-path=$dir $binfile $interp [concat $dests]"
302 + set prelink_args "--ld-library-path=$dir $binfile [concat $dests]"
303 + if {$interp != ""} {
304 + set prelink_args "--dynamic-linker=$interp $prelink_args $interp"
309 Index: gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp
310 ===================================================================
311 --- gdb-7.3.50.20110722.orig/gdb/testsuite/gdb.base/break-interp.exp 2011-07-01 21:12:12.000000000 +0200
312 +++ gdb-7.3.50.20110722/gdb/testsuite/gdb.base/break-interp.exp 2011-08-10 18:32:21.000000000 +0200
313 @@ -108,14 +108,20 @@ proc strip_debug {dest} {
317 +# Former symbol for solib changes notifications was _dl_debug_state, newer one
318 +# is _dl_debug_notify, the right one one traps by `set stop-on-solib-events 1'.
320 +set solib_bp {(_dl_debug_state|_dl_debug_notify)}
322 # Implementation of reach.
324 proc reach_1 {func command displacement} {
325 - global gdb_prompt expect_out
326 + global gdb_prompt expect_out solib_bp
328 - if {$func == "_dl_debug_state"} {
329 + if {$func == $solib_bp} {
330 # Breakpoint on _dl_debug_state can have problems due to its overlap
331 # with the existing internal breakpoint from GDB.
332 + # With also _dl_debug_notify we would need even two breakpoints.
333 gdb_test_no_output "set stop-on-solib-events 1"
334 } elseif {! [gdb_breakpoint $func allow-pending]} {
336 @@ -141,21 +147,21 @@ proc reach_1 {func command displacement}
339 -re "Breakpoint \[0-9\]+, \\.?(__GI_)?$func \\(.*\\) at .*:\[0-9\]+\r\n.*$gdb_prompt $" {
340 - if {$func == "_dl_debug_state"} {
341 + if {$func == $solib_bp} {
347 -re "Breakpoint \[0-9\]+, \[0-9xa-f\]+ in \\.?(__GI_)?$func \\(\\).*\r\n$gdb_prompt $" {
348 - if {$func == "_dl_debug_state"} {
349 + if {$func == $solib_bp} {
355 -re "Stopped due to shared library event\r\n$gdb_prompt $" {
356 - if {$func == "_dl_debug_state"} {
357 + if {$func == $solib_bp} {
358 if {$debug_state_count == 0} {
359 # First stop does not yet relocate the _start function
360 # descriptor on ppc64.
361 @@ -174,7 +180,7 @@ proc reach_1 {func command displacement}
362 fail $test_displacement
365 - if {$func == "_dl_debug_state"} {
366 + if {$func == $solib_bp} {
367 gdb_test_no_output "set stop-on-solib-events 0"
370 @@ -373,7 +379,7 @@ proc test_attach {file displacement {rel
373 proc test_ld {file ifmain trynosym displacement} {
374 - global srcdir subdir gdb_prompt expect_out inferior_exited_re
375 + global srcdir subdir gdb_prompt expect_out inferior_exited_re solib_bp
377 # First test normal `file'-command loaded $FILE with symbols.
379 @@ -401,9 +407,9 @@ proc test_ld {file ifmain trynosym displ
380 gdb_test_no_output "set args ${objdir}/${subdir}/$binfile_test" "set args OBJDIR/${subdir}/$binfile_test"
383 - reach "_dl_debug_state" "run" $displacement
384 + reach $solib_bp "run" $displacement
386 - gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?_dl_debug_state\\M.*" "dl bt"
387 + gdb_test "bt" "#0 +\[^\r\n\]*\\m(__GI_)?$solib_bp\\M.*" "dl bt"
390 reach "main" continue "NONE"
391 @@ -415,7 +421,7 @@ proc test_ld {file ifmain trynosym displ
393 # Try re-run if the new PIE displacement takes effect.
394 gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y"
395 - reach "_dl_debug_state" "run" $displacement
396 + reach $solib_bp "run" $displacement
399 test_core $file $displacement
400 @@ -448,7 +454,7 @@ proc test_ld {file ifmain trynosym displ
401 gdb_test "exec-file $file" "exec-file $escapedfile" "load"
404 - reach "_dl_debug_state" run $displacement
405 + reach $solib_bp run $displacement
407 # Use two separate gdb_test_multiple statements to avoid timeouts due
408 # to slow processing of wildcard capturing long output