mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-29 12:05:30 +00:00
Process sys calls.
This commit is contained in:
@@ -339,6 +339,16 @@ struct MessageData
|
||||
|
||||
enum { MessageDataSize = sizeof( MessageData ) };
|
||||
|
||||
|
||||
struct SysCall
|
||||
{
|
||||
int64_t begin;
|
||||
int64_t end;
|
||||
uint64_t ptr;
|
||||
};
|
||||
|
||||
enum { SysCallSize = sizeof( SysCall ) };
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
@@ -354,6 +364,7 @@ struct ThreadData
|
||||
#ifndef TRACY_NO_STATISTICS
|
||||
Vector<int64_t> childTimeStack;
|
||||
#endif
|
||||
Vector<SysCall> sysCalls;
|
||||
};
|
||||
|
||||
struct GpuCtxThreadData
|
||||
|
||||
@@ -3399,6 +3399,12 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::TidToPid:
|
||||
ProcessTidToPid( ev.tidToPid );
|
||||
break;
|
||||
case QueueType::SysCallEnter:
|
||||
ProcessSysCallEnter( ev.sysCallEnter );
|
||||
break;
|
||||
case QueueType::SysCallExit:
|
||||
ProcessSysCallExit( ev.sysCallExit );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
@@ -4641,6 +4647,38 @@ void Worker::ProcessTidToPid( const QueueTidToPid& ev )
|
||||
m_data.tidToPid.emplace( ev.tid, ev.pid );
|
||||
}
|
||||
|
||||
void Worker::ProcessSysCallEnter( const QueueSysCallEnter& ev )
|
||||
{
|
||||
auto td = RetrieveThread( ev.thread );
|
||||
if( !td ) return;
|
||||
if( td->sysCalls.empty() )
|
||||
{
|
||||
const auto refTime = m_refTimeCtx + ev.time;
|
||||
m_refTimeCtx = refTime;
|
||||
const auto time = TscTime( refTime - m_data.baseTime );
|
||||
td->sysCalls.push_back( SysCall { time, -1, ev.address } );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( td->sysCalls.back().end < 0 ) return;
|
||||
const auto refTime = m_refTimeCtx + ev.time;
|
||||
m_refTimeCtx = refTime;
|
||||
const auto time = TscTime( refTime - m_data.baseTime );
|
||||
td->sysCalls.push_back_non_empty( SysCall { time, -1, ev.address } );
|
||||
}
|
||||
}
|
||||
|
||||
void Worker::ProcessSysCallExit( const QueueSysCallExit& ev )
|
||||
{
|
||||
auto td = RetrieveThread( ev.thread );
|
||||
if( !td || td->sysCalls.empty() ) return;
|
||||
if( td->sysCalls.back().end >= 0 ) return;
|
||||
const auto refTime = m_refTimeCtx + ev.time;
|
||||
m_refTimeCtx = refTime;
|
||||
const auto time = TscTime( refTime - m_data.baseTime );
|
||||
td->sysCalls.back().end = time;
|
||||
}
|
||||
|
||||
void Worker::MemAllocChanged( int64_t time )
|
||||
{
|
||||
const auto val = (double)m_data.memory.usage;
|
||||
|
||||
@@ -459,6 +459,8 @@ private:
|
||||
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
||||
tracy_force_inline void ProcessThreadWakeup( const QueueThreadWakeup& ev );
|
||||
tracy_force_inline void ProcessTidToPid( const QueueTidToPid& ev );
|
||||
tracy_force_inline void ProcessSysCallEnter( const QueueSysCallEnter& ev );
|
||||
tracy_force_inline void ProcessSysCallExit( const QueueSysCallExit& ev );
|
||||
|
||||
tracy_force_inline void ProcessZoneBeginImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||
tracy_force_inline void ProcessZoneBeginAllocSrcLocImpl( ZoneEvent* zone, const QueueZoneBegin& ev );
|
||||
|
||||
Reference in New Issue
Block a user