]> git.proxmox.com Git - mirror_frr.git/blame - lib/trace.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / trace.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
552e2a30
QY
2/* Tracing macros
3 *
4 * Wraps tracepoint macros for different tracing systems to allow switching
5 * between them at compile time.
6 *
7 * This should not be included directly by source files wishing to provide
8 * tracepoints. Instead, write a header that defines LTTng tracepoints and
9 * which includes this header, and include your new header in your source. USDT
10 * probes do not need tracepoint definitions, but are less capable than LTTng
11 * tracepoints.
12 *
13 * Copyright (C) 2020 NVIDIA Corporation
14 * Quentin Young
552e2a30
QY
15 */
16
17#ifndef _TRACE_H_
18#define _TRACE_H_
19
20#ifdef HAVE_CONFIG_H
21#include "config.h"
22#endif /* HAVE_CONFIG_H */
23
24/*
25 * Provided here:
26 * - frrtrace(n, provider, name, ...args...)
27 * - frrtrace_enabled(provider, name)
28 * - frrtracelog(level, msg, ...)
29 *
30 * Use frrtrace() to define tracepoints. n is the number of arguments; this is
31 * needed because USDT probe definitions use DTRACE_PROBEn macros, so the
32 * number of args must be passed in order to expand the correct macro.
33 *
34 * frrtrace_enabled() maps to tracepoint_enabled() under LTTng and is always
35 * true when using USDT. In the future it could be mapped to USDT semaphores
36 * but this is not implemented at present.
37 *
38 * frrtracelog() maps to tracelog() under LTTng and should only be used in zlog
39 * core code, to propagate zlog messages to LTTng. It expands to nothing
40 * otherwise.
41 */
42
43#if defined(HAVE_LTTNG)
44
45#define frrtrace(nargs, provider, name, ...) \
46 tracepoint(provider, name, ## __VA_ARGS__)
47#define frrtrace_enabled(...) tracepoint_enabled(__VA_ARGS__)
48#define frrtracelog(...) tracelog(__VA_ARGS__)
49
50#elif defined(HAVE_USDT)
51
52#include "sys/sdt.h"
53
54#define frrtrace(nargs, provider, name, ...) \
55 DTRACE_PROBE##nargs(provider, name, ## __VA_ARGS__)
56#define frrtrace_enabled(...) true
57#define frrtracelog(...)
58
59#else
60
61#define frrtrace(nargs, provider, name, ...) (void)0
62#define frrtrace_enabled(...) false
63#define frrtracelog(...) (void)0
64
65#endif
66
67#endif /* _TRACE_H_ */