mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Add code transfer from client to server.
This commit is contained in:
parent
3e0e120222
commit
f114ec3f80
@ -2130,7 +2130,8 @@ void Profiler::SendString( uint64_t str, const char* ptr, QueueType type )
|
|||||||
|
|
||||||
void Profiler::SendLongString( uint64_t str, const char* ptr, size_t len, QueueType type )
|
void Profiler::SendLongString( uint64_t str, const char* ptr, size_t len, QueueType type )
|
||||||
{
|
{
|
||||||
assert( type == QueueType::FrameImageData );
|
assert( type == QueueType::FrameImageData ||
|
||||||
|
type == QueueType::SymbolCode );
|
||||||
|
|
||||||
QueueItem item;
|
QueueItem item;
|
||||||
MemWrite( &item.hdr.type, type );
|
MemWrite( &item.hdr.type, type );
|
||||||
@ -2354,6 +2355,9 @@ bool Profiler::HandleServerQuery()
|
|||||||
case ServerQuerySymbol:
|
case ServerQuerySymbol:
|
||||||
HandleSymbolQuery( ptr );
|
HandleSymbolQuery( ptr );
|
||||||
break;
|
break;
|
||||||
|
case ServerQuerySymbolCode:
|
||||||
|
HandleSymbolCodeQuery( ptr, extra );
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert( false );
|
assert( false );
|
||||||
break;
|
break;
|
||||||
@ -2747,6 +2751,11 @@ void Profiler::HandleSymbolQuery( uint64_t symbol )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Profiler::HandleSymbolCodeQuery( uint64_t symbol, uint32_t size )
|
||||||
|
{
|
||||||
|
SendLongString( symbol, (const char*)symbol, size, QueueType::SymbolCode );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -558,6 +558,7 @@ private:
|
|||||||
void HandleDisconnect();
|
void HandleDisconnect();
|
||||||
void HandleParameter( uint64_t payload );
|
void HandleParameter( uint64_t payload );
|
||||||
void HandleSymbolQuery( uint64_t symbol );
|
void HandleSymbolQuery( uint64_t symbol );
|
||||||
|
void HandleSymbolCodeQuery( uint64_t symbol, uint32_t size );
|
||||||
|
|
||||||
void CalibrateTimer();
|
void CalibrateTimer();
|
||||||
void CalibrateDelay();
|
void CalibrateDelay();
|
||||||
|
@ -48,7 +48,8 @@ enum ServerQuery : uint8_t
|
|||||||
ServerQueryDisconnect,
|
ServerQueryDisconnect,
|
||||||
ServerQueryExternalName,
|
ServerQueryExternalName,
|
||||||
ServerQueryParameter,
|
ServerQueryParameter,
|
||||||
ServerQuerySymbol
|
ServerQuerySymbol,
|
||||||
|
ServerQuerySymbolCode
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ServerQueryPacket
|
struct ServerQueryPacket
|
||||||
|
@ -83,6 +83,7 @@ enum class QueueType : uint8_t
|
|||||||
FrameImageData,
|
FrameImageData,
|
||||||
ExternalName,
|
ExternalName,
|
||||||
ExternalThreadName,
|
ExternalThreadName,
|
||||||
|
SymbolCode,
|
||||||
NUM_TYPES
|
NUM_TYPES
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -530,6 +531,7 @@ static constexpr size_t QueueDataSize[] = {
|
|||||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // frame image data
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // frame image data
|
||||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // external name
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // external name
|
||||||
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // external thread name
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // external thread name
|
||||||
|
sizeof( QueueHeader ) + sizeof( QueueStringTransfer ), // symbol code
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );
|
static_assert( QueueItemSize == 32, "Queue item size not 32 bytes" );
|
||||||
|
@ -2761,7 +2761,7 @@ void Worker::Exec()
|
|||||||
if( m_pendingStrings != 0 || m_pendingThreads != 0 || m_pendingSourceLocation != 0 || m_pendingCallstackFrames != 0 ||
|
if( m_pendingStrings != 0 || m_pendingThreads != 0 || m_pendingSourceLocation != 0 || m_pendingCallstackFrames != 0 ||
|
||||||
!m_pendingCustomStrings.empty() || m_data.plots.IsPending() || m_pendingCallstackPtr != 0 ||
|
!m_pendingCustomStrings.empty() || m_data.plots.IsPending() || m_pendingCallstackPtr != 0 ||
|
||||||
m_pendingExternalNames != 0 || m_pendingCallstackSubframes != 0 || !m_pendingFrameImageData.empty() ||
|
m_pendingExternalNames != 0 || m_pendingCallstackSubframes != 0 || !m_pendingFrameImageData.empty() ||
|
||||||
!m_pendingSymbols.empty() )
|
!m_pendingSymbols.empty() || !m_pendingSymbolCode.empty() )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2815,12 +2815,24 @@ bool Worker::DispatchProcess( const QueueItem& ev, const char*& ptr )
|
|||||||
if( ev.hdr.idx >= (int)QueueType::StringData )
|
if( ev.hdr.idx >= (int)QueueType::StringData )
|
||||||
{
|
{
|
||||||
ptr += sizeof( QueueHeader ) + sizeof( QueueStringTransfer );
|
ptr += sizeof( QueueHeader ) + sizeof( QueueStringTransfer );
|
||||||
if( ev.hdr.type == QueueType::FrameImageData )
|
if( ev.hdr.type == QueueType::FrameImageData ||
|
||||||
|
ev.hdr.type == QueueType::SymbolCode )
|
||||||
{
|
{
|
||||||
uint32_t sz;
|
uint32_t sz;
|
||||||
memcpy( &sz, ptr, sizeof( sz ) );
|
memcpy( &sz, ptr, sizeof( sz ) );
|
||||||
ptr += sizeof( sz );
|
ptr += sizeof( sz );
|
||||||
|
switch( ev.hdr.type )
|
||||||
|
{
|
||||||
|
case QueueType::FrameImageData:
|
||||||
AddFrameImageData( ev.stringTransfer.ptr, ptr, sz );
|
AddFrameImageData( ev.stringTransfer.ptr, ptr, sz );
|
||||||
|
break;
|
||||||
|
case QueueType::SymbolCode:
|
||||||
|
AddSymbolCode( ev.stringTransfer.ptr, ptr, sz );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
break;
|
||||||
|
}
|
||||||
ptr += sz;
|
ptr += sz;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -3317,6 +3329,18 @@ void Worker::AddFrameImageData( uint64_t ptr, const char* data, size_t sz )
|
|||||||
m_pendingFrameImageData.emplace( ptr, FrameImagePending { image, csz } );
|
m_pendingFrameImageData.emplace( ptr, FrameImagePending { image, csz } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Worker::AddSymbolCode( uint64_t ptr, const char* data, size_t sz )
|
||||||
|
{
|
||||||
|
auto it = m_pendingSymbolCode.find( ptr );
|
||||||
|
assert( it != m_pendingSymbolCode.end() );
|
||||||
|
m_pendingSymbolCode.erase( it );
|
||||||
|
|
||||||
|
auto code = (char*)m_slab.AllocBig( sz );
|
||||||
|
memcpy( code, data, sz );
|
||||||
|
m_data.symbolCode.emplace( ptr, SymbolCodeData{ code, uint32_t( sz ) } );
|
||||||
|
m_data.symbolCodeSize += sz;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Worker::GetCanonicalPointer( const CallstackFrameId& id ) const
|
uint64_t Worker::GetCanonicalPointer( const CallstackFrameId& id ) const
|
||||||
{
|
{
|
||||||
assert( id.sel == 0 );
|
assert( id.sel == 0 );
|
||||||
@ -5196,6 +5220,13 @@ void Worker::ProcessSymbolInformation( const QueueSymbolInformation& ev )
|
|||||||
sd.size.SetVal( it->second.size );
|
sd.size.SetVal( it->second.size );
|
||||||
m_data.symbolMap.emplace( ev.symAddr, std::move( sd ) );
|
m_data.symbolMap.emplace( ev.symAddr, std::move( sd ) );
|
||||||
|
|
||||||
|
if( it->second.size > 0 && it->second.size <= 64*1024 )
|
||||||
|
{
|
||||||
|
assert( m_pendingSymbolCode.find( ev.symAddr ) == m_pendingSymbolCode.end() );
|
||||||
|
m_pendingSymbolCode.emplace( ev.symAddr );
|
||||||
|
Query( ServerQuerySymbolCode, ev.symAddr, it->second.size );
|
||||||
|
}
|
||||||
|
|
||||||
m_pendingSymbols.erase( it );
|
m_pendingSymbols.erase( it );
|
||||||
m_pendingCustomStrings.erase( fit );
|
m_pendingCustomStrings.erase( fit );
|
||||||
}
|
}
|
||||||
|
@ -121,6 +121,12 @@ public:
|
|||||||
uint32_t core;
|
uint32_t core;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SymbolCodeData
|
||||||
|
{
|
||||||
|
const char* data;
|
||||||
|
uint32_t len;
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SourceLocationZones
|
struct SourceLocationZones
|
||||||
{
|
{
|
||||||
@ -283,6 +289,9 @@ private:
|
|||||||
|
|
||||||
unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, std::vector<uint32_t>>> cpuTopology;
|
unordered_flat_map<uint32_t, unordered_flat_map<uint32_t, std::vector<uint32_t>>> cpuTopology;
|
||||||
unordered_flat_map<uint32_t, CpuThreadTopology> cpuTopologyMap;
|
unordered_flat_map<uint32_t, CpuThreadTopology> cpuTopologyMap;
|
||||||
|
|
||||||
|
unordered_flat_map<uint64_t, SymbolCodeData> symbolCode;
|
||||||
|
uint64_t symbolCodeSize = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MbpsBlock
|
struct MbpsBlock
|
||||||
@ -654,6 +663,7 @@ private:
|
|||||||
void AddExternalName( uint64_t ptr, const char* str, size_t sz );
|
void AddExternalName( uint64_t ptr, const char* str, size_t sz );
|
||||||
void AddExternalThreadName( uint64_t ptr, const char* str, size_t sz );
|
void AddExternalThreadName( uint64_t ptr, const char* str, size_t sz );
|
||||||
void AddFrameImageData( uint64_t ptr, const char* data, size_t sz );
|
void AddFrameImageData( uint64_t ptr, const char* data, size_t sz );
|
||||||
|
void AddSymbolCode( uint64_t ptr, const char* data, size_t sz );
|
||||||
|
|
||||||
tracy_force_inline void AddCallstackPayload( uint64_t ptr, const char* data, size_t sz );
|
tracy_force_inline void AddCallstackPayload( uint64_t ptr, const char* data, size_t sz );
|
||||||
tracy_force_inline void AddCallstackAllocPayload( uint64_t ptr, const char* data, size_t sz );
|
tracy_force_inline void AddCallstackAllocPayload( uint64_t ptr, const char* data, size_t sz );
|
||||||
@ -754,6 +764,7 @@ private:
|
|||||||
unordered_flat_map<uint64_t, NextCallstack> m_nextCallstack;
|
unordered_flat_map<uint64_t, NextCallstack> m_nextCallstack;
|
||||||
unordered_flat_map<uint64_t, FrameImagePending> m_pendingFrameImageData;
|
unordered_flat_map<uint64_t, FrameImagePending> m_pendingFrameImageData;
|
||||||
unordered_flat_map<uint64_t, SymbolPending> m_pendingSymbols;
|
unordered_flat_map<uint64_t, SymbolPending> m_pendingSymbols;
|
||||||
|
unordered_flat_set<uint64_t> m_pendingSymbolCode;
|
||||||
|
|
||||||
uint32_t m_pendingStrings;
|
uint32_t m_pendingStrings;
|
||||||
uint32_t m_pendingThreads;
|
uint32_t m_pendingThreads;
|
||||||
|
Loading…
Reference in New Issue
Block a user