Add TRACY_DISALLOW_HW_TIMER for VMs / WSL2

This commit is contained in:
Clément Grégoire
2026-02-02 16:10:36 +01:00
parent 79cb60025d
commit b27561c21e
5 changed files with 12 additions and 1 deletions

View File

@@ -137,6 +137,7 @@ set_option(TRACY_MANUAL_LIFETIME "Enable the manual lifetime management of the p
set_option(TRACY_FIBERS "Enable fibers support" OFF)
set_option(TRACY_NO_CRASH_HANDLER "Disable crash handling" OFF)
set_option(TRACY_TIMER_FALLBACK "Use lower resolution timers" OFF)
set_option(TRACY_DISALLOW_HW_TIMER "Disallow hardware timer (may be useful on VMs). Requires TRACY_TIMER_FALLBACK=ON" OFF)
set_option(TRACY_LIBUNWIND_BACKTRACE "Use libunwind backtracing where supported" OFF)
set_option(TRACY_SYMBOL_OFFLINE_RESOLVE "Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution" OFF)
set_option(TRACY_LIBBACKTRACE_ELF_DYNLOAD_SUPPORT "Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation" OFF)

View File

@@ -93,6 +93,11 @@ if get_option('timer_fallback')
tracy_common_args += ['-DTRACY_TIMER_FALLBACK']
endif
if get_option('disallow_hw_timer')
tracy_common_args += ['-DTRACY_DISALLOW_HW_TIMER']
endif
if get_option('no_crash_handler')
tracy_common_args += ['-DTRACY_NO_CRASH_HANDLER']
endif

View File

@@ -16,6 +16,7 @@ option('no_frame_image', type : 'boolean', value : false, description : 'Disable
option('no_system_tracing', type : 'boolean', value : false, description : 'Disable systrace sampling')
option('patchable_nopsleds', type : 'boolean', value : false, description : 'Enable nopsleds for efficient patching by system-level tools (e.g. rr)')
option('timer_fallback', type : 'boolean', value : false, description : 'Use lower resolution timers')
option('disallow_hw_timer', type : 'boolean', value : false, description : 'Disallow hardware timer (may be useful on VMs). Requires timer_fallback.')
option('libunwind_backtrace', type : 'boolean', value : false, description : 'Use libunwind backtracing where supported')
option('symbol_offline_resolve', type : 'boolean', value : false, description : 'Instead of full runtime symbol resolution, only resolve the image path and offset to enable offline symbol resolution')
option('libbacktrace_elf_dynload_support', type : 'boolean', value : false, description : 'Enable libbacktrace to support dynamically loaded elfs in symbol resolution resolution after the first symbol resolve operation')

View File

@@ -28,7 +28,7 @@
# include <mach/mach_time.h>
#endif
#if ( (defined _WIN32 && !(defined _M_ARM64 || defined _M_ARM)) || ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 ) || ( defined TARGET_OS_IOS && TARGET_OS_IOS == 1 ) || ( defined __APPLE__ && defined __MACH__ && TARGET_CPU_ARM64 ) )
#if !defined TRACY_DISALLOW_HW_TIMER && ( (defined _WIN32 && !(defined _M_ARM64 || defined _M_ARM)) || ( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 ) || ( defined TARGET_OS_IOS && TARGET_OS_IOS == 1 ) || ( defined __APPLE__ && defined __MACH__ && TARGET_CPU_ARM64 ) )
# define TRACY_HW_TIMER
#endif

View File

@@ -600,6 +600,10 @@ bool SysTraceStart( int64_t& samplingPeriod )
#if !defined TRACY_HW_TIMER || !( defined __i386 || defined _M_IX86 || defined __x86_64__ || defined _M_X64 )
useMonotonicClockRaw = true;
#endif
if( useMonotonicClockRaw )
{
TracyDebug( "Using CLOCK_MONOTONIC_RAW for Linux perf events." );
}
#ifdef TRACY_NO_SAMPLING
const bool noSoftwareSampling = true;