Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2020-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_UTIL_TRACE_H6#define BITCOIN_UTIL_TRACE_H8#include <bitcoin-build-config.h> // IWYU pragma: keep10#ifdef ENABLE_TRACING12// Workaround for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10339513// systemtap 4.6 on 32-bit ARM triggers internal compiler error14// (this workaround is included in systemtap 4.7+)15#if defined(__arm__)16# define STAP_SDT_ARG_CONSTRAINT g17#endif19// Setting SDT_USE_VARIADIC lets systemtap (sys/sdt.h) know that we want to use20// the optional variadic macros to define tracepoints.21#define SDT_USE_VARIADIC 123// Setting _SDT_HAS_SEMAPHORES let's systemtap (sys/sdt.h) know that we want to24// use the optional semaphore feature for our tracepoints. This feature allows25// us to check if something is attached to a tracepoint. We only want to prepare26// some potentially expensive tracepoint arguments, if the tracepoint is being27// used. Here, an expensive argument preparation could, for example, be28// calculating a hash or serialization of a data structure.29#define _SDT_HAS_SEMAPHORES 131// Used to define a counting semaphore for a tracepoint. This semaphore is32// automatically incremented by tracing frameworks (bpftrace, bcc, libbpf, ...)33// upon attaching to the tracepoint and decremented when detaching. This needs34// to be a global variable. It's placed in the '.probes' ELF section.35#define TRACEPOINT_SEMAPHORE(context, event) \36unsigned short context##_##event##_semaphore __attribute__((section(".probes")))38#include <sys/sdt.h>40// Returns true if something is attached to the tracepoint.41#define TRACEPOINT_ACTIVE(context, event) (context##_##event##_semaphore > 0)43// A USDT tracepoint with one to twelve arguments. It's checked that the44// tracepoint is active before preparing its arguments.45#define TRACEPOINT(context, event, ...) \46do { \47if (TRACEPOINT_ACTIVE(context, event)) { \48STAP_PROBEV(context, event __VA_OPT__(, ) __VA_ARGS__); \49} \50} while(0)52#else54#define TRACEPOINT_SEMAPHORE(context, event)55#define TRACEPOINT_ACTIVE(context, event) false56#define TRACEPOINT(context, ...)58#endif // ENABLE_TRACING61#endif // BITCOIN_UTIL_TRACE_H