aboutsummaryrefslogtreecommitdiff
path: root/src/lib/trace/events.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-01-09 12:17:49 -0500
committerDavid Goulet <dgoulet@torproject.org>2020-07-08 09:10:08 -0400
commit6fc6cbd9b347ee1f82a024a04c0276bbc6e82c99 (patch)
tree137b8cc822adbdb5bc46fe9c038e234af5e67179 /src/lib/trace/events.h
parente4bfa734a60555a1871a008c2a125fe55d564aa1 (diff)
downloadtor-6fc6cbd9b347ee1f82a024a04c0276bbc6e82c99.tar.gz
tor-6fc6cbd9b347ee1f82a024a04c0276bbc6e82c99.zip
trace: Better structure lib/trace and configure options
In the next commits, we'll add more tracing options for instrumentation and specific tracer. This rename follows a more meaningful naming standard. It also adds a catch all "HAVE_TRACING" define that indicate in the code that we have tracing enabled. Part of #32910 Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/lib/trace/events.h')
-rw-r--r--src/lib/trace/events.h52
1 files changed, 20 insertions, 32 deletions
diff --git a/src/lib/trace/events.h b/src/lib/trace/events.h
index 368f85dd02..b1b31fdc9b 100644
--- a/src/lib/trace/events.h
+++ b/src/lib/trace/events.h
@@ -6,40 +6,28 @@
* \brief Header file for Tor event tracing.
**/
-#ifndef TOR_TRACE_EVENTS_H
-#define TOR_TRACE_EVENTS_H
-
-/*
- * The following defines a generic event tracing function name that has to be
- * used to trace events in the code base.
- *
- * That generic function is then defined by a event tracing framework. For
- * instance, the "log debug" framework sends all trace events to log_debug()
- * which is defined in src/trace/debug.h which can only be enabled at compile
- * time (--enable-event-tracing-debug).
- *
- * By default, every trace events in the code base are replaced by a NOP. See
- * doc/HACKING/Tracing.md for more information on how to use event tracing or
- * add events.
- */
-
-#ifdef TOR_EVENT_TRACING_ENABLED
-/* Map every trace event to a per subsystem macro. */
-#define tor_trace(subsystem, name, ...) \
- tor_trace_##subsystem(name, __VA_ARGS__)
-
-/* Enable event tracing for the debug framework where all trace events are
- * mapped to a log_debug(). */
-#ifdef USE_EVENT_TRACING_DEBUG
+#ifndef TOR_LIB_TRACE_EVENTS_H
+#define TOR_LIB_TRACE_EVENTS_H
+
+/* XXX: DOCDOC once framework is stable. */
+
+#ifdef HAVE_TRACING
+
+#define tor_trace(subsystem, event_name, ...) \
+ do { \
+ TOR_TRACE_LOG_DEBUG(tor_ ## subsystem, event_name); \
+ } 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"
-#endif
-#else /* !defined(TOR_EVENT_TRACING_ENABLED) */
+#else /* !defined(HAVE_TRACING) */
-/* Reaching this point, we NOP every event declaration because event tracing
- * is not been enabled at compile time. */
-#define tor_trace(subsystem, name, args...)
+/* Reaching this point, tracing is disabled thus we NOP every tracepoints
+ * declaration so we have no execution cost at runtime. */
+#define tor_trace(subsystem, name, ...)
-#endif /* defined(TOR_EVENT_TRACING_ENABLED) */
+#endif /* defined(HAVE_TRACING) */
-#endif /* !defined(TOR_TRACE_EVENTS_H) */
+#endif /* !defined(TOR_LIB_TRACE_EVENTS_H) */