Skip to content

Commit 22eb793

Browse files
jb55laanwj
authored andcommitted
tracing: add tracing framework
Signed-off-by: William Casarin <[email protected]>
1 parent 933ab8a commit 22eb793

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ BITCOIN_CORE_H = \
235235
util/system.h \
236236
util/threadnames.h \
237237
util/time.h \
238+
util/trace.h \
238239
util/translation.h \
239240
util/ui_change_type.h \
240241
util/url.h \

src/util/trace.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) 2020 The Bitcoin Core developers
2+
// Distributed under the MIT software license, see the accompanying
3+
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4+
5+
#ifndef BITCOIN_UTIL_TRACE_H
6+
#define BITCOIN_UTIL_TRACE_H
7+
8+
#ifdef ENABLE_TRACING
9+
10+
#include <sys/sdt.h>
11+
12+
#define TRACE(context, event) DTRACE_PROBE(context, event)
13+
#define TRACE1(context, event, a) DTRACE_PROBE1(context, event, a)
14+
#define TRACE2(context, event, a, b) DTRACE_PROBE2(context, event, a, b)
15+
#define TRACE3(context, event, a, b, c) DTRACE_PROBE3(context, event, a, b, c)
16+
#define TRACE4(context, event, a, b, c, d) DTRACE_PROBE4(context, event, a, b, c, d)
17+
#define TRACE5(context, event, a, b, c, d, e) DTRACE_PROBE5(context, event, a, b, c, d, e)
18+
#define TRACE6(context, event, a, b, c, d, e, f) DTRACE_PROBE6(context, event, a, b, c, d, e, f)
19+
#define TRACE7(context, event, a, b, c, d, e, f, g) DTRACE_PROBE7(context, event, a, b, c, d, e, f, g)
20+
#define TRACE8(context, event, a, b, c, d, e, f, g, h) DTRACE_PROBE8(context, event, a, b, c, d, e, f, g, h)
21+
#define TRACE9(context, event, a, b, c, d, e, f, g, h, i) DTRACE_PROBE9(context, event, a, b, c, d, e, f, g, h, i)
22+
#define TRACE10(context, event, a, b, c, d, e, f, g, h, i, j) DTRACE_PROBE10(context, event, a, b, c, d, e, f, g, h, i, j)
23+
#define TRACE11(context, event, a, b, c, d, e, f, g, h, i, j, k) DTRACE_PROBE11(context, event, a, b, c, d, e, f, g, h, i, j, k)
24+
#define TRACE12(context, event, a, b, c, d, e, f, g, h, i, j, k, l) DTRACE_PROBE12(context, event, a, b, c, d, e, f, g, h, i, j, k, l)
25+
26+
#else
27+
28+
#define TRACE(context, event)
29+
#define TRACE1(context, event, a)
30+
#define TRACE2(context, event, a, b)
31+
#define TRACE3(context, event, a, b, c)
32+
#define TRACE4(context, event, a, b, c, d)
33+
#define TRACE5(context, event, a, b, c, d, e)
34+
#define TRACE6(context, event, a, b, c, d, e, f)
35+
#define TRACE7(context, event, a, b, c, d, e, f, g)
36+
#define TRACE8(context, event, a, b, c, d, e, f, g, h)
37+
#define TRACE9(context, event, a, b, c, d, e, f, g, h, i)
38+
#define TRACE10(context, event, a, b, c, d, e, f, g, h, i, j)
39+
#define TRACE11(context, event, a, b, c, d, e, f, g, h, i, j, k)
40+
#define TRACE12(context, event, a, b, c, d, e, f, g, h, i, j, k, l)
41+
42+
#endif
43+
44+
45+
#endif /* BITCOIN_UTIL_TRACE_H */

0 commit comments

Comments
 (0)