mirror of
https://github.com/wolfpld/tracy
synced 2025-05-01 05:03:53 +00:00
Store code address -> source file+line mapping.
This commit is contained in:
parent
b2a8b53efa
commit
0ec89e9aae
@ -230,6 +230,7 @@ Worker::Worker( const char* addr, int port )
|
|||||||
, m_pendingSourceLocation( 0 )
|
, m_pendingSourceLocation( 0 )
|
||||||
, m_pendingCallstackFrames( 0 )
|
, m_pendingCallstackFrames( 0 )
|
||||||
, m_pendingCallstackSubframes( 0 )
|
, m_pendingCallstackSubframes( 0 )
|
||||||
|
, m_pendingCodeInformation( 0 )
|
||||||
, m_callstackFrameStaging( nullptr )
|
, m_callstackFrameStaging( nullptr )
|
||||||
, m_traceVersion( CurrentVersion )
|
, m_traceVersion( CurrentVersion )
|
||||||
, m_loadTime( 0 )
|
, m_loadTime( 0 )
|
||||||
@ -2860,7 +2861,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_pendingSymbolCode.empty() )
|
!m_pendingSymbols.empty() || !m_pendingSymbolCode.empty() || m_pendingCodeInformation != 0 )
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3588,6 +3589,7 @@ void Worker::AddSymbolCode( uint64_t ptr, const char* data, size_t sz )
|
|||||||
size_t cnt = cs_disasm( handle, (const uint8_t*)code, sz, ptr, 0, &insn );
|
size_t cnt = cs_disasm( handle, (const uint8_t*)code, sz, ptr, 0, &insn );
|
||||||
if( cnt > 0 )
|
if( cnt > 0 )
|
||||||
{
|
{
|
||||||
|
m_pendingCodeInformation += cnt;
|
||||||
for( size_t i=0; i<cnt; i++ )
|
for( size_t i=0; i<cnt; i++ )
|
||||||
{
|
{
|
||||||
Query( ServerQueryCodeLocation, insn[i].address );
|
Query( ServerQueryCodeLocation, insn[i].address );
|
||||||
@ -4024,7 +4026,7 @@ bool Worker::Process( const QueueItem& ev )
|
|||||||
m_serverQuerySpaceLeft++;
|
m_serverQuerySpaceLeft++;
|
||||||
break;
|
break;
|
||||||
case QueueType::CodeInformation:
|
case QueueType::CodeInformation:
|
||||||
// TODO
|
ProcessCodeInformation( ev.codeInformation );
|
||||||
m_serverQuerySpaceLeft++;
|
m_serverQuerySpaceLeft++;
|
||||||
break;
|
break;
|
||||||
case QueueType::Terminate:
|
case QueueType::Terminate:
|
||||||
@ -5502,6 +5504,28 @@ void Worker::ProcessSymbolInformation( const QueueSymbolInformation& ev )
|
|||||||
m_pendingCustomStrings.erase( fit );
|
m_pendingCustomStrings.erase( fit );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tracy_force_inline uint64_t PackFileLine( uint32_t fileIdx, uint32_t line )
|
||||||
|
{
|
||||||
|
return ( uint64_t( fileIdx ) << 32 ) | line;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Worker::ProcessCodeInformation( const QueueCodeInformation& ev )
|
||||||
|
{
|
||||||
|
assert( m_pendingCodeInformation > 0 );
|
||||||
|
m_pendingCodeInformation--;
|
||||||
|
|
||||||
|
auto fit = m_pendingCustomStrings.find( ev.file );
|
||||||
|
assert( fit != m_pendingCustomStrings.end() );
|
||||||
|
|
||||||
|
if( ev.line != 0 )
|
||||||
|
{
|
||||||
|
assert( m_data.codeAddressToLocation.find( ev.ptr ) == m_data.codeAddressToLocation.end() );
|
||||||
|
m_data.codeAddressToLocation.emplace( ev.ptr, PackFileLine( fit->second.idx, ev.line ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_pendingCustomStrings.erase( fit );
|
||||||
|
}
|
||||||
|
|
||||||
void Worker::ProcessCrashReport( const QueueCrashReport& ev )
|
void Worker::ProcessCrashReport( const QueueCrashReport& ev )
|
||||||
{
|
{
|
||||||
CheckString( ev.text );
|
CheckString( ev.text );
|
||||||
|
@ -296,6 +296,8 @@ private:
|
|||||||
|
|
||||||
unordered_flat_map<uint64_t, SymbolCodeData> symbolCode;
|
unordered_flat_map<uint64_t, SymbolCodeData> symbolCode;
|
||||||
uint64_t symbolCodeSize = 0;
|
uint64_t symbolCodeSize = 0;
|
||||||
|
|
||||||
|
unordered_flat_map<uint64_t, uint64_t> codeAddressToLocation;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MbpsBlock
|
struct MbpsBlock
|
||||||
@ -589,6 +591,7 @@ private:
|
|||||||
tracy_force_inline void ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev );
|
tracy_force_inline void ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev );
|
||||||
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev );
|
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev );
|
||||||
tracy_force_inline void ProcessSymbolInformation( const QueueSymbolInformation& ev );
|
tracy_force_inline void ProcessSymbolInformation( const QueueSymbolInformation& ev );
|
||||||
|
tracy_force_inline void ProcessCodeInformation( const QueueCodeInformation& ev );
|
||||||
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
|
tracy_force_inline void ProcessCrashReport( const QueueCrashReport& ev );
|
||||||
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
|
tracy_force_inline void ProcessSysTime( const QueueSysTime& ev );
|
||||||
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
||||||
@ -788,6 +791,7 @@ private:
|
|||||||
uint32_t m_pendingSourceLocation;
|
uint32_t m_pendingSourceLocation;
|
||||||
uint32_t m_pendingCallstackFrames;
|
uint32_t m_pendingCallstackFrames;
|
||||||
uint8_t m_pendingCallstackSubframes;
|
uint8_t m_pendingCallstackSubframes;
|
||||||
|
uint32_t m_pendingCodeInformation;
|
||||||
|
|
||||||
CallstackFrameData* m_callstackFrameStaging;
|
CallstackFrameData* m_callstackFrameStaging;
|
||||||
uint64_t m_callstackFrameStagingPtr;
|
uint64_t m_callstackFrameStagingPtr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user