// Copyright (c) Advanced Micro Devices, Inc. // SPDX-License-Identifier: MIT #include "internal_libs.hpp" #include "binary/analysis.hpp" #include "binary/binary_info.hpp" #include "binary/link_map.hpp" #include "binary/scope_filter.hpp" #include "binary/symbol.hpp" #include "common/defines.h" #include "common/delimit.hpp" #include "common/env_vars.hpp" #include "common/environment.hpp" #include "common/path.hpp" #include "core/demangler.hpp" #include "core/utility.hpp" #include "fwd.hpp" #include "log.hpp" #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { namespace filepath = ::tim::filepath; using rocprofsys::get_env; using strview_init_t = std::initializer_list; using strview_set_t = std::set; using open_modes_vec_t = std::vector; auto& get_symtab_file_cache() { static auto _cache = std::unordered_map>{}; return _cache; } symtab_t* get_symtab_file(const std::string& _name) { auto& _cache = get_symtab_file_cache(); auto itr = _cache.find(_name); if(itr == _cache.end()) { symtab_t* _v = SymTab::Symtab::findOpenSymtab(_name); bool _closable = (_v == nullptr); if(!_v) SymTab::Symtab::openFile(_v, _name); TIMEMORY_PREFER(_v != nullptr) << "Warning! Dyninst could not open a Symtab instance for file '" << _name << "'\n"; _cache.emplace(_name, std::make_pair(_v, _closable)); } return _cache.at(_name).first; } bool close_symtab_file(const std::string& _name) { auto& _cache = get_symtab_file_cache(); auto itr = _cache.find(_name); if(itr != _cache.end()) { symtab_t* _symtab = itr->second.first; bool _closable = itr->second.second; if(_symtab && _closable) SymTab::Symtab::closeSymtab(_symtab); _cache.erase(itr); return true; } return false; } template