tor  0.4.2.1-alpha-dev
events.h
Go to the documentation of this file.
1 /* Copyright (c) 2017-2019, The Tor Project, Inc. */
2 /* See LICENSE for licensing information */
3 
9 #ifndef TOR_TRACE_EVENTS_H
10 #define TOR_TRACE_EVENTS_H
11 
12 /*
13  * The following defines a generic event tracing function name that has to be
14  * used to trace events in the code base.
15  *
16  * That generic function is then defined by a event tracing framework. For
17  * instance, the "log debug" framework sends all trace events to log_debug()
18  * which is defined in src/trace/debug.h which can only be enabled at compile
19  * time (--enable-event-tracing-debug).
20  *
21  * By default, every trace events in the code base are replaced by a NOP. See
22  * doc/HACKING/Tracing.md for more information on how to use event tracing or
23  * add events.
24  */
25 
26 #ifdef TOR_EVENT_TRACING_ENABLED
27 /* Map every trace event to a per subsystem macro. */
28 #define tor_trace(subsystem, name, ...) \
29  tor_trace_##subsystem(name, __VA_ARGS__)
30 
31 /* Enable event tracing for the debug framework where all trace events are
32  * mapped to a log_debug(). */
33 #ifdef USE_EVENT_TRACING_DEBUG
34 #include "lib/trace/debug.h"
35 #endif
36 
37 #else /* !(defined(TOR_EVENT_TRACING_ENABLED)) */
38 
39 /* Reaching this point, we NOP every event declaration because event tracing
40  * is not been enabled at compile time. */
41 #define tor_trace(subsystem, name, args...)
42 
43 #endif /* defined(TOR_EVENT_TRACING_ENABLED) */
44 
45 #endif /* !defined(TOR_TRACE_EVENTS_H) */
Macros for debugging our event-trace support.