mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 22:44:34 +00:00
Perform symbol information queries.
This commit is contained in:
parent
ef05570540
commit
26cee8acf0
@ -2301,6 +2301,9 @@ bool Profiler::HandleServerQuery()
|
||||
case ServerQueryParameter:
|
||||
HandleParameter( ptr );
|
||||
break;
|
||||
case ServerQuerySymbol:
|
||||
HandleSymbolQuery( ptr );
|
||||
break;
|
||||
default:
|
||||
assert( false );
|
||||
break;
|
||||
@ -2677,6 +2680,28 @@ void Profiler::HandleParameter( uint64_t payload )
|
||||
m_paramCallback( idx, val );
|
||||
}
|
||||
|
||||
void Profiler::HandleSymbolQuery( uint64_t symbol )
|
||||
{
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
const auto sym = DecodeSymbolAddress( symbol );
|
||||
|
||||
SendString( uint64_t( sym.file ), sym.file, QueueType::CustomStringData );
|
||||
SendString( uint64_t( sym.name ), sym.name, QueueType::CustomStringData );
|
||||
|
||||
QueueItem item;
|
||||
MemWrite( &item.hdr.type, QueueType::SymbolInformation );
|
||||
MemWrite( &item.callstackFrame.file, uint64_t( sym.file ) );
|
||||
MemWrite( &item.callstackFrame.name, uint64_t( sym.name ) );
|
||||
MemWrite( &item.callstackFrame.line, sym.line );
|
||||
MemWrite( &item.callstackFrame.symAddr, symbol );
|
||||
|
||||
AppendData( &item, QueueDataSize[(int)QueueType::SymbolInformation] );
|
||||
|
||||
tracy_free( (void*)sym.file );
|
||||
tracy_free( (void*)sym.name );
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -557,6 +557,7 @@ private:
|
||||
bool HandleServerQuery();
|
||||
void HandleDisconnect();
|
||||
void HandleParameter( uint64_t payload );
|
||||
void HandleSymbolQuery( uint64_t symbol );
|
||||
|
||||
void CalibrateTimer();
|
||||
void CalibrateDelay();
|
||||
|
@ -47,7 +47,8 @@ enum ServerQuery : uint8_t
|
||||
ServerQueryFrameName,
|
||||
ServerQueryDisconnect,
|
||||
ServerQueryExternalName,
|
||||
ServerQueryParameter
|
||||
ServerQueryParameter,
|
||||
ServerQuerySymbol
|
||||
};
|
||||
|
||||
struct ServerQueryPacket
|
||||
|
@ -21,6 +21,7 @@ enum class QueueType : uint8_t
|
||||
Callstack,
|
||||
CallstackAlloc,
|
||||
CallstackSample,
|
||||
SymbolInformation,
|
||||
FrameImage,
|
||||
ZoneBegin,
|
||||
ZoneBeginCallstack,
|
||||
@ -448,6 +449,7 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstack ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackAlloc ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackSample ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrame ), // symbol information
|
||||
sizeof( QueueHeader ) + sizeof( QueueFrameImage ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // callstack
|
||||
|
@ -326,7 +326,14 @@ struct CallstackFrame : public CallstackFrameBasic
|
||||
uint64_t symAddr;
|
||||
};
|
||||
|
||||
struct SymbolData : public CallstackFrameBasic
|
||||
{
|
||||
StringIdx imageName;
|
||||
};
|
||||
|
||||
enum { CallstackFrameBasicSize = sizeof( CallstackFrameBasic ) };
|
||||
enum { CallstackFrameSize = sizeof( CallstackFrame ) };
|
||||
enum { SymbolDataSize = sizeof( SymbolData ) };
|
||||
|
||||
struct CallstackFrameData
|
||||
{
|
||||
|
@ -2501,7 +2501,8 @@ void Worker::Exec()
|
||||
{
|
||||
if( m_pendingStrings != 0 || m_pendingThreads != 0 || m_pendingSourceLocation != 0 || m_pendingCallstackFrames != 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() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@ -3461,6 +3462,9 @@ bool Worker::Process( const QueueItem& ev )
|
||||
case QueueType::CallstackFrame:
|
||||
ProcessCallstackFrame( ev.callstackFrame );
|
||||
break;
|
||||
case QueueType::SymbolInformation:
|
||||
ProcessSymbolInformation( ev.callstackFrame );
|
||||
break;
|
||||
case QueueType::Terminate:
|
||||
m_terminate = true;
|
||||
break;
|
||||
@ -4723,6 +4727,12 @@ void Worker::ProcessCallstackFrame( const QueueCallstackFrame& ev )
|
||||
m_callstackFrameStaging->data[idx].line = ev.line;
|
||||
m_callstackFrameStaging->data[idx].symAddr = ev.symAddr;
|
||||
|
||||
if( ev.symAddr != 0 && m_data.symbolMap.find( ev.symAddr ) == m_data.symbolMap.end() && m_pendingSymbols.find( ev.symAddr ) == m_pendingSymbols.end() )
|
||||
{
|
||||
m_pendingSymbols.emplace( ev.symAddr, m_callstackFrameStaging->imageName );
|
||||
Query( ServerQuerySymbol, ev.symAddr );
|
||||
}
|
||||
|
||||
if( --m_pendingCallstackSubframes == 0 )
|
||||
{
|
||||
assert( m_data.callstackFrameMap.find( PackPointer( m_callstackFrameStagingPtr ) ) == m_data.callstackFrameMap.end() );
|
||||
@ -4739,6 +4749,28 @@ void Worker::ProcessCallstackFrame( const QueueCallstackFrame& ev )
|
||||
m_pendingCustomStrings.erase( m_pendingCustomStrings.find( ev.file ) );
|
||||
}
|
||||
|
||||
void Worker::ProcessSymbolInformation( const QueueCallstackFrame& ev )
|
||||
{
|
||||
auto it = m_pendingSymbols.find( ev.symAddr );
|
||||
assert( it != m_pendingSymbols.end() );
|
||||
|
||||
auto nit = m_pendingCustomStrings.find( ev.name );
|
||||
assert( nit != m_pendingCustomStrings.end() );
|
||||
auto fit = m_pendingCustomStrings.find( ev.file );
|
||||
assert( fit != m_pendingCustomStrings.end() );
|
||||
|
||||
SymbolData sd;
|
||||
sd.name = StringIdx( nit->second.idx );
|
||||
sd.file = StringIdx( fit->second.idx );
|
||||
sd.line = ev.line;
|
||||
sd.imageName = it->second;
|
||||
m_data.symbolMap.emplace( ev.symAddr, std::move( sd ) );
|
||||
|
||||
m_pendingSymbols.erase( it );
|
||||
m_pendingCustomStrings.erase( nit );
|
||||
m_pendingCustomStrings.erase( m_pendingCustomStrings.find( ev.file ) );
|
||||
}
|
||||
|
||||
void Worker::ProcessCrashReport( const QueueCrashReport& ev )
|
||||
{
|
||||
CheckString( ev.text );
|
||||
|
@ -217,6 +217,7 @@ private:
|
||||
Vector<short_ptr<VarArray<CallstackFrameId>>> callstackPayload;
|
||||
unordered_flat_map<CallstackFrameId, CallstackFrameData*, CallstackFrameIdHash, CallstackFrameIdCompare> callstackFrameMap;
|
||||
unordered_flat_map<CallstackFrameData*, CallstackFrameId, RevFrameHash, RevFrameComp> revFrameMap;
|
||||
unordered_flat_map<uint64_t, SymbolData> symbolMap;
|
||||
|
||||
unordered_flat_map<uint32_t, LockMap*> lockMap;
|
||||
|
||||
@ -517,6 +518,7 @@ private:
|
||||
tracy_force_inline void ProcessCallstackSample( const QueueCallstackSample& ev );
|
||||
tracy_force_inline void ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev );
|
||||
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev );
|
||||
tracy_force_inline void ProcessSymbolInformation( const QueueCallstackFrame& ev );
|
||||
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
|
||||
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
|
||||
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
||||
@ -693,6 +695,7 @@ private:
|
||||
unordered_flat_map<uint64_t, ThreadData*> m_threadMap;
|
||||
unordered_flat_map<uint64_t, NextCallstack> m_nextCallstack;
|
||||
unordered_flat_map<uint64_t, FrameImagePending> m_pendingFrameImageData;
|
||||
unordered_flat_map<uint64_t, StringIdx> m_pendingSymbols;
|
||||
|
||||
uint32_t m_pendingStrings;
|
||||
uint32_t m_pendingThreads;
|
||||
|
Loading…
Reference in New Issue
Block a user