[rocprofiler-systems] Add cached demangler and replace old demangle (#2135)

* Add cached demangler and replace old

* Add unit tests

* Applied suggestions from code review

* Applied suggestions from code review
This commit is contained in:
Milan Radosavljevic
2025-12-16 08:32:18 +01:00
committed by GitHub
vanhempi 21afa807a9
commit 666e76deac
27 muutettua tiedostoa jossa 450 lisäystä ja 84 poistoa
@@ -22,6 +22,7 @@
#pragma once
#include "core/demangler.hpp"
#include "defines.hpp"
#include <timemory/settings/macros.hpp>
@@ -273,7 +274,7 @@ TIMEMORY_CEREAL_SAVE_FUNCTION_NAME(SettingsTextArchive& ar, const NameValuePair<
}
else
{
ar.setNextType(tim::demangle<T>().c_str());
ar.setNextType(rocprofsys::utility::demangle<T>().c_str());
}
ar(t.value);
}
@@ -45,7 +45,6 @@
namespace regex_const = ::std::regex_constants; // NOLINT
namespace comp = ::tim::component; // NOLINT
using settings = ::tim::settings; // NOLINT
using tim::demangle; // NOLINT
using tim::type_list; // NOLINT
//--------------------------------------------------------------------------------------//
@@ -23,6 +23,7 @@
#pragma once
#include "common.hpp"
#include "core/demangler.hpp"
#include "defines.hpp"
#include <timemory/components/types.hpp>
@@ -51,7 +52,7 @@ struct component_categories
(void) _cleanup; // unused but set if sizeof...(Tp) == 0
TIMEMORY_FOLD_EXPRESSION(_v.emplace(TIMEMORY_JOIN(
"::", "component", _cleanup(tim::try_demangle<Tp>(), "tim::"))));
"::", "component", _cleanup(rocprofsys::utility::demangle<Tp>(), "tim::"))));
}
void operator()(std::set<std::string>& _v) const
@@ -23,6 +23,7 @@
#pragma once
#include "common.hpp"
#include "core/demangler.hpp"
#include <timemory/utility/demangle.hpp>
#include <timemory/utility/type_list.hpp>
@@ -43,7 +44,7 @@ get_categories(type_list<Tp...>)
};
(void) _cleanup; // unused but set if sizeof...(Tp) == 0
auto _vec = str_vec_t{ _cleanup(demangle<Tp>(), "tim::")... };
auto _vec = str_vec_t{ _cleanup(rocprofsys::utility::demangle<Tp>(), "tim::")... };
std::sort(_vec.begin(), _vec.end(), [](const auto& lhs, const auto& rhs) {
// prioritize project category
auto lpos = lhs.find("project::");
@@ -29,6 +29,8 @@
#include <timemory/components/timing/wall_clock.hpp>
#include <timemory/utility/join.hpp>
#include "core/demangler.hpp"
#include <algorithm>
#include <link.h>
#include <linux/limits.h>
@@ -893,7 +895,8 @@ process_modules(const std::vector<module_t*>& _app_modules)
for(auto* fitr : symtab_data.functions.at(itr))
{
symtab_data.typed_func_names[tim::demangle(fitr->getName())] = fitr;
symtab_data.typed_func_names[rocprofsys::utility::demangle(fitr->getName())] =
fitr;
symtab_data.symbols.emplace(fitr, std::vector<symtab_symbol_t*>{});
if(!fitr->getSymbols(symtab_data.symbols.at(fitr))) continue;
@@ -906,7 +909,6 @@ process_modules(const std::vector<module_t*>& _app_modules)
}
}
}
_pr.stop();
_wc.stop();
verbprintf(0, "Processing %zu modules... Done (%.3f %s, %.3f %s)\n",
@@ -22,6 +22,8 @@
#include "function_signature.hpp"
#include "core/demangler.hpp"
function_signature::function_signature(std::string_view _ret, std::string_view _name,
std::string_view _file, location_t _row,
location_t _col, bool _loop, bool _info_beg,
@@ -32,7 +34,7 @@ function_signature::function_signature(std::string_view _ret, std::string_view _
, m_row(std::move(_row))
, m_col(std::move(_col))
, m_return(_ret)
, m_name(tim::demangle(_name.data()))
, m_name(rocprofsys::utility::demangle(_name.data()))
, m_file(_file)
{
if(m_file.find('/') != std::string_view::npos)
@@ -27,6 +27,7 @@
#include "binary/scope_filter.hpp"
#include "binary/symbol.hpp"
#include "common/defines.h"
#include "core/demangler.hpp"
#include "core/utility.hpp"
#include "fwd.hpp"
#include "log.hpp"
@@ -491,7 +492,7 @@ get_internal_libs_data_impl()
for(const auto& fitr : _funcs)
{
auto _fname = fitr->getName();
auto _dname = tim::demangle(_fname);
auto _dname = rocprofsys::utility::demangle(_fname);
_data[itr.first][_mpath].emplace(_fname);
_data[itr.first][_mpath].emplace(_dname);
@@ -24,6 +24,7 @@
#include "common/defines.h"
#include "common/join.hpp"
#include "common/path.hpp"
#include "core/demangler.hpp"
#include "dl/dl.hpp"
#include "fwd.hpp"
#include "internal_libs.hpp"
@@ -1451,8 +1452,8 @@ main(int argc, char** argv)
dynamic_cast<process_t*>(addr_space) != nullptr)
{
errprintf(-1, "address space statisfied dynamic_cast<%s> and dynamic_cast<%s>.\n",
tim::demangle<binary_edit_t*>().c_str(),
tim::demangle<process_t*>().c_str());
rocprofsys::utility::demangle<binary_edit_t*>().c_str(),
rocprofsys::utility::demangle<process_t*>().c_str());
}
auto _rewrite = (dynamic_cast<binary_edit_t*>(addr_space) != nullptr &&