SDK: remove majority of exceptions (#176)
* SDK: remove majority of exceptions
- replace with ROCP_FATAL, ROCP_CI_LOG(WARNING), etc.
- improve logging of symbolic link
- add --readlink and --realpath (hidden options) to rocprofv3 to follow symlinks for preloaded libraries
* Add rocprofv3 --rocm-root argument
* Fix registration resolved_exists
* Fix rocprofv3_avail.py
* Update logging for rocprofiler_configure search
- relax failure conditions
* Misc clang-tidy fixes
* Fix merge
* Fix merge
---------
Co-authored-by: Jonathan R. Madsen <jonathanrmadsen@gmail.com>
Co-authored-by: Bhardwaj, Gopesh <Gopesh.Bhardwaj@amd.com>
[ROCm/rocprofiler-sdk commit: 470f347e50]
This commit is contained in:
@@ -24,6 +24,8 @@
|
||||
#include "lib/common/environment.hpp"
|
||||
#include "lib/common/units.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <atomic>
|
||||
#include <cerrno>
|
||||
@@ -71,9 +73,8 @@ ring_buffer::operator=(ring_buffer&& rhs) noexcept
|
||||
void
|
||||
ring_buffer::init(size_t _size)
|
||||
{
|
||||
if(m_init)
|
||||
throw std::runtime_error("rocprofiler::common::container::base::ring_buffer::init(size_t) "
|
||||
":: already initialized");
|
||||
ROCP_FATAL_IF(m_init)
|
||||
<< "rocprofiler::common::container::base::ring_buffer::init(size_t) :: already initialized";
|
||||
|
||||
m_init = true;
|
||||
|
||||
@@ -85,9 +86,10 @@ ring_buffer::init(size_t _size)
|
||||
if((_size % units::get_page_size()) > 0)
|
||||
{
|
||||
std::ostringstream _oss{};
|
||||
_oss << "Error! size is not a multiple of page size: " << _size << " % "
|
||||
<< units::get_page_size() << " = " << (_size % units::get_page_size());
|
||||
throw std::runtime_error(_oss.str());
|
||||
ROCP_FATAL << fmt::format("Error! size is not a multiple of page size: {} % {} = {}",
|
||||
_size,
|
||||
units::get_page_size(),
|
||||
(_size % units::get_page_size()));
|
||||
}
|
||||
|
||||
m_size = _size;
|
||||
@@ -101,7 +103,7 @@ ring_buffer::init(size_t _size)
|
||||
{
|
||||
destroy();
|
||||
auto _err = errno;
|
||||
throw std::runtime_error(strerror(_err));
|
||||
ROCP_FATAL << fmt::format("mmap failed with errno {} :: {}", _err, strerror(_err));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,10 +258,9 @@ ring_buffer::can_clear() const
|
||||
bool
|
||||
ring_buffer::clear()
|
||||
{
|
||||
if(!can_clear())
|
||||
throw std::runtime_error(
|
||||
"ring_buffer does not permit invoking clear() member function when the read "
|
||||
"pointer is non-zero because this introduces thread-safety issues");
|
||||
ROCP_CI_LOG_IF(WARNING, !can_clear())
|
||||
<< "ring_buffer does not permit invoking clear() member function when the read pointer is "
|
||||
"non-zero because this introduces thread-safety issues";
|
||||
|
||||
m_write_count.store(0, std::memory_order_release);
|
||||
return true;
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
|
||||
#include "lib/common/elf_utils.hpp"
|
||||
|
||||
#include <rocprofiler-sdk/cxx/utility.hpp>
|
||||
|
||||
#include <fmt/format.h>
|
||||
#include <elfio/elfio.hpp>
|
||||
|
||||
#include <sys/stat.h>
|
||||
@@ -47,22 +50,14 @@ namespace
|
||||
{
|
||||
const ELFIO::Elf_Xword PAGE_SIZE = sysconf(_SC_PAGESIZE);
|
||||
|
||||
template <typename Tp>
|
||||
std::string
|
||||
as_hex_string(Tp&& _v, size_t _w = 16)
|
||||
{
|
||||
auto _ss = std::stringstream{};
|
||||
_ss.fill('0');
|
||||
_ss << "0x" << std::hex << std::setw(_w) << std::forward<Tp>(_v);
|
||||
return _ss.str();
|
||||
}
|
||||
using ::rocprofiler::sdk::utility::as_hex;
|
||||
} // namespace
|
||||
|
||||
SymbolEntry::SymbolEntry(unsigned int _idx, const accessor_type& _accessor)
|
||||
: index{_idx}
|
||||
{
|
||||
if(!_accessor.get_symbol(index, name, value, size, bind, type, section_index, other))
|
||||
throw std::runtime_error("Error in ELFIO::symbol_section_accessor::get_symbol");
|
||||
ROCP_WARNING << "ELFIO::symbol_section_accessor::get_symbol failed of symbol " << _idx;
|
||||
}
|
||||
|
||||
DynamicEntry::DynamicEntry(unsigned int _idx, const accessor_type& _accessor)
|
||||
@@ -75,7 +70,7 @@ RelocationEntry::RelocationEntry(unsigned int _idx, const accessor_type& _access
|
||||
: index{_idx}
|
||||
{
|
||||
if(!_accessor.get_entry(_idx, offset, symbol, type, addend))
|
||||
throw std::runtime_error("Error in ELFIO::relocation_section_accessor::get_entry");
|
||||
ROCP_WARNING << "ELFIO::relocation_section_accessor::get_entry failed for symbol " << _idx;
|
||||
}
|
||||
|
||||
ElfInfo::ElfInfo(std::string _fname)
|
||||
@@ -111,24 +106,25 @@ read(const std::string& _inp)
|
||||
|
||||
ROCP_TRACE << "\nReading " << _inp;
|
||||
|
||||
if(!reader.load(_inp)) throw std::runtime_error("Could not load elf file " + _inp);
|
||||
if(!reader.load(_inp))
|
||||
ROCP_WARNING << fmt::format("ELF parsing for '{}' did not succeed", _inp);
|
||||
|
||||
if(reader.get_class() == ELFIO::ELFCLASS32)
|
||||
ROCP_TRACE << "ELF 32-bit";
|
||||
ROCP_TRACE << " - ELF 32-bit";
|
||||
else
|
||||
ROCP_TRACE << "ELF 64-bit";
|
||||
ROCP_TRACE << " - ELF 64-bit";
|
||||
|
||||
ROCP_TRACE << "ELF file encoding: "
|
||||
ROCP_TRACE << " - ELF file encoding: "
|
||||
<< ((reader.get_encoding() == ELFIO::ELFDATA2LSB) ? std::string_view{"Little endian"}
|
||||
: std::string_view{"Big endian"});
|
||||
|
||||
ROCP_TRACE << "ELF version: " << reader.get_elf_version();
|
||||
ROCP_TRACE << "ELF header size: " << reader.get_header_size();
|
||||
ROCP_TRACE << "ELF OS ABI: " << reader.get_os_abi();
|
||||
ROCP_TRACE << " - ELF version: " << reader.get_elf_version();
|
||||
ROCP_TRACE << " - ELF header size: " << reader.get_header_size();
|
||||
ROCP_TRACE << " - ELF OS ABI: " << reader.get_os_abi();
|
||||
|
||||
// Print ELF file sections info
|
||||
ELFIO::Elf_Half sec_num = reader.sections.size();
|
||||
ROCP_TRACE << "Number of sections: " << sec_num;
|
||||
ROCP_TRACE << " - Number of sections: " << sec_num;
|
||||
|
||||
for(ELFIO::Elf_Half j = 0; j < sec_num; ++j)
|
||||
{
|
||||
@@ -143,85 +139,85 @@ read(const std::string& _inp)
|
||||
for(ELFIO::Elf_Half j = 0; j < sec_num; ++j)
|
||||
{
|
||||
Section* psec = sections.at(j);
|
||||
ROCP_TRACE << " [" << j << "] \t" << std::setw(20) << psec->get_name() << "\t : \t"
|
||||
ROCP_TRACE << " [" << j << "] \t" << std::setw(20) << psec->get_name() << "\t : \t"
|
||||
<< "size / entry-size = " << std::setw(6) << psec->get_size() << " / "
|
||||
<< std::setw(3) << psec->get_entry_size()
|
||||
<< " | addr: " << as_hex_string(psec->get_address())
|
||||
<< " | offset: " << as_hex_string(psec->get_offset());
|
||||
<< " | addr: " << as_hex(psec->get_address(), 16)
|
||||
<< " | offset: " << as_hex(psec->get_offset(), 16);
|
||||
|
||||
if(psec->get_size() == 0) continue;
|
||||
|
||||
if(psec->get_type() == ELFIO::SHT_SYMTAB)
|
||||
{
|
||||
const ELFIO::symbol_section_accessor _symbols(reader, psec);
|
||||
ROCP_TRACE << " Number of symbol entries: " << _symbols.get_symbols_num();
|
||||
ROCP_TRACE << " - Number of symbol entries: " << _symbols.get_symbols_num();
|
||||
for(ELFIO::Elf_Xword k = 0; k < _symbols.get_symbols_num(); ++k)
|
||||
symbol_entries.emplace_back(k, _symbols);
|
||||
}
|
||||
else if(psec->get_type() == ELFIO::SHT_DYNSYM)
|
||||
{
|
||||
const ELFIO::symbol_section_accessor _symbols(reader, psec);
|
||||
ROCP_TRACE << " Number of dynamic symbol entries: " << _symbols.get_symbols_num();
|
||||
ROCP_TRACE << " - Number of dynamic symbol entries: " << _symbols.get_symbols_num();
|
||||
for(ELFIO::Elf_Xword k = 0; k < _symbols.get_symbols_num(); ++k)
|
||||
dynamic_symbol_entries.emplace_back(k, _symbols);
|
||||
}
|
||||
else if(psec->get_type() == ELFIO::SHT_DYNAMIC)
|
||||
{
|
||||
const ELFIO::dynamic_section_accessor dynamic{reader, psec};
|
||||
ROCP_TRACE << " Number of dynamic entries: " << dynamic.get_entries_num();
|
||||
ROCP_TRACE << " - Number of dynamic entries: " << dynamic.get_entries_num();
|
||||
for(ELFIO::Elf_Xword k = 0; k < dynamic.get_entries_num(); ++k)
|
||||
dynamic_entries.emplace_back(k, dynamic);
|
||||
}
|
||||
else if(psec->get_type() == ELFIO::SHT_REL || psec->get_type() == ELFIO::SHT_RELA)
|
||||
{
|
||||
const ELFIO::relocation_section_accessor reloc{reader, psec};
|
||||
ROCP_TRACE << " Number of relocation entries: " << reloc.get_entries_num();
|
||||
ROCP_TRACE << " - Number of relocation entries: " << reloc.get_entries_num();
|
||||
for(ELFIO::Elf_Xword k = 0; k < reloc.get_entries_num(); ++k)
|
||||
reloc_entries.emplace_back(k, reloc);
|
||||
}
|
||||
}
|
||||
|
||||
ROCP_TRACE << "Symbols:";
|
||||
ROCP_TRACE << " - Symbols:";
|
||||
for(size_t k = 0; k < symbol_entries.size(); ++k)
|
||||
{
|
||||
if(!symbol_entries.at(k).name.empty())
|
||||
ROCP_TRACE << " [" << k << "] " << symbol_entries.at(k).name;
|
||||
ROCP_TRACE << " [" << k << "] " << symbol_entries.at(k).name;
|
||||
}
|
||||
|
||||
ROCP_TRACE << "Dynamic Symbols:";
|
||||
ROCP_TRACE << " - Dynamic Symbols:";
|
||||
for(size_t k = 0; k < dynamic_symbol_entries.size(); ++k)
|
||||
{
|
||||
if(!dynamic_symbol_entries.at(k).name.empty())
|
||||
ROCP_TRACE << " [" << k << "] " << dynamic_symbol_entries.at(k).name;
|
||||
ROCP_TRACE << " [" << k << "] " << dynamic_symbol_entries.at(k).name;
|
||||
}
|
||||
|
||||
ROCP_TRACE << "Dynamic entries:";
|
||||
ROCP_TRACE << " - Dynamic entries:";
|
||||
for(size_t k = 0; k < dynamic_entries.size(); ++k)
|
||||
{
|
||||
if(!dynamic_entries.at(k).name.empty())
|
||||
ROCP_TRACE << " [" << k << "] " << dynamic_entries.at(k).name;
|
||||
ROCP_TRACE << " [" << k << "] " << dynamic_entries.at(k).name;
|
||||
}
|
||||
|
||||
ROCP_TRACE << "Relocation entries:";
|
||||
ROCP_TRACE << " - Relocation entries:";
|
||||
for(size_t k = 0; k < reloc_entries.size(); ++k)
|
||||
{
|
||||
auto _sym_idx = reloc_entries.at(k).symbol;
|
||||
auto _name = std::string{};
|
||||
if(_sym_idx < symbol_entries.size()) _name = symbol_entries.at(_sym_idx).name;
|
||||
if(!_name.empty()) ROCP_TRACE << " [" << k << "] " << _name;
|
||||
if(!_name.empty()) ROCP_TRACE << " [" << k << "] " << _name;
|
||||
}
|
||||
|
||||
// Print ELF file segments info
|
||||
ELFIO::Elf_Half seg_num = reader.segments.size();
|
||||
ROCP_TRACE << "Number of segments: " << seg_num;
|
||||
ROCP_TRACE << " - Number of segments: " << seg_num;
|
||||
for(ELFIO::Elf_Half j = 0; j < seg_num; ++j)
|
||||
{
|
||||
const ELFIO::segment* pseg = reader.segments[j];
|
||||
ROCP_TRACE << " [" << std::setw(2) << j << "] flags: " << as_hex_string(pseg->get_flags())
|
||||
<< " offset: " << as_hex_string(pseg->get_offset())
|
||||
<< " align: " << as_hex_string(pseg->get_align())
|
||||
<< " virt: " << as_hex_string(pseg->get_virtual_address())
|
||||
<< " phys: " << as_hex_string(pseg->get_physical_address())
|
||||
ROCP_TRACE << " [" << std::setw(2) << j << "] flags: " << as_hex(pseg->get_flags(), 16)
|
||||
<< " offset: " << as_hex(pseg->get_offset(), 16)
|
||||
<< " align: " << as_hex(pseg->get_align(), 16)
|
||||
<< " virt: " << as_hex(pseg->get_virtual_address(), 16)
|
||||
<< " phys: " << as_hex(pseg->get_physical_address(), 16)
|
||||
<< " fsize: " << std::setw(8) << pseg->get_file_size()
|
||||
<< " msize: " << std::setw(8) << pseg->get_memory_size();
|
||||
}
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
#include "lib/common/demangle.hpp"
|
||||
#include "lib/common/logging.hpp"
|
||||
|
||||
#include <fmt/format.h>
|
||||
|
||||
#include <cctype>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
@@ -62,8 +64,7 @@ get_env(std::string_view env_id, bool _default)
|
||||
{
|
||||
if(std::string_view{env_var}.empty())
|
||||
{
|
||||
throw std::runtime_error(std::string{"No boolean value provided for "} +
|
||||
std::string{env_id});
|
||||
ROCP_FATAL << fmt::format("No boolean value provided for {}", env_id);
|
||||
}
|
||||
|
||||
if(std::string_view{env_var}.find_first_not_of("0123456789") == std::string_view::npos)
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "lib/common/defines.hpp"
|
||||
#include "lib/common/logging.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -68,8 +69,7 @@ public:
|
||||
{
|
||||
if(!(m_addrs.empty() && m_blocks.empty()))
|
||||
{
|
||||
throw std::runtime_error{"cannot call pool::rebind() after alloc"};
|
||||
::abort();
|
||||
ROCP_FATAL << "cannot call pool::rebind() after alloc";
|
||||
}
|
||||
|
||||
m_size = size;
|
||||
|
||||
مرجع در شماره جدید
Block a user