diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/trace/events.h | 13 | ||||
-rw-r--r-- | src/lib/trace/include.am | 4 | ||||
-rw-r--r-- | src/lib/trace/usdt/include.am | 3 | ||||
-rw-r--r-- | src/lib/trace/usdt/usdt.h | 33 |
4 files changed, 49 insertions, 4 deletions
diff --git a/src/lib/trace/events.h b/src/lib/trace/events.h index b1b31fdc9b..fcd31e24e1 100644 --- a/src/lib/trace/events.h +++ b/src/lib/trace/events.h @@ -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 @@ -13,15 +13,20 @@ #ifdef HAVE_TRACING -#define tor_trace(subsystem, event_name, ...) \ - do { \ - TOR_TRACE_LOG_DEBUG(tor_ ## subsystem, event_name); \ +#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 diff --git a/src/lib/trace/include.am b/src/lib/trace/include.am index 312fd4e87d..01ea0c8a1d 100644 --- a/src/lib/trace/include.am +++ b/src/lib/trace/include.am @@ -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) diff --git a/src/lib/trace/usdt/include.am b/src/lib/trace/usdt/include.am new file mode 100644 index 0000000000..4e7e04c326 --- /dev/null +++ b/src/lib/trace/usdt/include.am @@ -0,0 +1,3 @@ +# ADD_C_FILE: INSERT HEADERS HERE. +TRACEHEADERS += \ + src/lib/trace/usdt/usdt.h diff --git a/src/lib/trace/usdt/usdt.h b/src/lib/trace/usdt/usdt.h new file mode 100644 index 0000000000..0b5fd6c444 --- /dev/null +++ b/src/lib/trace/usdt/usdt.h @@ -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) */ |