1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Imported Chrome traces bring over thread names

This commit is contained in:
joshuakr
2021-01-21 17:07:31 -08:00
parent 25a95d99c0
commit 2920f97911
3 changed files with 25 additions and 6 deletions
+14 -4
View File
@@ -275,7 +275,7 @@ Worker::Worker( const char* addr, uint16_t port )
m_threadNet = std::thread( [this] { SetThreadName( "Tracy Network" ); Network(); } );
}
Worker::Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots )
Worker::Worker( const std::string& program, const std::vector<ImportEventTimeline>& timeline, const std::vector<ImportEventMessages>& messages, const std::vector<ImportEventPlots>& plots, const std::unordered_map<uint64_t, std::string>& threadNames )
: m_hasData( true )
, m_delay( 0 )
, m_resolution( 0 )
@@ -428,9 +428,19 @@ Worker::Worker( const std::string& program, const std::vector<ImportEventTimelin
for( auto& t : m_threadMap )
{
char buf[64];
sprintf( buf, "%" PRIu64, t.first );
AddThreadString( t.first, buf, strlen( buf ) );
auto name = threadNames.find(t.first);
if (name != threadNames.end())
{
char buf[128];
int len = snprintf(buf, sizeof(buf), "(%" PRIu64 ") %s", t.first, name->second.c_str());
AddThreadString(t.first, buf, len);
}
else
{
char buf[64];
sprintf( buf, "%" PRIu64, t.first );
AddThreadString( t.first, buf, strlen( buf ) );
}
}
m_data.framesBase = m_data.frames.Retrieve( 0, [this] ( uint64_t name ) {