GNU C Library master sources branch, roland/systemtap, created. glibc-2.13-17-gdadd341

roland@sourceware.org roland@sourceware.org
Tue Feb 8 22:46:00 GMT 2011


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, roland/systemtap has been created
        at  dadd34187c5c29eee8916f0d0163fcadca04ee90 (commit)

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=dadd34187c5c29eee8916f0d0163fcadca04ee90

commit dadd34187c5c29eee8916f0d0163fcadca04ee90
Author: Roland McGrath <roland@redhat.com>
Date:   Fri Jul 23 02:32:50 2010 -0700

    Add --enable-systemtap configuration to define static probe points.

diff --git a/ChangeLog b/ChangeLog
index 2d9a1e1..bfdc424 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-02-08  Roland McGrath  <roland@redhat.com>
+
+	* include/stap-probe.h: New file.
+	* configure.in: Handle --enable-systemtap.
+	* configure: Regenerated.
+	* config.h.in (USE_STAP_PROBE): New #undef.
+	* extra-lib.mk (CPPFLAGS-$(lib)): Add -DIN_LIB=$(lib).
+	* elf/Makefile (CPPFLAGS-.os): Add -DIN_LIB=rtld.
+	* elf/rtld-Rules (rtld-CPPFLAGS): Likewise.
+
 2011-02-03  Andreas Schwab  <schwab@redhat.com>
 
 	* sysdeps/unix/sysv/linux/sparc/bits/socket.h: Sync with
diff --git a/config.h.in b/config.h.in
index 9e797eb..7a3cd6a 100644
--- a/config.h.in
+++ b/config.h.in
@@ -204,6 +204,9 @@
 /* Define if `.ctors' and `.dtors' sections shouldn't be used.  */
 #undef	NO_CTORS_DTORS_SECTIONS
 
+/* Define if Systemtap <sys/sdt.h> probes should be defined.  */
+#undef USE_STAP_PROBE
+
 /*
  */
 
diff --git a/configure b/configure
index 1d419cf..8425d2a 100755
--- a/configure
+++ b/configure
@@ -785,6 +785,7 @@ enable_all_warnings
 enable_multi_arch
 enable_experimental_malloc
 enable_nss_crypt
+enable_systemtap
 with_cpu
 '
       ac_precious_vars='build_alias
@@ -1445,6 +1446,7 @@ Optional Features:
   --enable-experimental-malloc
                           enable experimental malloc features
   --enable-nss-crypt      enable libcrypt to use nss
+  --enable-systemtap      enable systemtap static probe points [default=no]
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -3824,6 +3826,51 @@ else
 fi
 
 
+# Check whether --enable-systemtap was given.
+if test "${enable_systemtap+set}" = set; then :
+  enableval=$enable_systemtap; systemtap=$enableval
+else
+  systemtap=no
+fi
+
+if test x$systemtap != xno; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for systemtap static probe support" >&5
+$as_echo_n "checking for systemtap static probe support... " >&6; }
+if test "${libc_cv_sdt+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+    old_CFLAGS="$CFLAGS"
+  CFLAGS="-std=gnu99 $CFLAGS"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/sdt.h>
+void foo (int i, void *p)
+{
+  asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
+       :: STAP_PROBE_ASM_OPERANDS (2, i, p));
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_cv_sdt=yes
+else
+  libc_cv_sdt=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  CFLAGS="$old_CFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_sdt" >&5
+$as_echo "$libc_cv_sdt" >&6; }
+  if test $libc_cv_sdt = yes; then
+    $as_echo "#define USE_STAP_PROBE 1" >>confdefs.h
+
+  else
+    { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "systemtap support needs sys/sdt.h with asm support
+See \`config.log' for more details" "$LINENO" 5; }
+  fi
+fi
+
 # The way shlib-versions is used to generate soversions.mk uses a
 # fairly simplistic model for name recognition that can't distinguish
 # i486-pc-linux-gnu fully from i486-pc-gnu.  So we mutate a $host_os
diff --git a/configure.in b/configure.in
index 7e46990..962960d 100644
--- a/configure.in
+++ b/configure.in
@@ -316,6 +316,29 @@ else
 fi
 AC_SUBST(libc_cv_nss_crypt)
 
+AC_ARG_ENABLE([systemtap],
+              [AS_HELP_STRING([--enable-systemtap],
+	       [enable systemtap static probe points @<:@default=no@:>@])],
+              [systemtap=$enableval],
+	      [systemtap=no])
+if test x$systemtap != xno; then
+  AC_CACHE_CHECK([for systemtap static probe support], libc_cv_sdt, [dnl
+  old_CFLAGS="$CFLAGS"
+  CFLAGS="-std=gnu99 $CFLAGS"
+  AC_COMPILE_IFELSE([#include <sys/sdt.h>
+void foo (int i, void *p)
+{
+  asm ("" STAP_PROBE_ASM (foo, bar, STAP_PROBE_ASM_TEMPLATE (2)) ""
+       :: STAP_PROBE_ASM_OPERANDS (2, i, p));
+}], [libc_cv_sdt=yes], [libc_cv_sdt=no])
+  CFLAGS="$old_CFLAGS"])
+  if test $libc_cv_sdt = yes; then
+    AC_DEFINE([USE_STAP_PROBE])
+  else
+    AC_MSG_FAILURE([systemtap support needs sys/sdt.h with asm support])
+  fi
+fi
+
 # The way shlib-versions is used to generate soversions.mk uses a
 # fairly simplistic model for name recognition that can't distinguish
 # i486-pc-linux-gnu fully from i486-pc-gnu.  So we mutate a $host_os
diff --git a/elf/Makefile b/elf/Makefile
index 36ea9b8..90bc797 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -472,7 +472,8 @@ CFLAGS-ldconfig.c = $(SYSCONF-FLAGS) -D'LIBDIR="$(libdir)"' \
 CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
 CFLAGS-cache.c = $(SYSCONF-FLAGS)
 
-CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-DNOT_IN_libc=1 -DIS_IN_rtld=1)
+CPPFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),\
+		     -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld)
 
 test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
 generated += $(addsuffix .so,$(strip $(modules-names)))
diff --git a/elf/rtld-Rules b/elf/rtld-Rules
index 10c9452..0a9bbf4 100644
--- a/elf/rtld-Rules
+++ b/elf/rtld-Rules
@@ -1,6 +1,7 @@
 # Subroutine makefile for compiling libc modules linked into dynamic linker.
 
-# Copyright (C) 2002,2003,2005,2006,2008,2010 Free Software Foundation, Inc.
+# Copyright (C) 2002,2003,2005,2006,2008,2010,2011
+#	Free Software Foundation, Inc.
 # This file is part of the GNU C Library.
 
 # The GNU C Library is free software; you can redistribute it and/or
@@ -131,6 +132,6 @@ ifdef rtld-depfiles
 endif
 
 # This here is the whole point of all the shenanigans.
-rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1
+rtld-CPPFLAGS := -DNOT_IN_libc=1 -DIS_IN_rtld=1 -DIN_LIB=rtld
 
 endif
diff --git a/extra-lib.mk b/extra-lib.mk
index 775eb23..7f8516e 100644
--- a/extra-lib.mk
+++ b/extra-lib.mk
@@ -101,4 +101,4 @@ ifneq (,$(cpp-srcs-left))
 include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
 endif
 
-CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1
+CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 -DIN_LIB=$(lib)
diff --git a/include/stap-probe.h b/include/stap-probe.h
new file mode 100644
index 0000000..be1bc1c
--- /dev/null
+++ b/include/stap-probe.h
@@ -0,0 +1,140 @@
+/* Macros for defining Systemtap <sys/sdt.h> static probe points.
+   Copyright (C) 2011 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _STAP_PROBE_H
+#define _STAP_PROBE_H 1
+
+#ifdef USE_STAP_PROBE
+
+# include <sys/sdt.h>
+
+/* Our code uses one macro LIBC_PROBE (name, n, arg1, ..., argn).
+
+   Without USE_STAP_PROBE, that does nothing but evaluates all
+   its arguments (to prevent bit rot, unlike e.g. assert).
+
+   Systemtap's header defines the macros STAP_PROBE (provider, name) and
+   STAP_PROBEn (provider, name, arg1, ..., argn).  For "provider" we paste
+   in the IN_LIB name (libc, libpthread, etc.) automagically.  */
+
+# ifndef NOT_IN_libc
+#  define IN_LIB	libc
+# elif !defined IN_LIB
+/* This is intentionally defined with extra unquoted commas in it so
+   that macro substitution will bomb out when it is used.  We don't
+   just use #error here, so that this header can be included by
+   other headers that use LIBC_PROBE inside their own macros.  We
+   only want such headers to fail to compile if those macros are
+   actually used in a context where IN_LIB has not been defined.  */
+#  define IN_LIB	,,,missing -DIN_LIB=... -- not extra-lib.mk?,,,
+# endif
+
+# define LIBC_PROBE(name, n, ...)	\
+  LIBC_PROBE_1 (IN_LIB, name, n, ## __VA_ARGS__)
+
+# define LIBC_PROBE_1(lib, name, n, ...) \
+  STAP_PROBE##n (lib, name, ## __VA_ARGS__)
+
+# define STAP_PROBE0		STAP_PROBE
+
+# define LIBC_PROBE_ASM(name, template) \
+  STAP_PROBE_ASM (IN_LIB, name, template)
+
+# define LIBC_PROBE_ASM_OPERANDS STAP_PROBE_ASM_OPERANDS
+
+#else  /* Not USE_STAP_PROBE.  */
+
+# ifndef __ASSEMBLER__
+#  define LIBC_PROBE(name, n, ...)		DUMMY_PROBE##n (__VA_ARGS__)
+# else
+#  define LIBC_PROBE(name, n, ...)		/* Nothing.  */
+# endif
+
+# define LIBC_PROBE_ASM(name, template)		/* Nothing.  */
+# define LIBC_PROBE_ASM_OPERANDS(n, ...)	/* Nothing.  */
+
+/* This silliness lets us evaluate all the arguments for each arity
+   of probe.  My kingdom for a real macro system.  */
+
+# define DUMMY_PROBE0()			do {} while (0)
+# define DUMMY_PROBE1(a1)		do {} while ((void) (a1), 0)
+# define DUMMY_PROBE2(a1, a2)		do {} while ((void) (a1), \
+						     (void) (a2), 0)
+# define DUMMY_PROBE3(a1, a2, a3)	do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), 0)
+# define DUMMY_PROBE4(a1, a2, a3, a4)	do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), \
+						     (void) (a4), 0)
+# define DUMMY_PROBE5(a1, a2, a3, a4, a5)			  \
+					do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), \
+						     (void) (a4), \
+						     (void) (a5), 0)
+# define DUMMY_PROBE6(a1, a2, a3, a4, a5, a6)			  \
+					do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), \
+						     (void) (a4), \
+						     (void) (a5), \
+						     (void) (a6), 0)
+# define DUMMY_PROBE7(a1, a2, a3, a4, a5, a6, a7)		  \
+					do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), \
+						     (void) (a4), \
+						     (void) (a5), \
+						     (void) (a6), \
+						     (void) (a7), 0)
+# define DUMMY_PROBE8(a1, a2, a3, a4, a5, a6, a7, a8)		  \
+					do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), \
+						     (void) (a4), \
+						     (void) (a5), \
+						     (void) (a6), \
+						     (void) (a7), \
+						     (void) (a8), 0)
+# define DUMMY_PROBE9(a1, a2, a3, a4, a5, a6, a7, a8, a9)	  \
+					do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), \
+						     (void) (a4), \
+						     (void) (a5), \
+						     (void) (a6), \
+						     (void) (a7), \
+						     (void) (a8), \
+						     (void) (a9), 0)
+# define DUMMY_PROBE10(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)	  \
+					do {} while ((void) (a1), \
+						     (void) (a2), \
+						     (void) (a3), \
+						     (void) (a4), \
+						     (void) (a5), \
+						     (void) (a6), \
+						     (void) (a7), \
+						     (void) (a8), \
+						     (void) (a9), \
+						     (void) (a10), 0)
+
+#endif	/* USE_STAP_PROBE.  */
+
+#endif	/* stap-probe.h */
diff --git a/nptl/ChangeLog b/nptl/ChangeLog
index 802abcd..da1aac7 100644
--- a/nptl/ChangeLog
+++ b/nptl/ChangeLog
@@ -1,3 +1,7 @@
+2010-07-23  Roland McGrath  <roland@redhat.com>
+
+	* pthread_create.c (start_thread): Define pthread_start LIBC_PROBE.
+
 2011-01-19  Roland McGrath  <roland@redhat.com>
 
 	* pthread_cond_wait.c (__pthread_cond_wait): Fix comment typo.
diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
index 34d83f9..4075dd9 100644
--- a/nptl/pthread_create.c
+++ b/nptl/pthread_create.c
@@ -31,6 +31,8 @@
 
 #include <shlib-compat.h>
 
+#include <stap-probe.h>
+
 
 /* Local function to start thread and handle cleanup.  */
 static int start_thread (void *arg);
@@ -296,6 +298,8 @@ start_thread (void *arg)
 	  CANCEL_RESET (oldtype);
 	}
 
+      LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
+
       /* Run the code the user provided.  */
 #ifdef CALL_THREAD_FCT
       THREAD_SETMEM (pd, result, CALL_THREAD_FCT (pd));

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources



More information about the Glibc-cvs mailing list