Fix LD_PRELOAD (#184)
- __libc_start_main in libomnitrace-dl wasn't wrapping bc of -fvisibility=hidden
- fix OMNITRACE_STRIP_TARGET
- omnitrace_reset_preload function in main library
- defer removing libomnitrace from LD_PRELOAD
[ROCm/rocprofiler-systems commit: a41a5c155e]
This commit is contained in:
committed by
GitHub
parent
18128adfd3
commit
58c7c71af6
@@ -424,7 +424,7 @@ omnitrace_init_tooling_hidden()
|
||||
omnitrace_preinit_hidden();
|
||||
|
||||
// start these gotchas once settings have been initialized
|
||||
get_init_bundle()->start();
|
||||
if(get_init_bundle()) get_init_bundle()->start();
|
||||
|
||||
if(get_use_sampling()) sampling::block_signals();
|
||||
|
||||
@@ -564,6 +564,28 @@ omnitrace_init_hidden(const char* _mode, bool _is_binary_rewrite, const char* _a
|
||||
|
||||
//======================================================================================//
|
||||
|
||||
extern "C" void
|
||||
omnitrace_reset_preload_hidden(void)
|
||||
{
|
||||
tim::set_env("OMNITRACE_PRELOAD", "0", 1);
|
||||
auto&& _preload_libs = get_env("LD_PRELOAD", std::string{});
|
||||
if(_preload_libs.find("libomnitrace") != std::string::npos)
|
||||
{
|
||||
auto _modified_preload = std::string{};
|
||||
for(const auto& itr : delimit(_preload_libs, ":"))
|
||||
{
|
||||
if(itr.find("libomnitrace") != std::string::npos) continue;
|
||||
_modified_preload += common::join("", ":", itr);
|
||||
}
|
||||
if(!_modified_preload.empty() && _modified_preload.find(':') == 0)
|
||||
_modified_preload = _modified_preload.substr(1);
|
||||
|
||||
tim::set_env("LD_PRELOAD", _modified_preload, 1);
|
||||
}
|
||||
}
|
||||
|
||||
//======================================================================================//
|
||||
|
||||
extern "C" void
|
||||
omnitrace_finalize_hidden(void)
|
||||
{
|
||||
@@ -590,6 +612,8 @@ omnitrace_finalize_hidden(void)
|
||||
tim::signals::block_signals(get_sampling_signals(),
|
||||
tim::signals::sigmask_scope::process);
|
||||
|
||||
omnitrace_reset_preload_hidden();
|
||||
|
||||
// some functions called during finalization may alter the push/pop count so we need
|
||||
// to save them here
|
||||
auto _push_count = tracing::push_count().load();
|
||||
@@ -635,6 +659,13 @@ omnitrace_finalize_hidden(void)
|
||||
tim::signals::enable_signal_detection({ tim::signals::sys_signal::Interrupt },
|
||||
[](int) {});
|
||||
|
||||
std::string _bundle_name = OMNITRACE_FUNCTION;
|
||||
comp::user_global_bundle _bundle{ _bundle_name.c_str() };
|
||||
_bundle.clear();
|
||||
_bundle.insert<comp::wall_clock, comp::cpu_clock, comp::peak_rss, comp::page_rss,
|
||||
comp::cpu_util>();
|
||||
_bundle.start();
|
||||
|
||||
OMNITRACE_DEBUG_F("Copying over all timemory hash information to main thread...\n");
|
||||
// copy these over so that all hashes are known
|
||||
auto& _hzero = tracing::get_timemory_hash_ids(0);
|
||||
@@ -929,6 +960,18 @@ omnitrace_finalize_hidden(void)
|
||||
}
|
||||
}
|
||||
|
||||
_bundle.stop();
|
||||
auto _get_metric = [](auto* _v, std::string_view _tail) -> std::string {
|
||||
return (_v) ? JOIN("", *_v, _tail) : std::string{};
|
||||
};
|
||||
|
||||
OMNITRACE_VERBOSE_F(0, "Finalization metrics: %s%s%s%s%s\n",
|
||||
_get_metric(_bundle.get<comp::wall_clock>(), ", ").c_str(),
|
||||
_get_metric(_bundle.get<comp::peak_rss>(), ", ").c_str(),
|
||||
_get_metric(_bundle.get<comp::page_rss>(), ", ").c_str(),
|
||||
_get_metric(_bundle.get<comp::cpu_clock>(), ", ").c_str(),
|
||||
_get_metric(_bundle.get<comp::cpu_util>(), "").c_str());
|
||||
|
||||
if(_timemory_manager && _timemory_manager != nullptr)
|
||||
{
|
||||
_timemory_manager->add_metadata([](auto& ar) {
|
||||
|
||||
Reference in New Issue
Block a user