]> git.pld-linux.org Git - packages/gdb.git/blob - gdb-dlopen-stap-probe-test.patch
- typo
[packages/gdb.git] / gdb-dlopen-stap-probe-test.patch
1 commit 5bfdc32cd3bf373c3b02e1fd864ed8ceab0292b2
2 Author: Jan Kratochvil <jan.kratochvil@redhat.com>
3 Date:   Mon Aug 8 12:08:53 2011 +0200
4
5     +testcase
6
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
11 @@ -0,0 +1,40 @@
12 +/* This testcase is part of GDB, the GNU debugger.
13 +
14 +   Copyright 2011 Free Software Foundation, Inc.
15 +
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.
20 +
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.
25 +
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/>.  */
28 +
29 +#include <pthread.h>
30 +#include <assert.h>
31 +
32 +static void *
33 +tfunc (void *arg)
34 +{
35 +  void (*notifyp) (void) = arg;
36 +
37 +  notifyp ();
38 +}
39 +
40 +void
41 +f (void (*notifyp) (void))
42 +{
43 +  pthread_t t;
44 +  int i;
45 +
46 +  i = pthread_create (&t, NULL, tfunc, notifyp);
47 +  assert (i == 0);
48 +
49 +  i = pthread_join (t, NULL);
50 +  assert (i == 0);
51 +}
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
56 @@ -0,0 +1,46 @@
57 +/* This testcase is part of GDB, the GNU debugger.
58 +
59 +   Copyright 2011 Free Software Foundation, Inc.
60 +
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.
65 +
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.
70 +
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/>.  */
73 +
74 +#include <dlfcn.h>
75 +#include <stddef.h>
76 +#include <assert.h>
77 +
78 +static const char *volatile filename;
79 +
80 +static void
81 +notify (void)
82 +{
83 +  filename = NULL; /* notify-here */
84 +}
85 +
86 +int
87 +main (void)
88 +{
89 +  void *h;
90 +  void (*fp) (void (*) (void));
91 +
92 +  assert (filename != NULL);
93 +  h = dlopen (filename, RTLD_LAZY);
94 +  assert (h != NULL);
95 +
96 +  fp = dlsym (h, "f");
97 +  assert (fp != NULL);
98 +
99 +  fp (notify);
100 +
101 +  return 0;
102 +}
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
107 @@ -0,0 +1,74 @@
108 +# Copyright 2011 Free Software Foundation, Inc.
109 +#
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.
114 +#
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.
119 +#
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/>.
122 +
123 +if {![istarget *-linux*] || [skip_shlib_tests]} {
124 +    return 0
125 +}
126 +
127 +load_lib prelink-support.exp
128 +
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]
136 +
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.
139 +
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}] } {
143 +    return -1
144 +}
145 +gdb_load_shlibs $binfile_lib
146 +
147 +if { ![runto_main] } {
148 +    return -1
149 +}
150 +
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 $" {
154 +       pass $test
155 +    }
156 +    -re "No probes matched\\.\r\n$gdb_prompt $" {
157 +       xfail $test
158 +       untested ${testfile}.exp
159 +       return
160 +    }
161 +}
162 +
163 +set test "libpthread.so not found"
164 +gdb_test_multiple "info sharedlibrary" $test {
165 +    -re "/libpthread\\.so.*\r\n$gdb_prompt $" {
166 +       fail $test
167 +    }
168 +    -re "/libc\\.so.*\r\n$gdb_prompt $" {
169 +       pass $test
170 +    }
171 +}
172 +
173 +gdb_test "set variable filename=\"$lib_dlopen\""
174 +
175 +gdb_breakpoint "notify"
176 +
177 +# The error was:
178 +# Cannot find new threads: generic error
179 +gdb_continue_to_breakpoint "notify" ".* notify-here .*"
180 +
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
187  
188      set binfile [standard_output_file $executable]
189  
190 -    set objects {}
191 -    set i 0
192 -    foreach {s local_options} $args {
193 -        if  { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } {
194 -            untested $testname
195 -            return -1
196 -        }
197 -        lappend objects "${binfile}${i}.o"
198 -       incr i
199 -    }
200 -    
201 -    if  { [gdb_compile $objects "${binfile}" executable $options] != "" } {
202 -        untested $testname
203 -        return -1
204 -    }
205 -
206      set info_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}] {
211          return -1
212      }
213 +
214 +    set binfile [standard_output_file $executable]
215 +
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]"
220 +    }
221 +
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}"
229 +       }
230 +       set ret [$func $sources_path "${binfile}" $options]
231 +    } else {
232 +       set objects {}
233 +       set i 0
234 +       foreach {s local_options} $args {
235 +           if  { [gdb_compile "${srcdir}/${subdir}/${s}" "${binfile}${i}.o" object $local_options] != "" } {
236 +               untested $testname
237 +               return -1
238 +           }
239 +           lappend objects "${binfile}${i}.o"
240 +           incr i
241 +       }
242 +       set ret [$func $objects "${binfile}" executable $options]
243 +    }
244 +    if  { $ret != "" } {
245 +        untested $testname
246 +        return -1
247 +    }
248 +
249      return 0
250  }
251  
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'.
266  #
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
269  
270      if {$interp == ""} {
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"
276 +       } else {
277 +           set interp ${dir}/[file tail $interp_system]
278 +           file_copy $interp_system $interp
279 +       }
280 +    }
281 +    if {$interp == "no"} {
282 +       set interp ""
283      }
284  
285      set dests {}
286 @@ -164,13 +172,19 @@ proc build_executable_own_libs {testname
287  
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"]
294 +    }
295  
296      if {[build_executable $testname $executable $sources $options] == -1} {
297         return ""
298      }
299  
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"
304 +    }
305      return $prelink_args
306  }
307  
This page took 0.050597 seconds and 3 git commands to generate.