Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
Trace.hpp
Go to the documentation of this file.
1// The Reactive C++ Toolbox.
2// Copyright (C) 2021 Reactive Markets Limited
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef TOOLBOX_SYS_TRACE_HPP
17#define TOOLBOX_SYS_TRACE_HPP
18
20
21#include <toolbox/Config.h> // TOOLBOX_HAVE_SYSTEMTAP
22
23#if TOOLBOX_HAVE_SYSTEMTAP
24#ifndef SDT_USE_VARIADIC
25#define SDT_USE_VARIADIC
26#endif
27#include <sys/sdt.h>
28#define TOOLBOX_PROBE(provider, name, ...) STAP_PROBEV(provider, name, ##__VA_ARGS__)
29// clang-format off
30#if defined(__GNUC__) && !defined(__clang__)
31#define TOOLBOX_PROBE_SCOPED(provider, name, ...) \
32 STAP_PROBEV(provider, name ## _begin); \
33 const auto __finally_ ## provider ## _ ## name = toolbox::util::make_finally([&]() noexcept __attribute__((noinline)) { \
34 STAP_PROBEV(provider, name ## _end, ##__VA_ARGS__); \
35 })
36#elif defined(__clang__)
37#define TOOLBOX_PROBE_SCOPED(provider, name, ...) \
38 STAP_PROBEV(provider, name ## _begin); \
39 const auto __finally_ ## provider ## _ ## name = toolbox::util::make_finally([&]() __attribute__((noinline)) noexcept { \
40 STAP_PROBEV(provider, name ## _end, ##__VA_ARGS__); \
41 })
42#endif
43// clang-format on
44#else
45#define TOOLBOX_PROBE(provider, name, ...)
46#define TOOLBOX_PROBE_SCOPED(provider, name, ...)
47#endif
48
49#endif // TOOLBOX_SYS_TRACE_HPP