Add offset-less GetSymbolForAddress().

This commit is contained in:
Bartosz Taudul 2020-04-08 16:55:49 +02:00
parent a34cfacb5c
commit 02e1a7669c
3 changed files with 12 additions and 8 deletions

View File

@ -239,8 +239,7 @@ bool View::ViewDispatch( const char* fileName, int line, uint64_t symAddr )
if( sit != symMap.end() ) symlen = sit->second.size.Val();
if( symlen == 0 )
{
uint32_t offset;
const auto parentAddr = m_worker.GetSymbolForAddress( symAddr, offset );
const auto parentAddr = m_worker.GetSymbolForAddress( symAddr );
if( parentAddr != 0 )
{
auto pit = symMap.find( parentAddr );
@ -11301,8 +11300,7 @@ void View::DrawStatistics()
bool pass = m_statisticsFilter.PassFilter( name );
if( !pass && v.second.size.Val() == 0 )
{
uint32_t offset;
const auto parentAddr = m_worker.GetSymbolForAddress( v.first, offset );
const auto parentAddr = m_worker.GetSymbolForAddress( v.first );
if( parentAddr != 0 )
{
auto pit = symMap.find( parentAddr );
@ -11357,8 +11355,7 @@ void View::DrawStatistics()
bool pass = m_statisticsFilter.PassFilter( name );
if( !pass && sit->second.size.Val() == 0 )
{
uint32_t offset;
const auto parentAddr = m_worker.GetSymbolForAddress( v.first, offset );
const auto parentAddr = m_worker.GetSymbolForAddress( v.first );
if( parentAddr != 0 )
{
auto pit = symMap.find( parentAddr );
@ -11484,8 +11481,7 @@ void View::DrawStatistics()
const char* parentName = nullptr;
if( symlen == 0 )
{
uint32_t offset;
const auto parentAddr = m_worker.GetSymbolForAddress( v.symAddr, offset );
const auto parentAddr = m_worker.GetSymbolForAddress( v.symAddr );
if( parentAddr != 0 )
{
auto pit = symMap.find( parentAddr );

View File

@ -2397,6 +2397,13 @@ const char* Worker::GetSymbolCode( uint64_t sym, uint32_t& len ) const
return it->second.data;
}
uint64_t Worker::GetSymbolForAddress( uint64_t address ) const
{
auto it = std::lower_bound( m_data.symbolLoc.begin(), m_data.symbolLoc.end(), address, [] ( const auto& l, const auto& r ) { return l.addr + l.len < r; } );
if( it == m_data.symbolLoc.end() || address < it->addr ) return 0;
return it->addr;
}
uint64_t Worker::GetSymbolForAddress( uint64_t address, uint32_t& offset ) const
{
auto it = std::lower_bound( m_data.symbolLoc.begin(), m_data.symbolLoc.end(), address, [] ( const auto& l, const auto& r ) { return l.addr + l.len < r; } );

View File

@ -438,6 +438,7 @@ public:
uint64_t GetCanonicalPointer( const CallstackFrameId& id ) const;
const SymbolData* GetSymbolData( uint64_t sym ) const;
const char* GetSymbolCode( uint64_t sym, uint32_t& len ) const;
uint64_t GetSymbolForAddress( uint64_t address ) const;
uint64_t GetSymbolForAddress( uint64_t address, uint32_t& offset ) const;
StringIdx GetLocationForAddress( uint64_t address, uint32_t& line ) const;
const Vector<uint64_t>* GetAddressesForLocation( uint32_t fileStringIdx, uint32_t line ) const;