summaryrefslogtreecommitdiff
path: root/src/lib/trace/events.h
blob: fcd31e24e19b2033e09983d1d7e879038999d5db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* Copyright (c) 2017-2020, The Tor Project, Inc. */
/* See LICENSE for licensing information */

/**
 * \file events.h
 * \brief Header file for Tor tracing instrumentation definition.
 **/

#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);             \
    TOR_TRACE_USDT(tor_ ## subsystem, event_name, ## __VA_ARGS__);  \
  } 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"

/* This corresponds to the --enable-tracing-instrumentation-usdt configure
 * option which will generate USDT probes for each tracepoints. */
#include "lib/trace/usdt/usdt.h"

#else /* !defined(HAVE_TRACING) */

/* 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(HAVE_TRACING) */

#endif /* !defined(TOR_LIB_TRACE_EVENTS_H) */