diff --git a/public/client/TracySysTrace.cpp b/public/client/TracySysTrace.cpp index 48910ef3..1407a3df 100644 --- a/public/client/TracySysTrace.cpp +++ b/public/client/TracySysTrace.cpp @@ -412,14 +412,27 @@ void SysTraceGetExternalName( uint64_t thread, const char*& threadName, const ch namespace tracy { -static std::atomic traceActive { false }; -static int s_numCpus = 0; -static int s_numBuffers = 0; -static int s_ctxBufferIdx = 0; -static bool s_ctxSwitchCallchain = false; +struct SysTraceState +{ + std::atomic traceActive { false }; + int numCpus = 0; + int numBuffers = 0; + int ctxBufferIdx = 0; + bool ctxSwitchCallchain = false; + RingBuffer* ring = nullptr; + int* redirectFd = nullptr; + int numRedirectFd = 0; +}; -static RingBuffer* s_ring = nullptr; +static SysTraceState s_state; +static void CloseRedirectFds() +{ + for( int i=0; i= KERNEL_VERSION( 4, 8, 0 ) @@ -1226,15 +1257,15 @@ bool SysTraceStart( int64_t& samplingPeriod ) } TracyDebug( "Setup context switch capture" ); - for( int i=0; i