mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 01:59:26 +00:00
Add support for User Statically Defined Tracing (USDT) probes
This adds support for User Statically Defined Tracing (USDT). On Linux, this uses the header from SystemTap and dtrace utility, but the support is universal as long as dtrace is available. Also add the required infrastructure to add probes to libisc, libdns and libns libraries, where most of the probes will be.
This commit is contained in:
parent
1e16d41446
commit
784d055809
@ -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 \
|
||||
|
18
Makefile.dtrace
Normal file
18
Makefile.dtrace
Normal file
@ -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
|
12
Makefile.top
12
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
|
||||
|
@ -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
|
||||
|
||||
|
58
configure.ac
58
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.
|
||||
|
@ -123,7 +123,7 @@ EXTRA_DIST = \
|
||||
$(MANPAGES_RST) \
|
||||
$(MANPAGES_IN)
|
||||
|
||||
CLEANFILES = \
|
||||
CLEANFILES += \
|
||||
$(man_MANS)
|
||||
|
||||
#
|
||||
|
@ -37,7 +37,7 @@ cfg_test_LDADD = \
|
||||
$(LIBDNS_LIBS) \
|
||||
$(LIBISCCFG_LIBS)
|
||||
|
||||
BUILT_SOURCES = \
|
||||
BUILT_SOURCES += \
|
||||
$(OPTIONS_FILES)
|
||||
|
||||
rndc.grammar: cfg_test
|
||||
|
3
lib/dns/.gitignore
vendored
3
lib/dns/.gitignore
vendored
@ -6,4 +6,5 @@ enumtype.h
|
||||
rdatastruct.h
|
||||
gen.dSYM
|
||||
dnstap.pb-c.c
|
||||
dnstap.pb-c.h
|
||||
dnstap.pb-c.h
|
||||
/probes.h
|
||||
|
@ -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)
|
||||
|
15
lib/dns/probes.d
Normal file
15
lib/dns/probes.d
Normal file
@ -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 {
|
||||
};
|
1
lib/isc/.gitignore
vendored
1
lib/isc/.gitignore
vendored
@ -1 +1,2 @@
|
||||
!netdb.h
|
||||
/probes.h
|
||||
|
@ -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)
|
||||
|
15
lib/isc/probes.d
Normal file
15
lib/isc/probes.d
Normal file
@ -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 {
|
||||
};
|
1
lib/ns/.gitignore
vendored
Normal file
1
lib/ns/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/probes.h
|
@ -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)
|
||||
|
15
lib/ns/probes.d
Normal file
15
lib/ns/probes.d
Normal file
@ -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 {
|
||||
};
|
@ -48,8 +48,6 @@ check_PROGRAMS = \
|
||||
zonemgr_test \
|
||||
zt_test
|
||||
|
||||
CLEANFILES =
|
||||
|
||||
if HAVE_PERL
|
||||
|
||||
check_PROGRAMS += \
|
||||
|
49
util/dtrace.sh
Executable file
49
util/dtrace.sh
Executable file
@ -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 <File>]"
|
||||
|
||||
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
|
Loading…
x
Reference in New Issue
Block a user