mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
Add --enable-systemtap configuration to define static probe points.
This commit is contained in:
parent
21708942c9
commit
3a097cc7a1
10 changed files with 179 additions and 5 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2012-05-25 Roland McGrath <roland@hack.frob.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.
|
||||||
|
|
||||||
2012-05-25 Joseph Myers <joseph@codesourcery.com>
|
2012-05-25 Joseph Myers <joseph@codesourcery.com>
|
||||||
|
|
||||||
[BZ #13717]
|
[BZ #13717]
|
||||||
|
|
|
@ -181,6 +181,10 @@
|
||||||
/* Define if obsolete RPC code should be made available for user-level code
|
/* Define if obsolete RPC code should be made available for user-level code
|
||||||
to link against. */
|
to link against. */
|
||||||
#undef LINK_OBSOLETE_RPC
|
#undef LINK_OBSOLETE_RPC
|
||||||
|
|
||||||
|
/* Define if Systemtap <sys/sdt.h> probes should be defined. */
|
||||||
|
#undef USE_STAP_PROBE
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
48
configure
vendored
48
configure
vendored
|
@ -784,6 +784,7 @@ enable_all_warnings
|
||||||
enable_multi_arch
|
enable_multi_arch
|
||||||
enable_nss_crypt
|
enable_nss_crypt
|
||||||
enable_obsolete_rpc
|
enable_obsolete_rpc
|
||||||
|
enable_systemtap
|
||||||
with_cpu
|
with_cpu
|
||||||
'
|
'
|
||||||
ac_precious_vars='build_alias
|
ac_precious_vars='build_alias
|
||||||
|
@ -1441,6 +1442,7 @@ Optional Features:
|
||||||
--enable-nss-crypt enable libcrypt to use nss
|
--enable-nss-crypt enable libcrypt to use nss
|
||||||
--enable-obsolete-rpc build and install the obsolete RPC code for
|
--enable-obsolete-rpc build and install the obsolete RPC code for
|
||||||
link-time usage
|
link-time usage
|
||||||
|
--enable-systemtap enable systemtap static probe points [default=no]
|
||||||
|
|
||||||
Optional Packages:
|
Optional Packages:
|
||||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||||
|
@ -3753,6 +3755,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Check whether --enable-obsolete-rpc was given.
|
# Check whether --enable-obsolete-rpc was given.
|
||||||
if test "${enable_obsolete_rpc+set}" = set; then :
|
if test "${enable_obsolete_rpc+set}" = set; then :
|
||||||
enableval=$enable_obsolete_rpc; link_obsolete_rpc=$enableval
|
enableval=$enable_obsolete_rpc; link_obsolete_rpc=$enableval
|
||||||
|
@ -3767,6 +3770,51 @@ if test "$link_obsolete_rpc" = yes; then
|
||||||
|
|
||||||
fi
|
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 ${libc_cv_sdt+:} false; 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
|
||||||
|
|
||||||
|
elif test "x$systemtap" != xauto; then
|
||||||
|
{ { $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
|
# The way shlib-versions is used to generate soversions.mk uses a
|
||||||
# fairly simplistic model for name recognition that can't distinguish
|
# 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
|
# i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
|
||||||
|
|
24
configure.in
24
configure.in
|
@ -252,6 +252,7 @@ else
|
||||||
fi
|
fi
|
||||||
AC_SUBST(libc_cv_nss_crypt)
|
AC_SUBST(libc_cv_nss_crypt)
|
||||||
|
|
||||||
|
|
||||||
AC_ARG_ENABLE([obsolete-rpc],
|
AC_ARG_ENABLE([obsolete-rpc],
|
||||||
AC_HELP_STRING([--enable-obsolete-rpc],
|
AC_HELP_STRING([--enable-obsolete-rpc],
|
||||||
[build and install the obsolete RPC code for link-time usage]),
|
[build and install the obsolete RPC code for link-time usage]),
|
||||||
|
@ -263,6 +264,29 @@ if test "$link_obsolete_rpc" = yes; then
|
||||||
AC_DEFINE(LINK_OBSOLETE_RPC)
|
AC_DEFINE(LINK_OBSOLETE_RPC)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
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])
|
||||||
|
elif test "x$systemtap" != xauto; then
|
||||||
|
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
|
# The way shlib-versions is used to generate soversions.mk uses a
|
||||||
# fairly simplistic model for name recognition that can't distinguish
|
# 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
|
# i486-pc-linux-gnu fully from i486-pc-gnu. So we mutate a $host_os
|
||||||
|
|
|
@ -422,7 +422,8 @@ CFLAGS-dl-cache.c = $(SYSCONF-FLAGS)
|
||||||
CFLAGS-cache.c = $(SYSCONF-FLAGS)
|
CFLAGS-cache.c = $(SYSCONF-FLAGS)
|
||||||
CFLAGS-rtld.c = $(SYSCONF-FLAGS)
|
CFLAGS-rtld.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))))
|
test-modules = $(addprefix $(objpfx),$(addsuffix .so,$(strip $(modules-names))))
|
||||||
generated += $(addsuffix .so,$(strip $(modules-names)))
|
generated += $(addsuffix .so,$(strip $(modules-names)))
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Subroutine makefile for compiling libc modules linked into dynamic linker.
|
# Subroutine makefile for compiling libc modules linked into dynamic linker.
|
||||||
|
|
||||||
# Copyright (C) 2002,2003,2005,2006,2008,2010,2011
|
# Copyright (C) 2002-2012 Free Software Foundation, Inc.
|
||||||
# Free Software Foundation, Inc.
|
|
||||||
# This file is part of the GNU C Library.
|
# This file is part of the GNU C Library.
|
||||||
|
|
||||||
# The GNU C Library is free software; you can redistribute it and/or
|
# The GNU C Library is free software; you can redistribute it and/or
|
||||||
|
@ -130,6 +129,6 @@ ifdef rtld-depfiles
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# This here is the whole point of all the shenanigans.
|
# 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
|
endif
|
||||||
|
|
|
@ -101,4 +101,4 @@ ifneq (,$(cpp-srcs-left))
|
||||||
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
|
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1
|
CPPFLAGS-$(lib) := -DNOT_IN_libc=1 -DIS_IN_$(lib)=1 -DIN_LIB=$(lib)
|
||||||
|
|
80
include/stap-probe.h
Normal file
80
include/stap-probe.h
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/* Macros for defining Systemtap <sys/sdt.h> static probe points.
|
||||||
|
Copyright (C) 2012 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, see
|
||||||
|
<http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#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__
|
||||||
|
/* Evaluate all the arguments and verify that N matches their number. */
|
||||||
|
# define LIBC_PROBE(name, n, ...) \
|
||||||
|
do { \
|
||||||
|
_Bool __libc_probe_args[] = { 0, ## __VA_ARGS__ }; \
|
||||||
|
_Bool __libc_probe_verify_n[(sizeof __libc_probe_args / sizeof (_Bool)) \
|
||||||
|
== n + 1 ? 1 : -1]; \
|
||||||
|
(void) __libc_probe_verify_n; \
|
||||||
|
} while (0)
|
||||||
|
# else
|
||||||
|
# define LIBC_PROBE(name, n, ...) /* Nothing. */
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define LIBC_PROBE_ASM(name, template) /* Nothing. */
|
||||||
|
# define LIBC_PROBE_ASM_OPERANDS(n, ...) /* Nothing. */
|
||||||
|
|
||||||
|
#endif /* USE_STAP_PROBE. */
|
||||||
|
|
||||||
|
#endif /* stap-probe.h */
|
|
@ -1,3 +1,7 @@
|
||||||
|
2012-05-24 Roland McGrath <roland@hack.frob.com>
|
||||||
|
|
||||||
|
* pthread_create.c (start_thread): Define pthread_start LIBC_PROBE.
|
||||||
|
|
||||||
2012-05-17 Andreas Jaeger <aj@suse.de>
|
2012-05-17 Andreas Jaeger <aj@suse.de>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h
|
* sysdeps/unix/sysv/linux/i386/i686/dl-sysdep.h
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
|
|
||||||
#include <shlib-compat.h>
|
#include <shlib-compat.h>
|
||||||
|
|
||||||
|
#include <stap-probe.h>
|
||||||
|
|
||||||
|
|
||||||
/* Local function to start thread and handle cleanup. */
|
/* Local function to start thread and handle cleanup. */
|
||||||
static int start_thread (void *arg);
|
static int start_thread (void *arg);
|
||||||
|
@ -299,6 +301,8 @@ start_thread (void *arg)
|
||||||
CANCEL_RESET (oldtype);
|
CANCEL_RESET (oldtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
|
||||||
|
|
||||||
/* Run the code the user provided. */
|
/* Run the code the user provided. */
|
||||||
#ifdef CALL_THREAD_FCT
|
#ifdef CALL_THREAD_FCT
|
||||||
THREAD_SETMEM (pd, result, CALL_THREAD_FCT (pd));
|
THREAD_SETMEM (pd, result, CALL_THREAD_FCT (pd));
|
||||||
|
|
Loading…
Add table
Reference in a new issue