From ab8a33cdfae2df8e0264b09a11d00508c161f92a Mon Sep 17 00:00:00 2001 From: Simon Boorer Date: Wed, 18 Nov 2026 11:34:02 +0000 Subject: [PATCH] Return OS thread ids from the server bindings. get_samples_for_symbol, get_zone_occurrences_with_thread and get_messages returned the worker's compressed thread index where the other bindings (get_threads, get_thread_name, get_thread_zone_stats) take an OS thread id, and where get_zone_occurrences_with_thread documents one. get_zone_occurrences_with_thread also looked the index up by position in GetThreadData(), which isn't ordered by it, so zones were attributed to another thread. Decompress the index with Worker::DecompressThread, as get_thread_zone_stats and the profiler do. Co-Authored-By: Claude Opus 5.5 --- python/bindings/ServerModule.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/python/bindings/ServerModule.cpp b/python/bindings/ServerModule.cpp index 28b6168b..d82c380f 100644 --- a/python/bindings/ServerModule.cpp +++ b/python/bindings/ServerModule.cpp @@ -509,7 +509,6 @@ PYBIND11_MODULE( TracyServerBindings, m ) // Returns list of (start_ns, duration_ns, thread_id) — thread_id is the OS thread ID std::vector> result; #ifndef TRACY_NO_STATISTICS - const auto& threads = w.GetThreadData(); for( const auto& kv : w.GetSourceLocationZones() ) { if( std::string( w.GetZoneName( w.GetSourceLocation( kv.first ) ) ) != name ) continue; @@ -518,8 +517,7 @@ PYBIND11_MODULE( TracyServerBindings, m ) if( result.size() >= maxSamples ) goto done_occ_thread; const auto* z = ztd.Zone(); if( !z || !z->IsEndValid() ) continue; - const uint16_t tidx = ztd.Thread(); - const uint64_t tid = ( tidx < threads.size() && threads[tidx] ) ? threads[tidx]->id : 0; + const uint64_t tid = w.DecompressThread( ztd.Thread() ); result.emplace_back( z->Start(), z->End() - z->Start(), tid ); } } @@ -702,7 +700,7 @@ PYBIND11_MODULE( TracyServerBindings, m ) { py::dict d; d["time"] = s.time.Val(); - d["thread"] = (uint32_t)s.thread; + d["thread"] = w.DecompressThread( s.thread ); result.append( d ); } return result; @@ -1031,7 +1029,7 @@ PYBIND11_MODULE( TracyServerBindings, m ) msg.time, std::string( w.GetString( msg.ref ) ), msg.color, - (uint64_t)msg.thread } ); + w.DecompressThread( msg.thread ) } ); } return result; } ) )