Optional perfetto annotations (#206)

* Misc tweaks

- C API function print with warning colors
- split region/trace start/stop functions into regions.cpp file

* Config option for disabling perfetto annotations

* Missing checks in roctracer.cpp and sampling.cpp

* Verbose makefile in CI

* run-ci uses -VV

* Fix gcc-7 maybe-uninitialized warning

* Fix push/pop perfetto

- moving perfetto::EventContext was causing errors
This commit is contained in:
Jonathan R. Madsen
2022-11-16 09:48:15 -06:00
committed by GitHub
orang tua 2135f82ab8
melakukan 2f16e2ecb1
13 mengubah file dengan 464 tambahan dan 220 penghapusan
+59 -27
Melihat File
@@ -823,7 +823,13 @@ post_process_perfetto(int64_t _tid, const bundle_t* _init,
_init->get<backtrace_timestamp>()->get_timestamp(), _beg_ns);
tracing::push_perfetto_ts(category::sampling{}, "samples [omnitrace]", _beg_ns,
"begin_ns", _beg_ns);
[&](perfetto::EventContext ctx) {
if(config::get_perfetto_annotations())
{
tracing::add_perfetto_annotation(
ctx, "begin_ns", _beg_ns);
}
});
auto _as_hex = [](auto _v) { return JOIN("", "0x", std::hex, _v); };
@@ -855,13 +861,24 @@ post_process_perfetto(int64_t _tid, const bundle_t* _init,
tracing::push_perfetto_ts(
category::sampling{}, _name, _beg,
[&](perfetto::EventContext ctx) {
tracing::add_perfetto_annotation(ctx, "begin_ns", _beg);
tracing::add_perfetto_annotation(ctx, "lineinfo", _info);
tracing::add_perfetto_annotation(ctx, "inlined",
(_n++ > 0));
if(config::get_perfetto_annotations())
{
tracing::add_perfetto_annotation(ctx, "begin_ns",
_beg);
tracing::add_perfetto_annotation(ctx, "lineinfo",
_info);
tracing::add_perfetto_annotation(ctx, "inlined",
(_n++ > 0));
}
});
tracing::pop_perfetto_ts(
category::sampling{}, _name, _end,
[&](perfetto::EventContext ctx) {
if(config::get_perfetto_annotations())
{
tracing::add_perfetto_annotation(ctx, "end_ns", _end);
}
});
tracing::pop_perfetto_ts(category::sampling{}, _name, _end,
"end_ns", _end);
}
}
else
@@ -870,38 +887,53 @@ post_process_perfetto(int64_t _tid, const bundle_t* _init,
tracing::push_perfetto_ts(
category::sampling{}, _name, _beg,
[&](perfetto::EventContext ctx) {
tracing::add_perfetto_annotation(ctx, "begin_ns", _beg);
tracing::add_perfetto_annotation(ctx, "file", iitr.location);
tracing::add_perfetto_annotation(ctx, "pc",
_as_hex(iitr.address));
tracing::add_perfetto_annotation(ctx, "line_address",
_as_hex(iitr.line_address));
if(iitr.lineinfo)
if(config::get_perfetto_annotations())
{
auto _lines = iitr.lineinfo.lines;
std::reverse(_lines.begin(), _lines.end());
size_t _n = 0;
for(const auto& litr : _lines)
tracing::add_perfetto_annotation(ctx, "begin_ns", _beg);
tracing::add_perfetto_annotation(ctx, "file",
iitr.location);
tracing::add_perfetto_annotation(ctx, "pc",
_as_hex(iitr.address));
tracing::add_perfetto_annotation(
ctx, "line_address", _as_hex(iitr.line_address));
if(iitr.lineinfo)
{
auto _label = JOIN('-', "lineinfo", _n++);
tracing::add_perfetto_annotation(
ctx, _label.c_str(),
JOIN('@', demangle(litr.name),
JOIN(':', litr.location, litr.line)));
auto _lines = iitr.lineinfo.lines;
std::reverse(_lines.begin(), _lines.end());
size_t _n = 0;
for(const auto& litr : _lines)
{
auto _label = JOIN('-', "lineinfo", _n++);
tracing::add_perfetto_annotation(
ctx, _label.c_str(),
JOIN('@', demangle(litr.name),
JOIN(':', litr.location, litr.line)));
}
}
}
});
tracing::pop_perfetto_ts(category::sampling{}, _name, _end, "end_ns",
_end);
tracing::pop_perfetto_ts(category::sampling{}, _name, _end,
[&](perfetto::EventContext ctx) {
if(config::get_perfetto_annotations())
{
tracing::add_perfetto_annotation(
ctx, "end_ns", _end);
}
});
}
}
_last_ts = _bt_ts->get_timestamp();
}
tracing::pop_perfetto_ts(category::sampling{}, "samples [omnitrace]", _end_ns,
"end_ns", _end_ns);
[&](perfetto::EventContext ctx) {
if(config::get_perfetto_annotations())
{
tracing::add_perfetto_annotation(ctx, "end_ns",
_end_ns);
}
});
};
auto _processing_thread = threading::get_tid();