mirror of
https://github.com/wolfpld/tracy
synced 2026-01-19 04:52:09 +00:00
Merge pull request #1233 from slomp/slomp/etw-happiness
Ensure all ETW StackWalk requests are satisfied
This commit is contained in:
@@ -23,6 +23,7 @@ struct Session
|
||||
EVENT_TRACE_PROPERTIES properties = {};
|
||||
CHAR name[64] = {};
|
||||
CONTROLTRACE_ID handle = 0;
|
||||
CLASSIC_EVENT_ID stackwalk[8] = {};
|
||||
};
|
||||
|
||||
// ---- ETW Events ----------
|
||||
@@ -213,6 +214,8 @@ static ULONG StopSession( Session& session )
|
||||
return ETWError( status );
|
||||
// once stopped, the session handle becomes invalid
|
||||
session.handle = 0;
|
||||
for ( auto&& sw : session.stackwalk )
|
||||
sw = {};
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -289,11 +292,24 @@ static ULONG EnableStackWalk( Session& session, GUID EventGuid, UCHAR Opcode )
|
||||
{
|
||||
if( !IsOS64Bit() )
|
||||
return 0 /* ERROR_SUCCESS */; // TODO: return error instead?
|
||||
CLASSIC_EVENT_ID stackId[1] = {};
|
||||
stackId[0].EventGuid = EventGuid;
|
||||
stackId[0].Type = Opcode;
|
||||
ULONG status = TraceSetInformation( session.handle, TraceStackTracingInfo, &stackId, sizeof( stackId ) );
|
||||
return ETWError( status );
|
||||
// TraceStackTracingInfo: Turns on stack trace collection for the specified kernel events
|
||||
// for the specified logger. It also turns off stack tracing for
|
||||
// all kernel events not on this list, regardless of prior status.
|
||||
// NOTE: It'd be nice if we could rely on TraceQueryInformation(TraceStackTracingInfo)
|
||||
// to retrieve the list of the active stack trace event ids, but even though MSDN says
|
||||
// that it is possible, the query call returns ERROR_NOT_SUPPORTED...
|
||||
// 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, {} ) )
|
||||
continue;
|
||||
sw.EventGuid = EventGuid;
|
||||
sw.Type = Opcode;
|
||||
size_t count = ( &sw - session.stackwalk ) + 1;
|
||||
ULONG status = TraceSetInformation( session.handle, TraceStackTracingInfo, session.stackwalk, count * sizeof( CLASSIC_EVENT_ID ) );
|
||||
return ETWError( status );
|
||||
}
|
||||
return 0 /* ERROR_SUCCESS */; // TODO: return error instead?
|
||||
}
|
||||
|
||||
static ULONG SetCPUProfilingInterval(int microseconds)
|
||||
|
||||
Reference in New Issue
Block a user