GNU C Library master sources branch, roland/systemtap, created. glibc-2.12-248-ge013f52

roland@sourceware.org roland@sourceware.org
Tue Jan 11 20:23: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  e013f52ef764097e11ff962733f824061b86e599 (commit)

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

commit e013f52ef764097e11ff962733f824061b86e599
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 0d73576..3abd21d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-01-11  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).
+
 2011-01-09  Ulrich Drepper  <drepper@gmail.com>
 
 	* sysdeps/i386/bits/select.h: Don't use asm code for __FD_SET,
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 823f15e..773bfa6 100755
--- a/configure
+++ b/configure
@@ -784,6 +784,7 @@ enable_all_warnings
 enable_multi_arch
 enable_experimental_malloc
 enable_nss_crypt
+enable_systemtap
 with_cpu
 '
       ac_precious_vars='build_alias
@@ -1444,6 +1445,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]
@@ -3823,6 +3825,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 ad25b9b..25d7496 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/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..7d8daad
--- /dev/null
+++ b/include/stap-probe.h
@@ -0,0 +1,133 @@
+/* Macros for defining Systemtap <sys/sdt.h> static probe points.
+   Copyright (C) 2010 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
+#  error "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.  */
+
+# define LIBC_PROBE(name, n, ...)	DUMMY_PROBE##n (__VA_ARGS__)
+
+# define LIBC_PROBE_ASM(name, template) \
+  STAP_PROBE_ASM (IN_LIB, name, template)
+
+# define LIBC_PROBE_ASM_OPERANDS(n, ...) \
+  [__probe_dummy__] "g" (({ DUMMY_PROBE##n (__VA_ARGS__); 0; }))
+
+/* 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 e3bfd00..39f0c75 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.
+
 2010-10-13  H.J. Lu  <hongjiu.lu@intel.com>
 
 	[BZ #12113]
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