debug.h (1193B)
1 /* Copyright (c) 2017-2021, The Tor Project, Inc. */ 2 /* See LICENSE for licensing information */ 3 4 /** 5 * \file debug.h 6 * \brief Macros for debugging our event-trace support. 7 **/ 8 9 #ifndef TOR_TRACE_DEBUG_H 10 #define TOR_TRACE_DEBUG_H 11 12 #ifdef USE_TRACING_INSTRUMENTATION_LOG_DEBUG 13 14 #include "lib/log/log.h" 15 16 /* Stringify pre-processor trick. */ 17 #define XSTR(d) STR(d) 18 #define STR(s) #s 19 20 /* Send every event to a debug log level. This is useful to debug new trace 21 * events without implementing them for a specific event tracing framework. 22 * 23 * NOTE: arguments can't be used because there is no easy generic ways to learn 24 * their type and amount. It is probably doable with massive C pre-processor 25 * trickery but this is meant to be simple. */ 26 27 #define TOR_TRACE_LOG_DEBUG(subsystem, event_name, ...) \ 28 log_debug(LD_GENERAL, "Tracepoint \"" XSTR(event_name) "\" from " \ 29 "subsystem \"" XSTR(subsystem) "\" hit.") 30 31 #else /* !defined(USE_TRACING_INSTRUMENTATION_LOG_DEBUG) */ 32 33 /* NOP the debug event. */ 34 #define TOR_TRACE_LOG_DEBUG(subsystem, name, ...) 35 36 #endif /* defined(USE_TRACING_INSTRUMENTATION_LOG_DEBUG) */ 37 38 #endif /* !defined(TOR_TRACE_DEBUG_H) */