diff --git a/Makefile.am b/Makefile.am index 63bb88fd7b..df91934e03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -8,8 +8,8 @@ SUBDIRS += tests # run fuzz tests before system tests SUBDIRS += fuzz bin -BUILT_SOURCES = bind.keys.h -CLEANFILES = bind.keys.h +BUILT_SOURCES += bind.keys.h +CLEANFILES += bind.keys.h bind.keys.h: bind.keys Makefile ${PERL} ${top_srcdir}/util/bindkeys.pl ${top_srcdir}/bind.keys > $@ @@ -19,6 +19,7 @@ bind.keys.h: bind.keys Makefile EXTRA_DIST = \ bind.keys \ util/bindkeys.pl \ + util/dtrace.sh \ contrib \ CHANGES \ COPYRIGHT \ diff --git a/Makefile.dtrace b/Makefile.dtrace new file mode 100644 index 0000000000..ea15124ec4 --- /dev/null +++ b/Makefile.dtrace @@ -0,0 +1,18 @@ +# Hey Emacs, this is -*- makefile-automake -*- file! +# vim: filetype=automake + +AM_V_DTRACE = $(AM_V_DTRACE_@AM_V@) +AM_V_DTRACE_ = $(AM_V_DTRACE_@AM_DEFAULT_V@) +AM_V_DTRACE_0 = @echo " DTRACE $@"; + +BUILT_SOURCES += probes.h +CLEANFILES += probes.h probes.o + +probes.h: probes.d + $(AM_V_DTRACE)$(DTRACE) -s $(srcdir)/probes.d -h -o $@ +probes.lo: probes.d $(DTRACE_DEPS) + $(AM_V_DTRACE)$(LIBTOOL) --mode=compile --tag=CC $(DTRACE) -s $(srcdir)/probes.d -G -o $@ $(DTRACE_OBJS) + +if HAVE_DTRACE +DTRACE_LIBADD = probes.lo +endif diff --git a/Makefile.top b/Makefile.top index ffb63289a7..d01317dadb 100644 --- a/Makefile.top +++ b/Makefile.top @@ -15,6 +15,9 @@ AM_LDFLAGS = \ $(STD_LDFLAGS) LDADD = +BUILT_SOURCES = +CLEANFILES = + if HOST_MACOS AM_LDFLAGS += \ -Wl,-flat_namespace @@ -26,6 +29,9 @@ LIBISC_CFLAGS = \ -I$(top_builddir)/lib/isc/include LIBISC_LIBS = $(top_builddir)/lib/isc/libisc.la +if HAVE_DTRACE +LIBISC_DTRACE = $(top_builddir)/lib/isc/probes.lo +endif LIBDNS_CFLAGS = \ -I$(top_srcdir)/lib/dns/include \ @@ -33,12 +39,18 @@ LIBDNS_CFLAGS = \ LIBDNS_LIBS = \ $(top_builddir)/lib/dns/libdns.la +if HAVE_DTRACE +LIBDNS_DTRACE = $(top_builddir)/lib/dns/probes.lo +endif LIBNS_CFLAGS = \ -I$(top_srcdir)/lib/ns/include LIBNS_LIBS = \ $(top_builddir)/lib/ns/libns.la +if HAVE_DTRACE +LIBNS_DTRACE = $(top_builddir)/lib/ns/probes.lo +endif LIBISCCFG_CFLAGS = \ -I$(top_srcdir)/lib/isccfg/include diff --git a/bin/named/Makefile.am b/bin/named/Makefile.am index 5c861b3ca6..291bab5e2a 100644 --- a/bin/named/Makefile.am +++ b/bin/named/Makefile.am @@ -38,8 +38,8 @@ AM_CPPFLAGS += \ sbin_PROGRAMS = named nodist_named_SOURCES = xsl.c -BUILT_SOURCES = xsl.c -CLEANFILES = xsl.c +BUILT_SOURCES += xsl.c +CLEANFILES += xsl.c EXTRA_DIST = bind9.xsl diff --git a/configure.ac b/configure.ac index 9455cf359e..d14b2b3cbf 100644 --- a/configure.ac +++ b/configure.ac @@ -1568,6 +1568,64 @@ AC_CHECK_HEADERS([glob.h]) AX_GCC_FUNC_ATTRIBUTE([constructor]) AX_GCC_FUNC_ATTRIBUTE([destructor]) +# +# Check whether to enable User Statically Defined Tracing. +# +# This is supported only on Linux now and requires SystemTap libraries. +# +# [pairwise: --enable-tracing=auto, --enable-tracing=yes, --disable-tracing] +AC_ARG_ENABLE([tracing], + [AS_HELP_STRING([--enable-tracing], + [enable User Statically Defined Tracing])], + [], + [enable_tracing=auto]) + +AC_ARG_VAR([DTRACE], [path to dtrace binary used to build User Statically Defined Tracing probes]) +AC_PATH_PROGS([DTRACE], [dtrace]) +AC_CHECK_HEADERS([sys/sdt.h]) + +AC_MSG_CHECKING([whether to enable User Statically Defined Tracing support (default is auto)]) +AS_CASE([$enable_tracing], + [auto], [enable_tracing=yes + AS_IF([test "$ac_cv_header_sys_sdt_h" != "yes"], [enable_tracing=no]) + AS_IF([test -z "$DTRACE"],[enable_tracing=no]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], + [[#if !defined(__has_feature) + #define __has_feature(x) 0 + #endif /* if !defined(__has_feature) */ + #if __has_feature(address_sanitizer) + #define __SANITIZE_ADDRESS__ 1 + #endif /* if __has_feature(address_sanitizer) */ + #if defined(__SANITIZE_ADDRESS__) + #error Address Sanitizer enabled + #endif + ]])], + [], + [enable_tracing=no] + )]) +AS_CASE([$enable_tracing], + [yes], [AS_IF([test "$ac_cv_header_sys_sdt_h" != "yes"], + [AC_MSG_ERROR([sys/sdt.h header not found])]) + AS_IF([test -z "$DTRACE"], + [AC_MSG_ERROR([The dtrace command not found])]) + AC_MSG_RESULT([yes])], + [DTRACE="" + AC_MSG_RESULT([no])]) + +AS_CASE([$host], + [*-linux*],[have_systemtap=true]) + +AM_CONDITIONAL([HAVE_SYSTEMTAP], [test -n "$have_systemtap"]) +AM_CONDITIONAL([HAVE_DTRACE], [test -n "$DTRACE"]) + +# Use shim script if dtrace is not available +AS_IF([test -z "$DTRACE"], + [DTRACE='$(top_srcdir)/util/dtrace.sh']) + +AC_SUBST([DTRACE]) + + # # Files to configure. These are listed here because we used to # specify them as arguments to AC_OUTPUT. diff --git a/doc/man/Makefile.am b/doc/man/Makefile.am index d814b028d8..2590e20da6 100644 --- a/doc/man/Makefile.am +++ b/doc/man/Makefile.am @@ -123,7 +123,7 @@ EXTRA_DIST = \ $(MANPAGES_RST) \ $(MANPAGES_IN) -CLEANFILES = \ +CLEANFILES += \ $(man_MANS) # diff --git a/doc/misc/Makefile.am b/doc/misc/Makefile.am index d613981855..898aa8f08b 100644 --- a/doc/misc/Makefile.am +++ b/doc/misc/Makefile.am @@ -37,7 +37,7 @@ cfg_test_LDADD = \ $(LIBDNS_LIBS) \ $(LIBISCCFG_LIBS) -BUILT_SOURCES = \ +BUILT_SOURCES += \ $(OPTIONS_FILES) rndc.grammar: cfg_test diff --git a/lib/dns/.gitignore b/lib/dns/.gitignore index 66c95ddd79..b41f1dc491 100644 --- a/lib/dns/.gitignore +++ b/lib/dns/.gitignore @@ -6,4 +6,5 @@ enumtype.h rdatastruct.h gen.dSYM dnstap.pb-c.c -dnstap.pb-c.h \ No newline at end of file +dnstap.pb-c.h +/probes.h diff --git a/lib/dns/Makefile.am b/lib/dns/Makefile.am index 9e0eeeb9e1..865a29f06a 100644 --- a/lib/dns/Makefile.am +++ b/lib/dns/Makefile.am @@ -12,10 +12,10 @@ nodist_libdns_la_SOURCES = \ $(nodist_libdns_la_HEADERS) \ code.h -BUILT_SOURCES = \ +BUILT_SOURCES += \ $(nodist_libdns_la_SOURCES) -CLEANFILES = \ +CLEANFILES += \ $(nodist_libdns_la_SOURCES) \ gen$(BUILD_EXEEXT) @@ -124,6 +124,7 @@ libdns_la_HEADERS = \ include/dns/ssu.h \ include/dns/stats.h \ include/dns/time.h \ + include/dns/trace.h \ include/dns/transport.h \ include/dns/tkey.h \ include/dns/trace.h \ @@ -208,6 +209,7 @@ libdns_la_SOURCES = \ order.c \ peer.c \ private.c \ + probes.d \ qp.c \ qp_p.h \ rbt.c \ @@ -330,3 +332,12 @@ if HAVE_LMDB libdns_la_CPPFLAGS += $(LMDB_CFLAGS) libdns_la_LIBADD += $(LMDB_LIBS) endif + +if !HAVE_SYSTEMTAP +DTRACE_DEPS = libdns_la-xfrin.lo +DTRACE_OBJS = .libs/libdns_la-xfrin.$(OBJEXT) +endif + +include $(top_srcdir)/Makefile.dtrace + +libdns_la_LIBADD += $(DTRACE_LIBADD) diff --git a/lib/dns/probes.d b/lib/dns/probes.d new file mode 100644 index 0000000000..056d9e6855 --- /dev/null +++ b/lib/dns/probes.d @@ -0,0 +1,15 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +provider libdns { +}; diff --git a/lib/isc/.gitignore b/lib/isc/.gitignore index 734ffcd9b4..d71e842664 100644 --- a/lib/isc/.gitignore +++ b/lib/isc/.gitignore @@ -1 +1,2 @@ !netdb.h +/probes.h diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index df2d327213..0f692d32c6 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -171,6 +171,7 @@ libisc_la_SOURCES = \ picohttpparser.c \ picohttpparser.h \ portset.c \ + probes.d \ quota.c \ radix.c \ random.c \ @@ -256,3 +257,12 @@ libisc_la_CPPFLAGS += \ libisc_la_LIBADD += \ $(LIBXML2_LIBS) endif HAVE_LIBXML2 + +if !HAVE_SYSTEMTAP +DTRACE_DEPS = libisc_la-rwlock.lo libisc_la-job.lo +DTRACE_OBJS = .libs/libisc_la-rwlock.$(OBJEXT) .libs/libisc_la-job.$(OBJEXT) +endif + +include $(top_srcdir)/Makefile.dtrace + +libisc_la_LIBADD += $(DTRACE_LIBADD) diff --git a/lib/isc/probes.d b/lib/isc/probes.d new file mode 100644 index 0000000000..bc587ed4f7 --- /dev/null +++ b/lib/isc/probes.d @@ -0,0 +1,15 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +provider libisc { +}; diff --git a/lib/ns/.gitignore b/lib/ns/.gitignore new file mode 100644 index 0000000000..1d0e72db59 --- /dev/null +++ b/lib/ns/.gitignore @@ -0,0 +1 @@ +/probes.h diff --git a/lib/ns/Makefile.am b/lib/ns/Makefile.am index 37274babe5..39b64a76b3 100644 --- a/lib/ns/Makefile.am +++ b/lib/ns/Makefile.am @@ -30,6 +30,7 @@ libns_la_SOURCES = \ listenlist.c \ log.c \ notify.c \ + probes.d \ query.c \ server.c \ sortlist.c \ @@ -54,3 +55,12 @@ libns_la_LIBADD = \ libns_la_LDFLAGS = \ $(AM_LDFLAGS) \ -release "$(PACKAGE_VERSION)" + +if !HAVE_SYSTEMTAP +DTRACE_DEPS = libns_la-query.lo +DTRACE_OBJS = .libs/libns_la-query.$(OBJEXT) +endif + +include $(top_srcdir)/Makefile.dtrace + +libns_la_LIBADD += $(DTRACE_LIBADD) diff --git a/lib/ns/probes.d b/lib/ns/probes.d new file mode 100644 index 0000000000..316ca37a1f --- /dev/null +++ b/lib/ns/probes.d @@ -0,0 +1,15 @@ +/* + * Copyright (C) Internet Systems Consortium, Inc. ("ISC") + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, you can obtain one at https://mozilla.org/MPL/2.0/. + * + * See the COPYRIGHT file distributed with this work for additional + * information regarding copyright ownership. + */ + +provider libns { +}; diff --git a/tests/dns/Makefile.am b/tests/dns/Makefile.am index da775f4995..aa9f1ea744 100644 --- a/tests/dns/Makefile.am +++ b/tests/dns/Makefile.am @@ -48,8 +48,6 @@ check_PROGRAMS = \ zonemgr_test \ zt_test -CLEANFILES = - if HAVE_PERL check_PROGRAMS += \ diff --git a/util/dtrace.sh b/util/dtrace.sh new file mode 100755 index 0000000000..a9da900238 --- /dev/null +++ b/util/dtrace.sh @@ -0,0 +1,49 @@ +#!/bin/sh + +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") +# +# SPDX-License-Identifier: MPL-2.0 +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, you can obtain one at https://mozilla.org/MPL/2.0/. +# +# See the COPYRIGHT file distributed with this work for additional +# information regarding copyright ownership. + +USAGE="# Usage: ${0} [-h | -G] -s File.d [-o ]" + +mode= +while getopts hGs:o: opt; do + case "${opt}" in + h) mode=header ;; + s) input=$OPTARG ;; + o) output=$OPTARG ;; + G) mode=object ;; + \?) echo $USAGE; exit 1;; + esac +done +shift $((OPTIND - 1)) + +if test -z "${mode}" || test -z "${input}"; then + echo $USAGE; exit 1; +fi + +case "${mode}" in + header) + if test -z "${output}"; then + output="$(basename "${input}" .d).h" + fi + PROVIDER=$(cat "${input}" | sed -ne 's/^provider \(.*\) {/\1/p' | tr "a-z" "A-Z") + sed -ne 's/.*probe \(.*\)(.*);/\1/p' "${input}" | tr "a-z" "A-Z" | while read PROBE; do + echo "#define ${PROVIDER}_${PROBE}_ENABLED() 0"; + echo "#define ${PROVIDER}_${PROBE}(...)"; + done > "${output}" + ;; + object) + if test -z "${output}"; then + output="$(basename "${input}" .d).o" + fi + echo "extern int empty;" | gcc -xc -c - -fPIC -DPIC -o "${output}" + ;; +esac