diff --git a/CMakeLists.txt b/CMakeLists.txt index 6652104157c06..ed3178b269773 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,11 @@ tristate_option(CCACHE "Use ccache for compiling." "if ccache is found." AUTO) tristate_option(WITH_NATPMP "Enable NAT-PMP." "if libnatpmp is found." AUTO) tristate_option(WITH_MINIUPNPC "Enable UPnP." "if libminiupnpc is found." AUTO) tristate_option(WITH_ZMQ "Enable ZMQ notifications." "if libzmq is found." AUTO) +tristate_option(WITH_USDT + "Enable tracepoints for Userspace, Statically Defined Tracing." + "if sys/sdt.h is found." + AUTO +) if(CXX20) set(CMAKE_CXX_STANDARD 20) @@ -147,6 +152,7 @@ message("Optional packages:") message(" NAT-PMP ............................. ${WITH_NATPMP}") message(" UPnP ................................ ${WITH_MINIUPNPC}") message(" ZeroMQ .............................. ${WITH_ZMQ}") +message(" USDT tracing ........................ ${WITH_USDT}") message("") if(CMAKE_CROSSCOMPILING) set(cross_status "TRUE, for ${CMAKE_SYSTEM_NAME}, ${CMAKE_SYSTEM_PROCESSOR}") diff --git a/cmake/bitcoin-config.h.in b/cmake/bitcoin-config.h.in index 7a3cf24f440a5..ed70bb5e8f8c8 100644 --- a/cmake/bitcoin-config.h.in +++ b/cmake/bitcoin-config.h.in @@ -33,6 +33,10 @@ /* Copyright year */ #define COPYRIGHT_YEAR @COPYRIGHT_YEAR@ +/* Define to 1 to enable tracepoints for Userspace, Statically Defined Tracing + */ +#cmakedefine ENABLE_TRACING 1 + /* Define this symbol if you have __builtin_clzl */ #cmakedefine HAVE_BUILTIN_CLZL 1 diff --git a/cmake/optional.cmake b/cmake/optional.cmake index f7d49c07a5c87..0cb454af3b57d 100644 --- a/cmake/optional.cmake +++ b/cmake/optional.cmake @@ -85,3 +85,24 @@ if(WITH_ZMQ) message(FATAL_ERROR "libzmq requested, but not found.") endif() endif() + +include(CheckCXXSourceCompiles) +if(WITH_USDT) + check_cxx_source_compiles(" + #include + + int main() + { + DTRACE_PROBE(\"context\", \"event\"); + } + " HAVE_USDT_H + ) + if(HAVE_USDT_H) + set(ENABLE_TRACING TRUE) + set(WITH_USDT ON) + elseif(WITH_USDT STREQUAL "AUTO") + set(WITH_USDT OFF) + else() + message(FATAL_ERROR "sys/sdt.h requested, but not found.") + endif() +endif()