Commit 0de543aa authored by David Goulet's avatar David Goulet 🔆
Browse files

trace: Add LTTng-UST interface support

No probes at this point. They are per subsystem and thus in later commits.

Part of #32910
parent 668fc70a
......@@ -258,6 +258,24 @@ AC_ARG_ENABLE(libscrypt,
dnl --- Tracing Options. ---
TOR_TRACE_LIBS=
dnl LTTng instrumentation option.
AC_ARG_ENABLE(tracing-instrumentation-lttng,
AS_HELP_STRING([--enable-tracing-instrumentation-lttng],
[build with LTTng-UST instrumentation]))
AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LTTNG],
[test "x$enable_tracing_instrumentation_lttng" = "xyes"])
if test "x$enable_tracing_instrumentation_lttng" = "xyes"; then
AC_CHECK_HEADERS([lttng/tracepoint.h], [],
[AC_MSG_ERROR([LTTng instrumentation headers not found.
On Debian, apt install liblttng-ust-dev"])], [])
AC_DEFINE([USE_TRACING_INSTRUMENTATION_LTTNG], [1], [Using LTTng instrumentation])
TOR_TRACE_LIBS="-llttng-ust -ldl"
fi
dnl USDT instrumentation option.
AC_ARG_ENABLE(tracing-instrumentation-usdt,
AS_HELP_STRING([--enable-tracing-instrumentation-usdt],
......@@ -269,6 +287,9 @@ if test "x$enable_tracing_instrumentation_usdt" = "xyes"; then
AC_CHECK_HEADERS([sys/sdt.h], [],
[AC_MSG_ERROR([USDT instrumentation requires sys/sdt.h header.
On Debian, apt install systemtap-sdt-dev])], [])
dnl LTTng generates USDT probes if the UST library was built with
dnl --with-sdt. There is unfortunately no way to check that so we always
dnl build the USDT probes even though LTTng instrumentation was requested.
AC_DEFINE([USE_TRACING_INSTRUMENTATION_USDT], [1], [Using USDT instrumentation])
fi
......@@ -286,6 +307,11 @@ AM_COND_IF([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
AM_COND_IF([USE_TRACING_INSTRUMENTATION_USDT],
AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
AM_COND_IF([USE_TRACING_INSTRUMENTATION_LTTNG],
AC_DEFINE([HAVE_TRACING], [1], [Compiled with tracing support]))
dnl Finally, define the trace libs.
AC_SUBST([TOR_TRACE_LIBS])
dnl -- End Tracing Options. --
......@@ -2750,6 +2776,9 @@ PPRINT_PROP_BOOL([Tracepoints to log_debug() (--enable-tracing-instrumentation-l
test "x$enable_tracing_instrumentation_usdt" = "xyes" && value=1 || value=0
PPRINT_PROP_BOOL([USDT Instrumentation (--enable-tracing-instrumentation-usdt)], $value)
test "x$enable_tracing_instrumentation_lttng" = "xyes" && value=1 || value=0
PPRINT_PROP_BOOL([LTTng Instrumentation (--enable-tracing-instrumentation-lttng)], $value)
AS_ECHO
PPRINT_SUBTITLE([Install Directories])
......
......@@ -20,7 +20,7 @@ src_app_tor_LDADD = $(TOR_INTERNAL_LIBS) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
if COVERAGE_ENABLED
src_app_tor_cov_SOURCES = $(src_app_tor_SOURCES)
......@@ -31,5 +31,5 @@ src_app_tor_cov_LDADD = $(TOR_INTERNAL_TESTING_LIBS) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ $(TOR_LIBS_CRYPTLIB) \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
endif
......@@ -17,6 +17,7 @@
do { \
TOR_TRACE_LOG_DEBUG(tor_ ## subsystem, event_name); \
TOR_TRACE_USDT(tor_ ## subsystem, event_name, ## __VA_ARGS__); \
TOR_TRACE_LTTNG(tor_ ## subsystem, event_name, ## __VA_ARGS__); \
} while (0)
/* This corresponds to the --enable-tracing-instrumentation-log-debug
......@@ -27,6 +28,10 @@
* option which will generate USDT probes for each tracepoints. */
#include "lib/trace/usdt/usdt.h"
/* This corresponds to the --enable-tracing-instrumentation-lttng configure
* option which will generate LTTng probes for each tracepoints. */
#include "lib/trace/lttng/lttng.h"
#else /* !defined(HAVE_TRACING) */
/* Reaching this point, tracing is disabled thus we NOP every tracepoints
......
......@@ -22,6 +22,10 @@ if USE_TRACING_INSTRUMENTATION_USDT
include src/lib/trace/usdt/include.am
endif
if USE_TRACING_INSTRUMENTATION_LTTNG
include src/lib/trace/lttng/include.am
endif
src_lib_libtor_trace_a_SOURCES = $(LIBTOR_TRACE_A_SOURCES)
noinst_HEADERS+= $(TRACEHEADERS)
# ADD_C_FILE: INSERT HEADERS HERE.
TRACEHEADERS += \
src/lib/trace/lttng/lttng.h
/* Copyright (c) 2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
* \file lttng.h
* \brief Header file for lttng.c.
**/
#ifndef TOR_TRACE_LTTNG_LTTNG_H
#define TOR_TRACE_LTTNG_LTTNG_H
#ifdef USE_TRACING_INSTRUMENTATION_LTTNG
#include <lttng/tracepoint.h>
/* Map event to an LTTng tracepoint. */
#define TOR_TRACE_LTTNG(subsystem, event_name, ...) \
tracepoint(subsystem, event_name, ## __VA_ARGS__)
#else /* !defined(USE_TRACING_INSTRUMENTATION_LTTNG) */
/* NOP event. */
#define TOR_TRACE_LTTNG(subsystem, event_name, ...)
#endif /* !defined(USE_TRACING_INSTRUMENTATION_LTTNG) */
#endif /* TOR_TRACE_LTTNG_LTTNG_H */
......@@ -14,7 +14,7 @@ FUZZING_LIBS = \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ @CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ \
@TOR_LZMA_LIBS@ \
@TOR_ZSTD_LIBS@
@TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
oss-fuzz-prereqs: \
$(TOR_INTERNAL_TESTING_LIBS)
......
......@@ -297,7 +297,7 @@ src_test_test_switch_id_LDADD = \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_USERENV@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@
......@@ -307,7 +307,7 @@ src_test_test_LDADD = \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
src_test_test_slow_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_slow_CFLAGS = $(src_test_test_CFLAGS)
......@@ -336,7 +336,7 @@ src_test_bench_LDADD = \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
@TOR_SYSTEMD_LIBS@ @TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
src_test_test_workqueue_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB) \
@TOR_LDFLAGS_libevent@
......@@ -346,7 +346,7 @@ src_test_test_workqueue_LDADD = \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@
@TOR_LZMA_LIBS@ @TOR_ZSTD_LIBS@ @TOR_TRACE_LIBS@
src_test_test_timers_CPPFLAGS = $(src_test_test_CPPFLAGS)
src_test_test_timers_CFLAGS = $(src_test_test_CFLAGS)
......@@ -358,7 +358,7 @@ src_test_test_timers_LDADD = \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ \
@TOR_LZMA_LIBS@
@TOR_LZMA_LIBS@ @TOR_TRACE_LIBS@
src_test_test_timers_LDFLAGS = $(src_test_test_LDFLAGS)
# ADD_C_FILE: INSERT HEADERS HERE.
......@@ -394,7 +394,7 @@ src_test_test_ntor_cl_LDADD = \
$(rust_ldadd) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@CURVE25519_LIBS@ @TOR_LZMA_LIBS@
@CURVE25519_LIBS@ @TOR_LZMA_LIBS@ @TOR_TRACE_LIBS@
src_test_test_ntor_cl_AM_CPPFLAGS = \
$(AM_CPPFLAGS)
......@@ -403,7 +403,8 @@ src_test_test_hs_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ $(TOR_LDFLAGS_CRYPTLIB)
src_test_test_hs_ntor_cl_LDADD = \
$(TOR_INTERNAL_LIBS) \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ \
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
$(TOR_LIBS_CRYPTLIB) @TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ \
@CURVE25519_LIBS@ @TOR_TRACE_LIBS@
src_test_test_hs_ntor_cl_AM_CPPFLAGS = \
$(AM_CPPFLAGS)
......@@ -415,7 +416,8 @@ src_test_test_bt_cl_LDADD = \
$(TOR_UTIL_TESTING_LIBS) \
$(rust_ldadd) \
@TOR_LIB_MATH@ \
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@
@TOR_LIB_WS32@ @TOR_LIB_IPHLPAPI@ @TOR_LIB_GDI@ @TOR_LIB_USERENV@ \
@TOR_TRACE_LIBS@
src_test_test_bt_cl_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS) $(TEST_CPPFLAGS)
endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment