mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Add thread name getter combining local and external thread names.
This commit is contained in:
parent
f8e3d1ad0a
commit
3c092b4bec
@ -1849,6 +1849,37 @@ const char* Worker::GetThreadString( uint64_t id ) const
|
||||
}
|
||||
}
|
||||
|
||||
const char* Worker::GetThreadName( uint64_t id ) const
|
||||
{
|
||||
const auto it = m_data.threadNames.find( id );
|
||||
if( it == m_data.threadNames.end() )
|
||||
{
|
||||
const auto eit = m_data.externalNames.find( id );
|
||||
if( eit == m_data.externalNames.end() )
|
||||
{
|
||||
return "???";
|
||||
}
|
||||
else
|
||||
{
|
||||
return eit->second.second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Client should send additional information about thread name, to make this check unnecessary
|
||||
const auto txt = it->second;
|
||||
if( txt[0] >= '0' && txt[0] <= '9' && atoi( txt ) == id )
|
||||
{
|
||||
const auto eit = m_data.externalNames.find( id );
|
||||
if( eit != m_data.externalNames.end() )
|
||||
{
|
||||
return eit->second.second;
|
||||
}
|
||||
}
|
||||
return txt;
|
||||
}
|
||||
}
|
||||
|
||||
bool Worker::IsThreadLocal( uint64_t id ) const
|
||||
{
|
||||
return m_data.localThreadCompress.Exists( id );
|
||||
|
@ -337,6 +337,7 @@ public:
|
||||
const char* GetString( const StringRef& ref ) const;
|
||||
const char* GetString( const StringIdx& idx ) const;
|
||||
const char* GetThreadString( uint64_t id ) const;
|
||||
const char* GetThreadName( uint64_t id ) const;
|
||||
bool IsThreadLocal( uint64_t id ) const;
|
||||
const SourceLocation& GetSourceLocation( int16_t srcloc ) const;
|
||||
std::pair<const char*, const char*> GetExternalName( uint64_t id ) const;
|
||||
|
Loading…
Reference in New Issue
Block a user