mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 13:53:31 +01:00
trace: Add USDT probes generation support
This commit adds both configure options and probe generation for tracepoints. Part of #32910 Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
70f031528d
commit
668fc70a20
21
configure.ac
21
configure.ac
@ -258,6 +258,20 @@ AC_ARG_ENABLE(libscrypt,
|
||||
|
||||
dnl --- Tracing Options. ---
|
||||
|
||||
dnl USDT instrumentation option.
|
||||
AC_ARG_ENABLE(tracing-instrumentation-usdt,
|
||||
AS_HELP_STRING([--enable-tracing-instrumentation-usdt],
|
||||
[build with tracing USDT instrumentation]))
|
||||
AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_USDT],
|
||||
[test "x$enable_tracing_instrumentation_usdt" = "xyes"])
|
||||
|
||||
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])], [])
|
||||
AC_DEFINE([USE_TRACING_INSTRUMENTATION_USDT], [1], [Using USDT instrumentation])
|
||||
fi
|
||||
|
||||
dnl Tracepoints event to debug logs.
|
||||
AC_ARG_ENABLE(tracing-instrumentation-log-debug,
|
||||
AS_HELP_STRING([--enable-tracing-instrumentation-log-debug],
|
||||
@ -267,9 +281,11 @@ AC_ARG_ENABLE(tracing-instrumentation-log-debug,
|
||||
AM_CONDITIONAL([USE_TRACING_INSTRUMENTATION_LOG_DEBUG],
|
||||
[test "x$enable_tracing_instrumentation_log_debug" = "xyes"])
|
||||
|
||||
dnl Define that tracing is supported.
|
||||
dnl Define that tracing is supported if any instrumentation is used.
|
||||
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]))
|
||||
|
||||
dnl -- End Tracing Options. --
|
||||
|
||||
@ -2731,6 +2747,9 @@ PPRINT_SUBTITLE([Tracing])
|
||||
test "x$enable_tracing_instrumentation_log_debug" = "xyes" && value=1 || value=0
|
||||
PPRINT_PROP_BOOL([Tracepoints to log_debug() (--enable-tracing-instrumentation-log-debug)], $value)
|
||||
|
||||
test "x$enable_tracing_instrumentation_usdt" = "xyes" && value=1 || value=0
|
||||
PPRINT_PROP_BOOL([USDT Instrumentation (--enable-tracing-instrumentation-usdt)], $value)
|
||||
|
||||
AS_ECHO
|
||||
PPRINT_SUBTITLE([Install Directories])
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
/**
|
||||
* \file events.h
|
||||
* \brief Header file for Tor event tracing.
|
||||
* \brief Header file for Tor tracing instrumentation definition.
|
||||
**/
|
||||
|
||||
#ifndef TOR_LIB_TRACE_EVENTS_H
|
||||
@ -16,12 +16,17 @@
|
||||
#define tor_trace(subsystem, event_name, ...) \
|
||||
do { \
|
||||
TOR_TRACE_LOG_DEBUG(tor_ ## subsystem, event_name); \
|
||||
TOR_TRACE_USDT(tor_ ## subsystem, event_name, ## __VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
/* This corresponds to the --enable-tracing-instrumentation-log-debug
|
||||
* configure option which maps all tracepoints to a log_debug() statement. */
|
||||
#include "lib/trace/debug.h"
|
||||
|
||||
/* This corresponds to the --enable-tracing-instrumentation-usdt configure
|
||||
* option which will generate USDT probes for each tracepoints. */
|
||||
#include "lib/trace/usdt/usdt.h"
|
||||
|
||||
#else /* !defined(HAVE_TRACING) */
|
||||
|
||||
/* Reaching this point, tracing is disabled thus we NOP every tracepoints
|
||||
|
@ -18,6 +18,10 @@ TRACEHEADERS += \
|
||||
src/lib/trace/debug.h
|
||||
endif
|
||||
|
||||
if USE_TRACING_INSTRUMENTATION_USDT
|
||||
include src/lib/trace/usdt/include.am
|
||||
endif
|
||||
|
||||
src_lib_libtor_trace_a_SOURCES = $(LIBTOR_TRACE_A_SOURCES)
|
||||
|
||||
noinst_HEADERS+= $(TRACEHEADERS)
|
||||
|
3
src/lib/trace/usdt/include.am
Normal file
3
src/lib/trace/usdt/include.am
Normal file
@ -0,0 +1,3 @@
|
||||
# ADD_C_FILE: INSERT HEADERS HERE.
|
||||
TRACEHEADERS += \
|
||||
src/lib/trace/usdt/usdt.h
|
33
src/lib/trace/usdt/usdt.h
Normal file
33
src/lib/trace/usdt/usdt.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* Copyright (c) 2020, The Tor Project, Inc. */
|
||||
/* See LICENSE for licensing information */
|
||||
|
||||
/**
|
||||
* \file trace.h
|
||||
* \brief Header for usdt.h
|
||||
**/
|
||||
|
||||
#ifndef TOR_TRACE_USDT_USDT_H
|
||||
#define TOR_TRACE_USDT_USDT_H
|
||||
|
||||
#ifdef USE_TRACING_INSTRUMENTATION_USDT
|
||||
|
||||
#ifdef HAVE_SYS_SDT_H
|
||||
#define SDT_USE_VARIADIC
|
||||
#include <sys/sdt.h>
|
||||
#define TOR_STAP_PROBEV STAP_PROBEV
|
||||
#else /* defined(HAVE_SYS_SDT_H) */
|
||||
#define TOR_STAP_PROBEV(...)
|
||||
#endif
|
||||
|
||||
/* Map events to an USDT probe. */
|
||||
#define TOR_TRACE_USDT(subsystem, event_name, ...) \
|
||||
TOR_STAP_PROBEV(subsystem, event_name, ## __VA_ARGS__);
|
||||
|
||||
#else /* !defined(USE_TRACING_INSTRUMENTATION_USDT) */
|
||||
|
||||
/* NOP event. */
|
||||
#define TOR_TRACE_USDT(subsystem, event_name, ...)
|
||||
|
||||
#endif /* !defined(USE_TRACING_INSTRUMENTATION_USDT) */
|
||||
|
||||
#endif /* !defined(TOR_TRACE_USDT_USDT_H) */
|
Loading…
Reference in New Issue
Block a user