summaryrefslogtreecommitdiff
path: root/src/lib/trace/events.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2020-03-11 10:54:47 -0400
committerDavid Goulet <dgoulet@torproject.org>2020-07-08 09:18:33 -0400
commit3604d86a016b6202a5864a81f46addc087658b8c (patch)
treef442658ec6439a363d31b802f30cdd32cfff5429 /src/lib/trace/events.h
parentd80c34d214f88c0831ce7cf7595c5e6e8b6fa168 (diff)
downloadtor-3604d86a016b6202a5864a81f46addc087658b8c.tar.gz
tor-3604d86a016b6202a5864a81f46addc087658b8c.zip
trace: Helper macro to disambiguate identifiers
In order to disambiguate the subsystem and event_name identifiers in the tor_trace() macro, add TR_SUBSYS() and TR_EV() which help to identify the parameters of tor_trace() explicitly. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/lib/trace/events.h')
-rw-r--r--src/lib/trace/events.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/lib/trace/events.h b/src/lib/trace/events.h
index 4a8078bf34..ce1604de22 100644
--- a/src/lib/trace/events.h
+++ b/src/lib/trace/events.h
@@ -9,6 +9,8 @@
#ifndef TOR_LIB_TRACE_EVENTS_H
#define TOR_LIB_TRACE_EVENTS_H
+#include "orconfig.h"
+
/*
* A tracepoint signature is defined as follow:
*
@@ -34,13 +36,22 @@
* enabling this instrumentation provides both probes.
*/
+/** Helper to disambiguate these identifiers in the code base. They should
+ * only be used with tor_trace() like so:
+ *
+ * tor_trace(TR_SUBSYS(circuit), TR_EV(opened), ...);
+ */
+
+#define TR_SUBSYS(name) tor_ ## name
+#define TR_EV(name) name
+
#ifdef HAVE_TRACING
#define tor_trace(subsystem, event_name, ...) \
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__); \
+ TOR_TRACE_LOG_DEBUG(subsystem, event_name); \
+ TOR_TRACE_USDT(subsystem, event_name, ## __VA_ARGS__); \
+ TOR_TRACE_LTTNG(subsystem, event_name, ## __VA_ARGS__); \
} while (0)
/* This corresponds to the --enable-tracing-instrumentation-log-debug