From 6249999153a9497b32bc84e9dc95a1537a0af714 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Tue, 4 Apr 2023 15:20:46 -0400 Subject: [PATCH] linux: respect `TRACY_NO_SAMPLING` for sys-tracing This compile-time flag was being ignored on Linux. This change adds gating for software-sampled stack trace sampling following the same pattern as other `TRACY_NO_SAMPLE_*` options. If `TRACY_NO_SAMPLING=1` is provided as an environment variable, software stack sampling is also disabled. --- public/client/TracySysTrace.cpp | 44 ++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/public/client/TracySysTrace.cpp b/public/client/TracySysTrace.cpp index 4a562eaa..af0641fe 100644 --- a/public/client/TracySysTrace.cpp +++ b/public/client/TracySysTrace.cpp @@ -770,6 +770,13 @@ bool SysTraceStart( int64_t& samplingPeriod ) TracyDebug( "sched_wakeup id: %i\n", wakeupId ); TracyDebug( "drm_vblank_event id: %i\n", vsyncId ); +#ifdef TRACY_NO_SAMPLING + const bool noSoftwareSampling = true; +#else + const char* noSoftwareSamplingEnv = GetEnvVar( "TRACY_NO_SAMPLING" ); + const bool noSoftwareSampling = noSoftwareSamplingEnv && noSoftwareSamplingEnv[0] == '1'; +#endif + #ifdef TRACY_NO_SAMPLE_RETIREMENT const bool noRetirement = true; #else @@ -839,28 +846,31 @@ bool SysTraceStart( int64_t& samplingPeriod ) pe.clockid = CLOCK_MONOTONIC_RAW; #endif - TracyDebug( "Setup software sampling\n" ); - ProbePreciseIp( pe, currentPid ); - for( int i=0; i