19#if defined(PULP_TRACING_ENABLED) && PULP_TRACING_ENABLED
27#if defined(PULP_TRACING_ENABLED) && PULP_TRACING_ENABLED
37PERFETTO_DEFINE_CATEGORIES(
38 perfetto::Category(
"dsp").SetDescription(
"Offline DSP block timing"),
39 perfetto::Category(
"dsp.node").SetDescription(
"Offline per-node DSP timing"),
40 perfetto::Category(
"render").SetDescription(
"Frame render pipeline"),
41 perfetto::Category(
"layout").SetDescription(
"Yoga layout passes"),
42 perfetto::Category(
"canvas").SetDescription(
"Canvas 2D drawing"),
43 perfetto::Category(
"text").SetDescription(
"Text shaping (prepare vs layout)"),
44 perfetto::Category(
"js").SetDescription(
"QuickJS bridge dispatch"),
45 perfetto::Category(
"gpu").SetDescription(
"Dawn/Graphite GPU passes"),
46 perfetto::Category(
"state").SetDescription(
"Parameter/state changes"),
47 perfetto::Category(
"io").SetDescription(
"File / network I/O"),
48 perfetto::Category(
"lifecycle")
49 .SetDescription(
"Plug-in instantiation, activation and editor open (host threads only)"));
51namespace pulp::runtime::trace_detail {
62#define PULP_TRACE_WRAP_CT_STRING(x) [] { return (x); }
63#define PULP_TRACE_UNWRAP_CT_STRING(x) (x)()
65template <
typename WrappedString>
66constexpr auto prettify_function(WrappedString wrapped) {
67 constexpr auto src = PULP_TRACE_UNWRAP_CT_STRING(wrapped);
68 constexpr auto size = std::string_view(src).size();
69 std::array<char, size> result{};
71 for (
size_t i = 0; i < size; ++i) {
76 if (src[i + 1] ==
'_') i += 8;
81 while ((src[i] !=
'(' && src[i] !=
'<') && i < size && j < size) {
87 if (src[i] ==
'<') result[
j - 2] =
'\0';
96namespace prettify_test {
97template <
size_t N,
size_t M>
98constexpr bool eq(
const std::array<char, N>& r,
const char (&t)[M]) {
100 static_assert(N + 1 >= M);
101 return std::string_view(t, M) == std::string_view(
r.data(), M);
103static_assert(eq(prettify_function(PULP_TRACE_WRAP_CT_STRING(
"int main")),
"main"));
104static_assert(eq(prettify_function(PULP_TRACE_WRAP_CT_STRING(
105 "void Foo::bar(int, float)::(anonymous class)::operator()()")),
115#define PULP_TRACE_SCOPE(category) \
116 static constexpr auto _pulp_tr_pf = \
117 ::pulp::runtime::trace_detail::prettify_function( \
118 PULP_TRACE_WRAP_CT_STRING(PERFETTO_DEBUG_FUNCTION_IDENTIFIER())); \
119 TRACE_EVENT(category, ::perfetto::StaticString(_pulp_tr_pf.data()))
121#define PULP_TRACE_SCOPE_NAMED(category, name) \
122 TRACE_EVENT(category, ::perfetto::StaticString(name))
134#define PULP_TRACE_SCOPE_DYNAMIC(category, name_expr) \
135 TRACE_EVENT(category, ::perfetto::DynamicString{name_expr})
143#define PULP_TRACE_SCOPE_NAMED_ARGS(category, name, ...) \
144 TRACE_EVENT(category, ::perfetto::StaticString(name), __VA_ARGS__)
146#define PULP_TRACE_BEGIN(category, name) \
147 TRACE_EVENT_BEGIN(category, ::perfetto::StaticString(name))
152#define PULP_TRACE_BEGIN_ARGS(category, name, ...) \
153 TRACE_EVENT_BEGIN(category, ::perfetto::StaticString(name), __VA_ARGS__)
160#define PULP_TRACE_BEGIN_DYNAMIC(category, name_expr) \
161 TRACE_EVENT_BEGIN(category, ::perfetto::DynamicString{name_expr})
163#define PULP_TRACE_END(category) TRACE_EVENT_END(category)
169#define PULP_TRACE_INSTANT(category, name) \
170 TRACE_EVENT_INSTANT(category, ::perfetto::StaticString(name))
178#define PULP_TRACE_INSTANT_ARGS(category, name, ...) \
179 TRACE_EVENT_INSTANT(category, ::perfetto::StaticString(name), __VA_ARGS__)
185#define PULP_TRACE_INSTANT_DYNAMIC(category, name_expr) \
186 TRACE_EVENT_INSTANT(category, ::perfetto::DynamicString{name_expr})
188#define PULP_TRACE_COUNTER(category, name, value) \
189 TRACE_COUNTER(category, ::perfetto::StaticString(name), (value))
195#define PULP_TRACE_SCOPE(category) ((void)0)
196#define PULP_TRACE_SCOPE_NAMED(category, name) ((void)0)
197#define PULP_TRACE_SCOPE_DYNAMIC(category, name_expr) ((void)0)
198#define PULP_TRACE_SCOPE_NAMED_ARGS(category, name, ...) ((void)0)
199#define PULP_TRACE_BEGIN(category, name) ((void)0)
200#define PULP_TRACE_BEGIN_ARGS(category, name, ...) ((void)0)
201#define PULP_TRACE_BEGIN_DYNAMIC(category, name_expr) ((void)0)
202#define PULP_TRACE_END(category) ((void)0)
203#define PULP_TRACE_INSTANT(category, name) ((void)0)
204#define PULP_TRACE_INSTANT_ARGS(category, name, ...) ((void)0)
205#define PULP_TRACE_INSTANT_DYNAMIC(category, name_expr) ((void)0)
206#define PULP_TRACE_COUNTER(category, name, value) ((void)0)
Definition generated_event_source.hpp:33
constexpr bool kTracingEnabled
True only in a PULP_TRACING=ON build. Every shipping/default build is false.
Definition trace.hpp:22
@ j
Definition input_events.hpp:40
@ r
Definition input_events.hpp:41