summaryrefslogtreecommitdiff
path: root/src/lib/trace/debug.h
blob: 4ee14fab8d67d6512b5b27a6b8dbc553872e7ec7 (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 debug.h
 * \brief Macros for debugging our event-trace support.
 **/

#ifndef TOR_TRACE_DEBUG_H
#define TOR_TRACE_DEBUG_H

#ifdef USE_TRACING_INSTRUMENTATION_LOG_DEBUG

#include "lib/log/log.h"

/* Stringify pre-processor trick. */
#define XSTR(d) STR(d)
#define STR(s) #s

/* 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: arguments can't be used because 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, ...)

#endif /* defined(USE_TRACING_INSTRUMENTATION_LOG_DEBUG) */

#endif /* !defined(TOR_TRACE_DEBUG_H) */