2
0
mirror of https://github.com/wolfpld/tracy synced 2026-01-19 17:02:11 +00:00

formatting

This commit is contained in:
Marcos Slomp
2026-01-15 11:25:26 -08:00
parent dacb3dbae6
commit 44696c47c6
2 changed files with 24 additions and 24 deletions

View File

@@ -188,42 +188,42 @@ bool SysTraceStart( int64_t& samplingPeriod )
s_pid = GetCurrentProcessId();
if ( !etw::CheckAdminPrivilege() )
if( !etw::CheckAdminPrivilege() )
return false;
session_kernel = etw::StartSingletonKernelLoggerSession();
if ( session_kernel.handle == 0 )
if( session_kernel.handle == 0 )
return false;
#ifndef TRACY_NO_CONTEXT_SWITCH
if ( etw::EnableProcessAndThreadMonitoring( session_kernel ) != ERROR_SUCCESS )
if( etw::EnableProcessAndThreadMonitoring( session_kernel ) != ERROR_SUCCESS )
return etw::StopSession( session_kernel ), false;
if ( etw::EnableContextSwitchMonitoring( session_kernel ) != ERROR_SUCCESS )
if( etw::EnableContextSwitchMonitoring( session_kernel ) != ERROR_SUCCESS )
return etw::StopSession( session_kernel ), false;
#endif
#ifndef TRACY_NO_SAMPLING
int microseconds = GetSamplingInterval() / 10;
if ( etw::EnableCPUProfiling( session_kernel, microseconds ) != ERROR_SUCCESS )
if( etw::EnableCPUProfiling( session_kernel, microseconds ) != ERROR_SUCCESS )
return etw::StopSession( session_kernel ), false;
samplingPeriod = GetSamplingPeriod();
#endif
consumer_kernel = etw::SetupEventConsumer( session_kernel, EventRecordCallback );
if ( consumer_kernel == INVALID_PROCESSTRACE_HANDLE )
if( consumer_kernel == INVALID_PROCESSTRACE_HANDLE )
return etw::StopSession( session_kernel ), false;
#ifndef TRACY_NO_VSYNC_CAPTURE
session_vsync = etw::StartUserSession( "TracyVsync" );
if ( session_vsync.handle != 0 )
if( session_vsync.handle != 0 )
{
if ( etw::EnableVSyncMonitoring( session_vsync ) != ERROR_SUCCESS )
if( etw::EnableVSyncMonitoring( session_vsync ) != ERROR_SUCCESS )
etw::StopSession( session_vsync );
else
{
consumer_vsync = etw::SetupEventConsumer( session_vsync, EventRecordCallback );
if ( consumer_vsync != INVALID_PROCESSTRACE_HANDLE )
if( consumer_vsync != INVALID_PROCESSTRACE_HANDLE )
{
s_threadVsync = (Thread*)tracy_malloc( sizeof( Thread ) );
new(s_threadVsync) Thread( [] (void*) {

View File

@@ -134,12 +134,12 @@ constexpr uint32_t Color_Red4 = 0x8b0000; // TracyColor.hpp
static void ETWErrorAction( ULONG error_code, const char* message, int length )
{
#ifndef TRACY_NO_INTERNAL_MESSAGE
#ifdef TRACY_HAS_CALLSTACK
# ifdef TRACY_HAS_CALLSTACK
tracy::InitCallstackCritical();
tracy::Profiler::LogString( MessageSourceType::Tracy, MessageSeverity::Error, Color_Red4, 60, length, message );
#else
# else
tracy::Profiler::LogString( MessageSourceType::Tracy, MessageSeverity::Error, Color_Red4, 0, length, message );
#endif
# endif
#endif
#ifdef __cpp_exceptions
// TODO: should we throw an exception?
@@ -216,7 +216,7 @@ static ULONG StopSession( Session& session )
return ETWError( status );
// once stopped, the session handle becomes invalid
session.handle = 0;
for ( auto&& sw : session.stackwalk )
for( auto&& sw : session.stackwalk )
sw = {};
return ERROR_SUCCESS;
}
@@ -303,7 +303,7 @@ static ULONG EnableStackWalk( Session& session, GUID EventGuid, UCHAR Opcode )
// Instead, we keep our own array of active stack trace event ids in the session object.
for( auto&& sw : session.stackwalk )
{
if ( !IsEqualGUID( sw.EventGuid, {} ) )
if( !IsEqualGUID( sw.EventGuid, {} ) )
continue;
sw.EventGuid = EventGuid;
sw.Type = Opcode;
@@ -314,7 +314,7 @@ static ULONG EnableStackWalk( Session& session, GUID EventGuid, UCHAR Opcode )
return 0 /* ERROR_SUCCESS */; // TODO: return error instead?
}
static ULONG SetCPUProfilingInterval(int microseconds)
static ULONG SetCPUProfilingInterval( int microseconds )
{
if( !IsOS64Bit() )
return 0 /* ERROR_SUCCESS */; // TODO: fabricate SetLastError(ERROR_NOT_SUPPORTED) instead?
@@ -436,15 +436,15 @@ static ULONG UpdateSessionEnableFlags( Session& session, ULONGLONG EnableFlags )
Session temp = session;
temp.properties.EnableFlags = EnableFlags;
ULONG status = ControlTraceA( temp.handle, temp.name, &temp.properties, EVENT_TRACE_CONTROL_UPDATE );
if (status != ERROR_SUCCESS)
return ETWError(status);
if( status != ERROR_SUCCESS )
return ETWError( status );
session.properties.EnableFlags = EnableFlags;
return status;
}
static ULONG EnableProcessAndThreadMonitoring( Session& session )
{
if ( IsSingletonKernelLoggerSession(session) )
if( IsSingletonKernelLoggerSession( session ) )
{
ULONGLONG EnableFlags = session.properties.EnableFlags;
EnableFlags |= EVENT_TRACE_FLAG_THREAD;
@@ -460,7 +460,7 @@ static ULONG EnableProcessAndThreadMonitoring( Session& session )
static ULONG EnableCPUProfiling( Session& session, int microseconds = 125 /* 8KHz = 125us */ )
{
if ( !IsOS64Bit() )
if( !IsOS64Bit() )
return 0 /* ERROR_SUCCESS */; // TODO: fabricate SetLastError(ERROR_NOT_SUPPORTED) instead?
// CPU Profiling requires special privileges on top of admin privileges
@@ -468,12 +468,12 @@ static ULONG EnableCPUProfiling( Session& session, int microseconds = 125 /* 8KH
if( access != ERROR_SUCCESS )
return access;
if ( IsSingletonKernelLoggerSession( session ) )
if( IsSingletonKernelLoggerSession( session ) )
{
ULONGLONG EnableFlags = session.properties.EnableFlags;
EnableFlags |= EVENT_TRACE_FLAG_PROFILE;
ULONG status = UpdateSessionEnableFlags( session, EnableFlags );
if ( status != ERROR_SUCCESS )
if( status != ERROR_SUCCESS )
return status;
}
else
@@ -484,7 +484,7 @@ static ULONG EnableCPUProfiling( Session& session, int microseconds = 125 /* 8KH
return status;
}
ULONG status = SetCPUProfilingInterval(microseconds);
ULONG status = SetCPUProfilingInterval( microseconds );
if( status != ERROR_SUCCESS )
return status;
@@ -494,13 +494,13 @@ static ULONG EnableCPUProfiling( Session& session, int microseconds = 125 /* 8KH
static ULONG EnableContextSwitchMonitoring( Session& session )
{
if ( IsSingletonKernelLoggerSession( session ) )
if( IsSingletonKernelLoggerSession( session ) )
{
ULONGLONG EnableFlags = session.properties.EnableFlags;
EnableFlags |= EVENT_TRACE_FLAG_CSWITCH;
EnableFlags |= EVENT_TRACE_FLAG_DISPATCHER;
ULONG status = UpdateSessionEnableFlags( session, EnableFlags );
if ( status != ERROR_SUCCESS )
if( status != ERROR_SUCCESS )
return status;
}
else