Support for libbfd (binary file descriptor) (#168)

- provides addr2line information for sampling

[ROCm/rocprofiler-systems commit: 2ed818449f]
This commit is contained in:
Jonathan R. Madsen
2022-09-28 00:18:05 -05:00
committed by GitHub
parent 6ec1c639bd
commit 6c8570f610
7 changed files with 52 additions and 12 deletions
@@ -32,6 +32,7 @@ target_link_libraries(
$<BUILD_INTERFACE:omnitrace::omnitrace-compile-definitions>
$<BUILD_INTERFACE:omnitrace::omnitrace-perfetto>
$<BUILD_INTERFACE:omnitrace::omnitrace-timemory>
$<BUILD_INTERFACE:omnitrace::omnitrace-bfd>
$<BUILD_INTERFACE:omnitrace::omnitrace-mpi>
$<BUILD_INTERFACE:omnitrace::omnitrace-ptl>
$<BUILD_INTERFACE:omnitrace::omnitrace-hip>
@@ -109,7 +109,7 @@ backtrace::description()
return "Records backtrace data";
}
std::vector<std::string>
std::vector<backtrace::entry_type>
backtrace::filter_and_patch(const std::vector<entry_type>& _data)
{
// check whether the call-stack entry should be used. -1 means break, 0 means continue
@@ -143,14 +143,16 @@ backtrace::filter_and_patch(const std::vector<entry_type>& _data)
return std::string{ _lbl }.replace(_pos, _dyninst.length(), "");
};
auto _ret = std::vector<std::string>{};
auto _ret = std::vector<entry_type>{};
for(const auto& itr : _data)
{
auto _name = tim::demangle(_patch_label(itr.name));
auto _use = _use_label(_name);
if(_use == -1) break;
if(_use == 0) continue;
_ret.emplace_back(_name);
auto _v = itr;
_v.name = _name;
_ret.emplace_back(_v);
}
return _ret;
@@ -70,7 +70,7 @@ struct backtrace
backtrace& operator=(const backtrace&) = default;
backtrace& operator=(backtrace&&) noexcept = default;
static std::vector<std::string> filter_and_patch(const std::vector<entry_type>&);
static std::vector<entry_type> filter_and_patch(const std::vector<entry_type>&);
static void start();
static void stop();
@@ -606,6 +606,8 @@ post_process_perfetto(int64_t _tid, const bundle_t* _init,
tracing::push_perfetto_ts(category::sampling{}, "samples [omnitrace]", _beg_ns,
"begin_ns", _beg_ns);
auto _as_hex = [](auto _v) { return JOIN("", "0x", std::hex, _v); };
for(const auto& itr : _data)
{
const auto* _bt_ts = itr->get<backtrace_timestamp>();
@@ -617,13 +619,32 @@ post_process_perfetto(int64_t _tid, const bundle_t* _init,
static std::set<std::string> _static_strings{};
for(const auto& itr : backtrace::filter_and_patch(_bt_cs->get()))
{
const auto* _name = _static_strings.emplace(itr).first->c_str();
const auto* _name = _static_strings.emplace(itr.name).first->c_str();
uint64_t _beg = _last_ts;
uint64_t _end = _bt_ts->get_timestamp();
if(!_thread_info->is_valid_lifetime({ _beg, _end })) continue;
tracing::push_perfetto_ts(category::sampling{}, _name, _beg, "begin_ns",
_beg);
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", itr.location);
tracing::add_perfetto_annotation(ctx, "pc", _as_hex(itr.address));
tracing::add_perfetto_annotation(ctx, "line_address",
_as_hex(itr.line_address));
if(itr.lineinfo)
{
size_t _n = 0;
for(const auto& litr : itr.lineinfo.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);
}
@@ -687,7 +708,7 @@ post_process_timemory(int64_t _tid, const bundle_t* _init,
// generate the instances of the tuple of components and start them
for(const auto& itr : backtrace::filter_and_patch(_bt_data->get()))
{
_tc.emplace_back(tim::string_view_t{ itr });
_tc.emplace_back(tim::string_view_t{ itr.name });
_tc.back().push(_bt_time->get_tid());
_tc.back().start();
}
@@ -761,7 +782,7 @@ post_process_timemory(int64_t _tid, const bundle_t* _init,
// generate the instances of the tuple of components and start them
for(const auto& itr : backtrace::filter_and_patch(_bt_data->get()))
{
_tc.emplace_back(tim::string_view_t{ itr });
_tc.emplace_back(tim::string_view_t{ itr.name });
_tc.back().push(_bt_time->get_tid());
_tc.back().start();
}