diff --git a/client/TracySysTrace.cpp b/client/TracySysTrace.cpp index e64d13a9..558dafa3 100644 --- a/client/TracySysTrace.cpp +++ b/client/TracySysTrace.cpp @@ -688,6 +688,21 @@ enum TraceEventId EventBranchMiss }; +static void ProbePreciseIp( perf_event_attr& pe ) +{ + pe.precise_ip = 3; + while( pe.precise_ip != 0 ) + { + const int fd = perf_event_open( &pe, -1, 0, -1, PERF_FLAG_FD_CLOEXEC ); + if( fd != -1 ) + { + close( fd ); + break; + } + pe.precise_ip--; + } +} + static void SetupSampling( int64_t& samplingPeriod ) { #ifndef CLOCK_MONOTONIC_RAW @@ -762,9 +777,9 @@ static void SetupSampling( int64_t& samplingPeriod ) pe.disabled = 1; pe.exclude_kernel = 1; pe.exclude_idle = 1; - pe.precise_ip = 2; if( !noRetirement ) { + ProbePreciseIp( pe ); for( int i=0; i