diff --git a/server/TracyEvent.hpp b/server/TracyEvent.hpp index 11060aa3..d847193c 100644 --- a/server/TracyEvent.hpp +++ b/server/TracyEvent.hpp @@ -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 childTimeStack; #endif + Vector sysCalls; }; struct GpuCtxThreadData diff --git a/server/TracyWorker.cpp b/server/TracyWorker.cpp index 15accd80..28fd2533 100644 --- a/server/TracyWorker.cpp +++ b/server/TracyWorker.cpp @@ -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; diff --git a/server/TracyWorker.hpp b/server/TracyWorker.hpp index 95b3b0c1..8f136d45 100644 --- a/server/TracyWorker.hpp +++ b/server/TracyWorker.hpp @@ -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 );