Decode PID and TID when generating imported thread names.

This commit is contained in:
Bartosz Taudul 2021-05-15 13:08:51 +02:00
parent 8ea02a4794
commit 7f1f929662
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3

View File

@ -435,14 +435,30 @@ Worker::Worker( const char* name, const char* program, const std::vector<ImportE
if( name != threadNames.end() ) if( name != threadNames.end() )
{ {
char buf[128]; char buf[128];
int len = snprintf( buf, sizeof( buf ), "(%" PRIu64 ") %s", t.first, name->second.c_str() ); int len;
if( t.first <= std::numeric_limits<uint32_t>::max() )
{
len = snprintf( buf, sizeof( buf ), "(%" PRIu64 ") %s", t.first, name->second.c_str() );
}
else
{
len = snprintf( buf, sizeof( buf ), "(PID %" PRIu64 " TID %" PRIu64 ") %s", t.first >> 32, t.first & 0xFFFFFFFF, name->second.c_str() );
}
AddThreadString( t.first, buf, len ); AddThreadString( t.first, buf, len );
} }
else else
{ {
char buf[64]; char buf[64];
sprintf( buf, "%" PRIu64, t.first ); int len;
AddThreadString( t.first, buf, strlen( buf ) ); if( t.first <= std::numeric_limits<uint32_t>::max() )
{
len = sprintf( buf, "%" PRIu64, t.first );
}
else
{
len = sprintf( buf, "PID %" PRIu64 " TID %" PRIu64, t.first >> 32, t.first & 0xFFFFFFFF );
}
AddThreadString( t.first, buf, len );
} }
} }