mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-29 16:54:35 +00:00
Don't clear image cache on refresh.
This commit is contained in:
parent
7fc7935359
commit
5decb91cd0
@ -140,18 +140,24 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
tracy::FastVector<ImageEntry>* m_images;
|
tracy::FastVector<ImageEntry>* m_images;
|
||||||
|
bool m_updated;
|
||||||
|
|
||||||
static int Callback( struct dl_phdr_info* info, size_t size, void* data )
|
static int Callback( struct dl_phdr_info* info, size_t size, void* data )
|
||||||
{
|
{
|
||||||
ImageCache* cache = reinterpret_cast<ImageCache*>( data );
|
ImageCache* cache = reinterpret_cast<ImageCache*>( data );
|
||||||
|
|
||||||
ImageEntry* image = cache->m_images->push_next();
|
const auto startAddress = reinterpret_cast<void*>( info->dlpi_addr );
|
||||||
image->m_startAddress = reinterpret_cast<void*>( info->dlpi_addr );
|
if( cache->Contains( startAddress ) ) return 0;
|
||||||
|
|
||||||
const uint32_t headerCount = info->dlpi_phnum;
|
const uint32_t headerCount = info->dlpi_phnum;
|
||||||
assert( headerCount > 0);
|
assert( headerCount > 0);
|
||||||
image->m_endAddress = reinterpret_cast<void*>( info->dlpi_addr +
|
const auto endAddress = reinterpret_cast<void*>( info->dlpi_addr +
|
||||||
info->dlpi_phdr[info->dlpi_phnum - 1].p_vaddr + info->dlpi_phdr[info->dlpi_phnum - 1].p_memsz);
|
info->dlpi_phdr[info->dlpi_phnum - 1].p_vaddr + info->dlpi_phdr[info->dlpi_phnum - 1].p_memsz);
|
||||||
|
|
||||||
|
ImageEntry* image = cache->m_images->push_next();
|
||||||
|
image->m_startAddress = startAddress;
|
||||||
|
image->m_endAddress = endAddress;
|
||||||
|
|
||||||
const char* imageName = nullptr;
|
const char* imageName = nullptr;
|
||||||
// the base executable name isn't provided when iterating with dl_iterate_phdr, get it with dladdr()
|
// the base executable name isn't provided when iterating with dl_iterate_phdr, get it with dladdr()
|
||||||
if( info->dlpi_name && info->dlpi_name[0] != '\0' )
|
if( info->dlpi_name && info->dlpi_name[0] != '\0' )
|
||||||
@ -167,29 +173,38 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(imageName != nullptr)
|
if( imageName )
|
||||||
{
|
{
|
||||||
size_t sz = strlen( imageName ) + 1;
|
size_t sz = strlen( imageName ) + 1;
|
||||||
image->m_name = (char*)tracy_malloc( sz );
|
image->m_name = (char*)tracy_malloc( sz );
|
||||||
memcpy( (void*)image->m_name, imageName, sz );
|
memcpy( image->m_name, imageName, sz );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
image->m_name = nullptr;
|
image->m_name = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cache->m_updated = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Contains( void* startAddress ) const
|
||||||
|
{
|
||||||
|
return std::any_of( m_images->begin(), m_images->end(), [startAddress]( const ImageEntry& entry ) { return startAddress == entry.m_startAddress; } );
|
||||||
|
}
|
||||||
|
|
||||||
void Refresh()
|
void Refresh()
|
||||||
{
|
{
|
||||||
Clear();
|
m_updated = false;
|
||||||
|
|
||||||
dl_iterate_phdr( Callback, this );
|
dl_iterate_phdr( Callback, this );
|
||||||
|
|
||||||
|
if( m_updated )
|
||||||
|
{
|
||||||
std::sort( m_images->begin(), m_images->end(),
|
std::sort( m_images->begin(), m_images->end(),
|
||||||
[]( const ImageEntry& lhs, const ImageEntry& rhs ) { return lhs.m_startAddress > rhs.m_startAddress; } );
|
[]( const ImageEntry& lhs, const ImageEntry& rhs ) { return lhs.m_startAddress > rhs.m_startAddress; } );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ImageEntry* GetImageForAddressImpl( void* address ) const
|
const ImageEntry* GetImageForAddressImpl( void* address ) const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user