From 5f0c8403f69d5334d9026ab24895f235306bda7e Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Mon, 29 Feb 2016 13:05:59 +0100 Subject: [PATCH 02/10] BUILD: Add build infrastructure for systemtap scripts Adds infrastructure that generatest the probes.h and probes.o from the dtrace probes.d file. The probes.d file is empty except for the provider name in this commit, its content will be added with later commits that actually add some content. The probes.d file is always distributed in the tarball so that distributions can optionally enable systemtap support. The generation is done using the "dtrace" command because the probes.d file is compatible with the Solaris dtrace format. Please see "man 1 dtrace" for more information on the dtrace format and the command line tool. In order to make libtool happy, a fake libtool object is generated. This hunk was taken from the libvirt code. The AM_V_GEN macro is used to make the build compatible with the silent build configuration. To enable systemtap probing, configure sssd with: --enable-systemtap In order to do so, the 'dtrace' command-line utility must be installed. On Fedora and RHEL, this package is installed as part of the "systemtap-sdt-devel" package. You'll also want the 'systemtap' package installed as well as the matching versions of kernel-devel and kernel-debuginfo on your machine. --- Makefile.am | 43 +++++++++++++++++++++++++++++++++++++++++-- configure.ac | 4 ++++ src/external/systemtap.m4 | 35 +++++++++++++++++++++++++++++++++++ src/systemtap/sssd_probes.d | 2 ++ src/tests/cwrap/Makefile.am | 6 ++++++ src/util/probes.h | 2 ++ 6 files changed, 90 insertions(+), 2 deletions(-) create mode 100644 src/external/systemtap.m4 create mode 100644 src/systemtap/sssd_probes.d diff --git a/Makefile.am b/Makefile.am index eb4ea65fad6ff1adb3d1e31b801a48feed194115..315a24c21151dacd4d97e3c30e6762bbe631cac9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -12,6 +12,8 @@ DISTCHECK_CONFIGURE_FLAGS = --with-ldb-lib-dir="$$dc_install_base"/lib/ldb \ --enable-all-experimental-features \ $(extra_distcheck_flags) \ $(AUX_DISTCHECK_CONFIGURE_FLAGS) +CLEANFILES = $(NULL) +BUILT_SOURCES = $(NULL) SUBDIRS = po @@ -403,6 +405,7 @@ dist_noinst_DATA = \ contrib/ci/sssd.supp \ src/tests/cmocka/p11_nssdb/cert9.db \ src/tests/cmocka/p11_nssdb/key4.db \ + $(SYSTEMTAP_PROBES) \ $(NULL) ############################### @@ -895,6 +898,9 @@ libsss_util_la_SOURCES += \ src/db/sysdb_ssh.c \ src/util/sss_ssh.c endif +if BUILD_SYSTEMTAP +libsss_util_la_LIBADD += stap_generated_probes.lo +endif libsss_util_la_LDFLAGS = -avoid-version pkglib_LTLIBRARIES += libsss_semanage.la @@ -1067,6 +1073,39 @@ include_HEADERS += \ src/lib/sifp/sss_sifp_dbus.h endif +######################### +# Systemtap tracing # +######################### + +if BUILD_SYSTEMTAP +SYSTEMTAP_PROBES = \ + $(srcdir)/src/systemtap/sssd_probes.d \ + $(NULL) + +stap_generated_probes.h: $(srcdir)/src/systemtap/sssd_probes.d + $(AM_V_GEN)$(DTRACE) -C -h -s $< -o $@ + +stap_generated_probes.o: $(srcdir)/src/systemtap/sssd_probes.d stap_generated_probes.h + $(AM_V_GEN)$(DTRACE) -C -G -s $< -o $@ + +stap_generated_probes.lo: stap_generated_probes.o + $(AM_V_GEN)printf %s\\n \ + '# $@ - a libtool object file' \ + '# Generated by libtool (GNU libtool) 2.4' \ + '# Actually generated by Makefile.am, in order to shut up libtool' \ + "pic_object='$<'" \ + "non_pic_object='$<'" \ + > $@ + +BUILT_SOURCES += stap_generated_probes.h + +CLEANFILES += stap_generated_probes.h \ + stap_generated_probes.o \ + stap_generated_probes.lo \ + $(NULL) + +endif + #################### # Sbus Codegen # #################### @@ -1099,7 +1138,7 @@ CODEGEN_CODE = \ $(CODEGEN_CODE): $(SBUS_CODEGEN) -BUILT_SOURCES = $(CODEGEN_CODE) +BUILT_SOURCES += $(CODEGEN_CODE) #################### # Program Binaries # @@ -3782,7 +3821,7 @@ endif rm -f $(builddir)/src/sysv/systemd/sssd.service rm -f $(builddir)/src/sysv/systemd/journal.conf -CLEANFILES = *.X */*.X */*/*.X +CLEANFILES += *.X */*.X */*/*.X tests: all $(check_PROGRAMS) (cd src/tests/cwrap && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; diff --git a/configure.ac b/configure.ac index b4ba366d7a32a45879e9f2e9b6e84256a3ac7235..2c208cd483db977c0b1f3902b1f3c35c649cd89c 100644 --- a/configure.ac +++ b/configure.ac @@ -183,6 +183,7 @@ m4_include([src/external/libnfsidmap.m4]) m4_include([src/external/cwrap.m4]) m4_include([src/external/libresolv.m4]) m4_include([src/external/intgcheck.m4]) +m4_include([src/external/systemtap.m4]) if test x$build_config_lib = xyes; then m4_include([src/external/libaugeas.m4]) @@ -424,6 +425,9 @@ AM_CHECK_CMOCKA AM_CHECK_UID_WRAPPER AM_CHECK_NSS_WRAPPER +# Check if the user wants SSSD to be compiled with systemtap probes +AM_CHECK_SYSTEMTAP + SSS_ENABLE_INTGCHECK_REQS AM_CONDITIONAL([HAVE_DEVSHM], [test -d /dev/shm]) diff --git a/src/external/systemtap.m4 b/src/external/systemtap.m4 new file mode 100644 index 0000000000000000000000000000000000000000..d1caa2017f0730394339f0a439046df6b56cb2ba --- /dev/null +++ b/src/external/systemtap.m4 @@ -0,0 +1,35 @@ +dnl A macro to check the availability of systemtap user-space probes +AC_DEFUN([AM_CHECK_SYSTEMTAP], +[ + AC_ARG_ENABLE([systemtap], + [AS_HELP_STRING([--enable-systemtap], + [Enable inclusion of systemtap trace support])], + [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP='no']) + + if test "x${ENABLE_SYSTEMTAP}" = xyes; then + AC_CHECK_PROGS(DTRACE, dtrace) + if test -z "$DTRACE"; then + AC_MSG_ERROR([dtrace not found]) + fi + + AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'], + [SDT_H_FOUND='no'; + AC_MSG_ERROR([systemtap support needs sys/sdt.h header])]) + + AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if systemtap is enabled]) + HAVE_SYSTEMTAP=1 + + AC_ARG_WITH([tapset-install-dir], + [AS_HELP_STRING([--with-tapset-install-dir], + [The absolute path where the tapset dir will be installed])], + [if test "x${withval}" = x; then + tapset_dir="\$(datadir)/systemtap/tapset" + else + tapset_dir="${withval}" + fi], + [tapset_dir="\$(datadir)/systemtap/tapset"]) + AC_SUBST(tapset_dir) + fi + + AM_CONDITIONAL([BUILD_SYSTEMTAP], [test x$HAVE_SYSTEMTAP = x1]) +]) diff --git a/src/systemtap/sssd_probes.d b/src/systemtap/sssd_probes.d new file mode 100644 index 0000000000000000000000000000000000000000..7579577c8661e862d83b9fc7c9fe205d25be30ed --- /dev/null +++ b/src/systemtap/sssd_probes.d @@ -0,0 +1,2 @@ +provider sssd { +} diff --git a/src/tests/cwrap/Makefile.am b/src/tests/cwrap/Makefile.am index a5afb8c020ee00b680aac0680bcf6f6495dd8222..abf50a56f3a9b5e24759e819b24ba01d65192f37 100644 --- a/src/tests/cwrap/Makefile.am +++ b/src/tests/cwrap/Makefile.am @@ -88,6 +88,9 @@ server_tests_LDADD = \ $(abs_top_builddir)/libsss_debug.la \ $(abs_top_builddir)/libsss_test_common.la \ $(NULL) +if BUILD_SYSTEMTAP +server_tests_LDADD += $(abs_top_builddir)/stap_generated_probes.lo +endif usertools_tests_SOURCES = \ test_usertools.c \ @@ -103,6 +106,9 @@ usertools_tests_LDADD = \ $(abs_top_builddir)/libsss_debug.la \ $(abs_top_builddir)/libsss_test_common.la \ $(NULL) +if BUILD_SYSTEMTAP +usertools_tests_LDADD += $(abs_top_builddir)/stap_generated_probes.lo +endif responder_common_tests_SOURCES =\ test_responder_common.c \ diff --git a/src/util/probes.h b/src/util/probes.h index 349f29086e86a51b4551f09f542d0f45bf6f1aae..effce492d0a6cbcfe5b4c347b8931e102b853db2 100644 --- a/src/util/probes.h +++ b/src/util/probes.h @@ -20,6 +20,8 @@ #ifdef HAVE_SYSTEMTAP +#include "stap_generated_probes.h" + /* Probe expansion inspired by libvirt */ #define PROBE_EXPAND(NAME, ...) NAME(__VA_ARGS__) -- 2.4.11