1 Index: glibc-2.12-2-gc4ccff1/config.h.in
2 ===================================================================
3 --- glibc-2.12-2-gc4ccff1.orig/config.h.in
4 +++ glibc-2.12-2-gc4ccff1/config.h.in
6 /* Define if multi-arch DSOs should be generated. */
9 +/* Define if Systemtap <sys/sdt.h> probes should be defined. */
10 +#undef USE_STAP_PROBE
15 Index: glibc-2.12-2-gc4ccff1/configure
16 ===================================================================
17 --- glibc-2.12-2-gc4ccff1.orig/configure
18 +++ glibc-2.12-2-gc4ccff1/configure
19 @@ -830,6 +830,7 @@ enable_all_warnings
21 enable_experimental_malloc
26 ac_precious_vars='build_alias
27 @@ -1501,6 +1502,7 @@ Optional Features:
28 --enable-experimental-malloc
29 enable experimental malloc features
30 --enable-nss-crypt enable libcrypt to use nss
31 + --enable-systemtap enable systemtap static probe points [default=no]
34 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
35 @@ -3932,6 +3934,79 @@ else
39 +# Check whether --enable-systemtap was given.
40 +if test "${enable_systemtap+set}" = set; then
41 + enableval=$enable_systemtap; systemtap=$enableval
46 +if test x$systemtap != xno; then
48 + { $as_echo "$as_me:$LINENO: checking for systemtap static probe support" >&5
49 +$as_echo_n "checking for systemtap static probe support... " >&6; }
50 +if test "${libc_cv_sdt+set}" = set; then
51 + $as_echo_n "(cached) " >&6
53 + old_CFLAGS="$CFLAGS"
54 + CFLAGS="-std=gnu99 $CFLAGS"
55 + cat >conftest.$ac_ext <<_ACEOF
57 +void foo (int i, void *p)
59 + asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
60 + :: STAP_PROBE_ASM_OPERANDS (2, i, p));
63 +rm -f conftest.$ac_objext
64 +if { (ac_try="$ac_compile"
66 + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
67 + *) ac_try_echo=$ac_try;;
69 +eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
70 +$as_echo "$ac_try_echo") >&5
71 + (eval "$ac_compile") 2>conftest.er1
73 + grep -v '^ *+' conftest.er1 >conftest.err
75 + cat conftest.err >&5
76 + $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
77 + (exit $ac_status); } && {
78 + test -z "$ac_c_werror_flag" ||
79 + test ! -s conftest.err
80 + } && test -s conftest.$ac_objext; then
83 + $as_echo "$as_me: failed program was:" >&5
84 +sed 's/^/| /' conftest.$ac_ext >&5
89 +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
90 + CFLAGS="$old_CFLAGS"
92 +{ $as_echo "$as_me:$LINENO: result: $libc_cv_sdt" >&5
93 +$as_echo "$libc_cv_sdt" >&6; }
94 + if test $libc_cv_sdt = yes; then
95 + cat >>confdefs.h <<\_ACEOF
96 +#define USE_STAP_PROBE 1
100 + { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5
101 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
102 +{ { $as_echo "$as_me:$LINENO: error: systemtap support needs sys/sdt.h with asm support
103 +See \`config.log' for more details." >&5
104 +$as_echo "$as_me: error: systemtap support needs sys/sdt.h with asm support
105 +See \`config.log' for more details." >&2;}
106 + { (exit 1); exit 1; }; }; }
112 # The way shlib-versions is used to generate soversions.mk uses a
113 # fairly simplistic model for name recognition that can't distinguish
114 # i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
115 Index: glibc-2.12-2-gc4ccff1/configure.in
116 ===================================================================
117 --- glibc-2.12-2-gc4ccff1.orig/configure.in
118 +++ glibc-2.12-2-gc4ccff1/configure.in
119 @@ -319,6 +319,29 @@ else
121 AC_SUBST(libc_cv_nss_crypt)
123 +AC_ARG_ENABLE([systemtap],
124 + [AS_HELP_STRING([--enable-systemtap],
125 + [enable systemtap static probe points @<:@default=no@:>@])],
126 + [systemtap=$enableval],
128 +AS_IF([test x$systemtap != xno], [
129 + AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
130 + old_CFLAGS="$CFLAGS"
131 + CFLAGS="-std=gnu99 $CFLAGS"
132 + AC_COMPILE_IFELSE([#include <sys/sdt.h>
133 +void foo (int i, void *p)
135 + asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
136 + :: STAP_PROBE_ASM_OPERANDS (2, i, p));
137 +}], [libc_cv_sdt=yes], [libc_cv_sdt=no])
138 + CFLAGS="$old_CFLAGS"])
139 + if test $libc_cv_sdt = yes; then
140 + AC_DEFINE([USE_STAP_PROBE])
142 + AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
146 # The way shlib-versions is used to generate soversions.mk uses a
147 # fairly simplistic model for name recognition that can't distinguish
148 # i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
149 Index: glibc-2.12-2-gc4ccff1/elf/Makefile
150 ===================================================================
151 --- glibc-2.12-2-gc4ccff1.orig/elf/Makefile
152 +++ glibc-2.12-2-gc4ccff1/elf/Makefile
153 @@ -458,7 +458,8 @@ CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'
154 CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
155 CFLAGS-cache.c = $(SYSCONF-FLAGS)
157 -CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
158 +CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
159 + -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)
161 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
162 generated += $(addsuffix .so,$(strip $(modules-names)))
163 Index: glibc-2.12-2-gc4ccff1/elf/dl-close.c
164 ===================================================================
165 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-close.c
166 +++ glibc-2.12-2-gc4ccff1/elf/dl-close.c
168 #include <sys/mman.h>
169 #include <sysdep-cancel.h>
171 +#include <stap-probe.h>
174 /* Type of the constructor functions. */
175 @@ -469,6 +470,7 @@ _dl_close_worker (struct link_map *map)
176 struct r_debug *r = _dl_debug_initialize (0, nsid);
177 r->r_state = RT_DELETE;
179 + LIBC_PROBE (rtld_unmap_start, 2, nsid, r);
183 @@ -722,6 +724,7 @@ _dl_close_worker (struct link_map *map)
184 /* Notify the debugger those objects are finalized and gone. */
185 r->r_state = RT_CONSISTENT;
187 + LIBC_PROBE (rtld_unmap_complete, 2, nsid, r);
189 /* Recheck if we need to retry, release the lock. */
191 Index: glibc-2.12-2-gc4ccff1/elf/dl-load.c
192 ===================================================================
193 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-load.c
194 +++ glibc-2.12-2-gc4ccff1/elf/dl-load.c
196 #include <stackinfo.h>
199 +#include <stap-probe.h>
203 @@ -806,7 +807,7 @@ _dl_init_paths (const char *llp)
205 __attribute__ ((noreturn, noinline))
206 lose (int code, int fd, const char *name, char *realname, struct link_map *l,
207 - const char *msg, struct r_debug *r)
208 + const char *msg, struct r_debug *r, Lmid_t nsid)
210 /* The file might already be closed. */
212 @@ -818,6 +819,7 @@ lose (int code, int fd, const char *name
214 r->r_state = RT_CONSISTENT;
216 + LIBC_PROBE (rtld_map_complete, 2, nsid, r);
219 _dl_signal_error (code, name, NULL, msg);
220 @@ -856,7 +858,7 @@ _dl_map_object_from_fd (const char *name
223 lose (errval, fd, name, realname, l, errstring,
224 - make_consistent ? r : NULL);
225 + make_consistent ? r : NULL, nsid);
228 /* Look again to see if the real name matched another already loaded. */
229 @@ -963,6 +965,7 @@ _dl_map_object_from_fd (const char *name
230 linking has not been used before. */
233 + LIBC_PROBE (rtld_map_start, 2, nsid, r);
234 make_consistent = true;
237 @@ -1656,7 +1659,7 @@ open_verify (const char *name, struct fi
238 name = strdupa (realname);
241 - lose (errval, fd, name, NULL, NULL, errstring, NULL);
242 + lose (errval, fd, name, NULL, NULL, errstring, NULL, 0);
245 /* See whether the ELF header is what we expect. */
246 Index: glibc-2.12-2-gc4ccff1/elf/dl-open.c
247 ===================================================================
248 --- glibc-2.12-2-gc4ccff1.orig/elf/dl-open.c
249 +++ glibc-2.12-2-gc4ccff1/elf/dl-open.c
252 #include <sysdep-cancel.h>
254 +#include <stap-probe.h>
258 @@ -297,6 +298,7 @@ dl_open_worker (void *a)
259 struct r_debug *r = _dl_debug_initialize (0, args->nsid);
260 r->r_state = RT_CONSISTENT;
262 + LIBC_PROBE (rtld_map_complete, 2, args->nsid, r);
264 /* Only do lazy relocation if `LD_BIND_NOW' is not set. */
265 int reloc_mode = mode & __RTLD_AUDIT;
266 @@ -309,10 +311,18 @@ dl_open_worker (void *a)
267 struct link_map *l = new;
270 + int relocation_in_progress = 0;
273 if (! l->l_real->l_relocated)
275 + if (! relocation_in_progress)
277 + /* Notify the debugger that relocations are about to happen. */
278 + LIBC_PROBE (rtld_reloc_start, 2, args->nsid, r);
279 + relocation_in_progress = 1;
283 if (__builtin_expect (GLRO(dl_profile) != NULL, 0))
285 @@ -460,6 +470,10 @@ cannot load any more object with static
286 _dl_fatal_printf (N_("\
287 TLS generation counter wrapped! Please report this."));
289 + /* Notify the debugger all new objects have been relocated. */
290 + if (relocation_in_progress)
291 + LIBC_PROBE (rtld_reloc_complete, 2, args->nsid, r);
293 /* Run the initializer functions of new objects. */
294 _dl_init (new, args->argc, args->argv, args->env);
296 Index: glibc-2.12-2-gc4ccff1/elf/rtld-Rules
297 ===================================================================
298 --- glibc-2.12-2-gc4ccff1.orig/elf/rtld-Rules
299 +++ glibc-2.12-2-gc4ccff1/elf/rtld-Rules
300 @@ -122,6 +122,6 @@ ifdef rtld-depfiles
303 # This here is the whole point of all the shenanigans.
304 -rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1
305 +rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld
308 Index: glibc-2.12-2-gc4ccff1/elf/rtld.c
309 ===================================================================
310 --- glibc-2.12-2-gc4ccff1.orig/elf/rtld.c
311 +++ glibc-2.12-2-gc4ccff1/elf/rtld.c
313 #include <dl-osinfo.h>
314 #include <dl-procinfo.h>
316 +#include <stap-probe.h>
320 @@ -1656,6 +1657,7 @@ ERROR: ld.so: object '%s' cannot be load
321 /* We start adding objects. */
324 + LIBC_PROBE (rtld_init_start, 2, LM_ID_BASE, r);
326 /* Auditing checkpoint: we are ready to signal that the initial map
327 is being constructed. */
328 @@ -2353,6 +2355,7 @@ ERROR: ld.so: object '%s' cannot be load
329 r = _dl_debug_initialize (0, LM_ID_BASE);
330 r->r_state = RT_CONSISTENT;
332 + LIBC_PROBE (rtld_init_complete, 2, LM_ID_BASE, r);
335 /* We must munmap() the cache file. */
336 Index: glibc-2.12-2-gc4ccff1/extra-lib.mk
337 ===================================================================
338 --- glibc-2.12-2-gc4ccff1.orig/extra-lib.mk
339 +++ glibc-2.12-2-gc4ccff1/extra-lib.mk
340 @@ -101,4 +101,4 @@ ifneq (,$(cpp-srcs-left))
341 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
344 -CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1
345 +CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 -DIN_LIB=$(lib)
346 Index: glibc-2.12-2-gc4ccff1/include/stap-probe.h
347 ===================================================================
349 +++ glibc-2.12-2-gc4ccff1/include/stap-probe.h
351 +/* Macros for defining Systemtap <sys/sdt.h> static probe points.
352 + Copyright (C) 2011 Free Software Foundation, Inc.
353 + This file is part of the GNU C Library.
355 + The GNU C Library is free software; you can redistribute it and/or
356 + modify it under the terms of the GNU Lesser General Public
357 + License as published by the Free Software Foundation; either
358 + version 2.1 of the License, or (at your option) any later version.
360 + The GNU C Library is distributed in the hope that it will be useful,
361 + but WITHOUT ANY WARRANTY; without even the implied warranty of
362 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
363 + Lesser General Public License for more details.
365 + You should have received a copy of the GNU Lesser General Public
366 + License along with the GNU C Library; if not, write to the Free
367 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
370 +#ifndef _STAP_PROBE_H
371 +#define _STAP_PROBE_H 1
373 +#ifdef USE_STAP_PROBE
375 +# include <sys/sdt.h>
377 +/* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
379 + Without USE_STAP_PROBE, that does nothing but evaluates all
380 + its arguments (to prevent bit rot, unlike e.g. assert).
382 + Systemtap's header defines the macros STAP_PROBE (provider, name) and
383 + STAP_PROBEn (provider, name, arg1, ..., argn). For "provider" we paste
384 + in the IN_LIB name (libc, libpthread, etc.) automagically. */
386 +# ifndef NOT_IN_libc
387 +# define IN_LIB libc
388 +# elif !defined IN_LIB
389 +/* This is intentionally defined with extra unquoted commas in it so
390 + that macro substitution will bomb out when it is used. We don't
391 + just use #error here, so that this header can be included by
392 + other headers that use LIBC_PROBE inside their own macros. We
393 + only want such headers to fail to compile if those macros are
394 + actually used in a context where IN_LIB has not been defined. */
395 +# define IN_LIB ,,,missing -DIN_LIB=... -- not extra-lib.mk?,,,
398 +# define LIBC_PROBE(name, n, ...) \
399 + LIBC_PROBE_1 (IN_LIB, name, n, ## __VA_ARGS__)
401 +# define LIBC_PROBE_1(lib, name, n, ...) \
402 + STAP_PROBE##n (lib, name, ## __VA_ARGS__)
404 +# define STAP_PROBE0 STAP_PROBE
406 +# define LIBC_PROBE_ASM(name, template) \
407 + STAP_PROBE_ASM (IN_LIB, name, template)
409 +# define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
411 +#else /* Not USE_STAP_PROBE. */
413 +# ifndef __ASSEMBLER__
414 +# define LIBC_PROBE(name, n, ...) DUMMY_PROBE##n (__VA_ARGS__)
416 +# define LIBC_PROBE(name, n, ...) /* Nothing. */
419 +# define LIBC_PROBE_ASM(name, template) /* Nothing. */
420 +# define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */
422 +/* This silliness lets us evaluate all the arguments for each arity
423 + of probe. My kingdom for a real macro system. */
425 +# define DUMMY_PROBE0() do {} while (0)
426 +# define DUMMY_PROBE1(a1) do {} while ((void) (a1), 0)
427 +# define DUMMY_PROBE2(a1, a2) do {} while ((void) (a1), \
429 +# define DUMMY_PROBE3(a1, a2, a3) do {} while ((void) (a1), \
432 +# define DUMMY_PROBE4(a1, a2, a3, a4) do {} while ((void) (a1), \
436 +# define DUMMY_PROBE5(a1, a2, a3, a4, a5) \
437 + do {} while ((void) (a1), \
442 +# define DUMMY_PROBE6(a1, a2, a3, a4, a5, a6) \
443 + do {} while ((void) (a1), \
449 +# define DUMMY_PROBE7(a1, a2, a3, a4, a5, a6, a7) \
450 + do {} while ((void) (a1), \
457 +# define DUMMY_PROBE8(a1, a2, a3, a4, a5, a6, a7, a8) \
458 + do {} while ((void) (a1), \
466 +# define DUMMY_PROBE9(a1, a2, a3, a4, a5, a6, a7, a8, a9) \
467 + do {} while ((void) (a1), \
476 +# define DUMMY_PROBE10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) \
477 + do {} while ((void) (a1), \
488 +#endif /* USE_STAP_PROBE. */
490 +#endif /* stap-probe.h */
491 Index: glibc-2.12-2-gc4ccff1/scripts/check-local-headers.sh
492 ===================================================================
493 --- glibc-2.12-2-gc4ccff1.orig/scripts/check-local-headers.sh
494 +++ glibc-2.12-2-gc4ccff1/scripts/check-local-headers.sh
495 @@ -31,6 +31,8 @@ fgrep -v "$includedir/asm" |
496 fgrep -v "$includedir/linux" |
497 fgrep -v "$includedir/selinux" |
498 fgrep -v "$includedir/sys/capability.h" |
499 +fgrep -v "$includedir/sys/sdt.h" |
500 +fgrep -v "$includedir/sys/sdt-config.h" |
501 fgrep -v "$includedir/gd" |
502 fgrep -v "$includedir/nss3"; then
503 # If we found a match something is wrong.