aboutsummaryrefslogtreecommitdiff
path: root/src/lib/trace/debug.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/debug.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/debug.h')
-rw-r--r--src/lib/trace/debug.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/src/lib/trace/debug.h b/src/lib/trace/debug.h
index 87b3074e0b..84a2867a6d 100644
--- a/src/lib/trace/debug.h
+++ b/src/lib/trace/debug.h
@@ -6,8 +6,10 @@
* \brief Macros for debugging our event-trace support.
**/
-#ifndef TOR_TRACE_LOG_DEBUG_H
-#define TOR_TRACE_LOG_DEBUG_H
+#ifndef TOR_TRACE_DEBUG_H
+#define TOR_TRACE_DEBUG_H
+
+#ifdef USE_TRACING_INSTRUMENTATION_LOG_DEBUG
#include "lib/log/log.h"
@@ -17,14 +19,20 @@
/* Send every event to a debug log level. This is useful to debug new trace
* events without implementing them for a specific event tracing framework.
- * Note that the arguments are ignored since at this step we do not know the
- * types and amount there is. */
+ *
+ * NOTE: arguments can't be used becaue there is no easy generic ways to learn
+ * their type and amount. It is probably doable with massive C pre-processor
+ * trickery but this is meant to be simple. */
+
+#define TOR_TRACE_LOG_DEBUG(subsystem, event_name, ...) \
+ log_debug(LD_GENERAL, "Tracepoint \"" XSTR(event_name) "\" from " \
+ "subsystem \"" XSTR(subsystem) "\" hit.")
+
+#else /* defined(USE_TRACING_INSTRUMENTATION_LOG_DEBUG) */
+
+/* NOP the debug event. */
+#define TOR_TRACE_LOG_DEBUG(subsystem, name, ...)
-/* Example on how to map a tracepoint to log_debug(). */
-#undef tor_trace
-#define tor_trace(subsystem, name, args...) \
- log_debug(LD_GENERAL, "Trace event \"" XSTR(name) "\" from " \
- "\"" XSTR(subsystem) "\" hit. " \
- "(line "XSTR(__LINE__) ")")
+#endif /* defined(USE_TRACING_INSTRUMENTATION_LOG_DEBUG) */
-#endif /* !defined(TOR_TRACE_LOG_DEBUG_H) */
+#endif /* !defined(TOR_TRACE_DEBUG_H) */