diff --git a/public/client/TracySysTrace.cpp b/public/client/TracySysTrace.cpp index cc89d5de..26d7935c 100644 --- a/public/client/TracySysTrace.cpp +++ b/public/client/TracySysTrace.cpp @@ -190,6 +190,8 @@ bool SysTraceStart( int64_t& samplingPeriod ) return false; #ifndef TRACY_NO_CONTEXT_SWITCH + if ( etw::EnableProcessAndThreadMonitoring(session) != ERROR_SUCCESS ) + return etw::StopSession(session), false; if ( etw::EnableContextSwitchMonitoring(session) != ERROR_SUCCESS ) return etw::StopSession( session ), false; #endif diff --git a/public/client/windows/TracyETW.cpp b/public/client/windows/TracyETW.cpp index 46abb994..3509bdb6 100644 --- a/public/client/windows/TracyETW.cpp +++ b/public/client/windows/TracyETW.cpp @@ -167,6 +167,15 @@ static Session StartPrivateKernelSession( const CHAR* name ) return session; } +static ULONG EnableProcessAndThreadMonitoring(Session& session) { + ULONGLONG MatchAnyKeyword = SYSTEM_PROCESS_KW_THREAD; // ThreadStart and ThreadDCStart events + ULONG status = EnableProvider( session, SystemProcessProviderGuid, + EVENT_CONTROL_CODE_ENABLE_PROVIDER, TRACE_LEVEL_INFORMATION, MatchAnyKeyword ); + if (status != ERROR_SUCCESS) + return status; + return status; +} + static ULONG EnableCPUProfiling( Session& session, int microseconds = 125 /* 8KHz = 125us */ ) { // CPU Profiling requires special privileges on top of admin privileges @@ -192,7 +201,9 @@ static ULONG EnableCPUProfiling( Session& session, int microseconds = 125 /* 8KH static ULONG EnableContextSwitchMonitoring( Session& session ) { - ULONGLONG MatchAnyKeyword = SYSTEM_SCHEDULER_KW_CONTEXT_SWITCH; + ULONGLONG MatchAnyKeyword = 0; + MatchAnyKeyword |= SYSTEM_SCHEDULER_KW_CONTEXT_SWITCH; // CSwitch events + MatchAnyKeyword |= SYSTEM_SCHEDULER_KW_DISPATCHER; // ReadyThread events ULONG status = EnableProvider( session, SystemSchedulerProviderGuid, EVENT_CONTROL_CODE_ENABLE_PROVIDER, TRACE_LEVEL_INFORMATION, MatchAnyKeyword ); if( status != ERROR_SUCCESS )