From 7f1f929662303601ab223265772a7ff3873871d2 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 15 May 2021 13:08:51 +0200 Subject: [PATCH] Decode PID and TID when generating imported thread names. --- server/TracyWorker.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 2b3ddfc3..e85fc694 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -435,14 +435,30 @@ Worker::Worker( const char* name, const char* program, const std::vectorsecond.c_str() ); + int len; + if( t.first <= std::numeric_limits::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 ); } else { char buf[64]; - sprintf( buf, "%" PRIu64, t.first ); - AddThreadString( t.first, buf, strlen( buf ) ); + int len; + if( t.first <= std::numeric_limits::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 ); } }