diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b4c0e27e154c..46abb1c565e08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,6 +47,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) @@ -144,6 +149,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 0aa01d921fb0a..0053fb451b356 100644 --- a/cmake/optional.cmake +++ b/cmake/optional.cmake @@ -83,3 +83,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()