More utility extract.

This commit is contained in:
Bartosz Taudul 2022-07-02 14:14:27 +02:00
parent 701cc16cbf
commit b58a206d9d
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 38 additions and 38 deletions

View File

@ -5504,44 +5504,6 @@ int View::DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos,
return cnt;
}
const char* View::GetThreadContextData( uint64_t thread, bool& _local, bool& _untracked, const char*& program )
{
static char buf[256];
const auto local = m_worker.IsThreadLocal( thread );
auto txt = local ? m_worker.GetThreadName( thread ) : m_worker.GetExternalName( thread ).first;
auto label = txt;
bool untracked = false;
if( !local )
{
if( m_worker.GetPid() == 0 )
{
untracked = strcmp( txt, m_worker.GetCaptureProgram().c_str() ) == 0;
}
else
{
const auto pid = m_worker.GetPidFromTid( thread );
untracked = pid == m_worker.GetPid();
if( untracked )
{
label = txt = m_worker.GetExternalName( thread ).second;
}
else
{
const auto ttxt = m_worker.GetExternalName( thread ).second;
if( strcmp( ttxt, "???" ) != 0 && strcmp( ttxt, txt ) != 0 )
{
snprintf( buf, 256, "%s (%s)", txt, ttxt );
label = buf;
}
}
}
}
_local = local;
_untracked = untracked;
program = txt;
return label;
}
int View::DrawCpuData( int offset, double pxns, const ImVec2& wpos, bool hover, float yMin, float yMax )
{
auto cpuData = m_worker.GetCpuData();

View File

@ -805,4 +805,42 @@ const char* View::ShortenNamespace( const char* name ) const
}
}
const char* View::GetThreadContextData( uint64_t thread, bool& _local, bool& _untracked, const char*& program )
{
static char buf[256];
const auto local = m_worker.IsThreadLocal( thread );
auto txt = local ? m_worker.GetThreadName( thread ) : m_worker.GetExternalName( thread ).first;
auto label = txt;
bool untracked = false;
if( !local )
{
if( m_worker.GetPid() == 0 )
{
untracked = strcmp( txt, m_worker.GetCaptureProgram().c_str() ) == 0;
}
else
{
const auto pid = m_worker.GetPidFromTid( thread );
untracked = pid == m_worker.GetPid();
if( untracked )
{
label = txt = m_worker.GetExternalName( thread ).second;
}
else
{
const auto ttxt = m_worker.GetExternalName( thread ).second;
if( strcmp( ttxt, "???" ) != 0 && strcmp( ttxt, txt ) != 0 )
{
snprintf( buf, 256, "%s (%s)", txt, ttxt );
label = buf;
}
}
}
}
_local = local;
_untracked = untracked;
program = txt;
return label;
}
}