mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 04:23:51 +00:00
Remove CodeLocation query and CodeInformation response.
This commit is contained in:
parent
ac6902501a
commit
383ecb6a12
@ -6,7 +6,6 @@
|
||||
#include "TracyFastVector.hpp"
|
||||
#include "TracyStringHelpers.hpp"
|
||||
#include "../common/TracyAlloc.hpp"
|
||||
#include "../common/TracyStackFrames.hpp"
|
||||
#include "TracyDebug.hpp"
|
||||
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
@ -385,85 +384,6 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||
return sym;
|
||||
}
|
||||
|
||||
CallstackSymbolData DecodeCodeAddress( uint64_t ptr )
|
||||
{
|
||||
CallstackSymbolData sym = {};
|
||||
const auto proc = GetCurrentProcess();
|
||||
bool done = false;
|
||||
|
||||
char buf[sizeof( SYMBOL_INFO ) + MaxNameSize];
|
||||
auto si = (SYMBOL_INFO*)buf;
|
||||
si->SizeOfStruct = sizeof( SYMBOL_INFO );
|
||||
si->MaxNameLen = MaxNameSize;
|
||||
|
||||
IMAGEHLP_LINE64 line;
|
||||
DWORD displacement = 0;
|
||||
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
|
||||
|
||||
#ifdef TRACY_DBGHELP_LOCK
|
||||
DBGHELP_LOCK;
|
||||
#endif
|
||||
#if !defined TRACY_NO_CALLSTACK_INLINES
|
||||
if( _SymAddrIncludeInlineTrace )
|
||||
{
|
||||
DWORD inlineNum = _SymAddrIncludeInlineTrace( proc, ptr );
|
||||
DWORD ctx = 0;
|
||||
DWORD idx;
|
||||
BOOL doInline = FALSE;
|
||||
if( inlineNum != 0 ) doInline = _SymQueryInlineTrace( proc, ptr, 0, ptr, ptr, &ctx, &idx );
|
||||
if( doInline )
|
||||
{
|
||||
if( _SymGetLineFromInlineContext( proc, ptr, ctx, 0, &displacement, &line ) != 0 )
|
||||
{
|
||||
sym.file = CopyString( line.FileName );
|
||||
sym.line = line.LineNumber;
|
||||
sym.needFree = true;
|
||||
done = true;
|
||||
|
||||
if( _SymFromInlineContext( proc, ptr, ctx, nullptr, si ) != 0 )
|
||||
{
|
||||
sym.symAddr = si->Address;
|
||||
}
|
||||
else
|
||||
{
|
||||
sym.symAddr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if( !done )
|
||||
{
|
||||
const auto res = SymGetLineFromAddr64( proc, ptr, &displacement, &line );
|
||||
if( res == 0 || line.LineNumber >= 0xF00000 )
|
||||
{
|
||||
sym.file = "[unknown]";
|
||||
sym.line = 0;
|
||||
sym.symAddr = 0;
|
||||
sym.needFree = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sym.file = CopyString( line.FileName );
|
||||
sym.line = line.LineNumber;
|
||||
sym.needFree = true;
|
||||
|
||||
if( SymFromAddr( proc, ptr, nullptr, si ) != 0 )
|
||||
{
|
||||
sym.symAddr = si->Address;
|
||||
}
|
||||
else
|
||||
{
|
||||
sym.symAddr = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef TRACY_DBGHELP_LOCK
|
||||
DBGHELP_UNLOCK;
|
||||
#endif
|
||||
return sym;
|
||||
}
|
||||
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||
{
|
||||
int write;
|
||||
@ -900,42 +820,6 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||
return sym;
|
||||
}
|
||||
|
||||
static int CodeDataCb( void* data, uintptr_t pc, uintptr_t lowaddr, const char* fn, int lineno, const char* function )
|
||||
{
|
||||
if( !fn ) return 1;
|
||||
|
||||
const auto fnsz = strlen( fn );
|
||||
if( fnsz >= s_tracySkipSubframesMinLen )
|
||||
{
|
||||
auto ptr = s_tracySkipSubframes;
|
||||
do
|
||||
{
|
||||
if( fnsz >= ptr->len && memcmp( fn + fnsz - ptr->len, ptr->str, ptr->len ) == 0 ) return 0;
|
||||
ptr++;
|
||||
}
|
||||
while( ptr->str );
|
||||
}
|
||||
|
||||
auto& sym = *(CallstackSymbolData*)data;
|
||||
sym.file = NormalizePath( fn );
|
||||
if( !sym.file ) sym.file = CopyString( fn );
|
||||
sym.line = lineno;
|
||||
sym.needFree = true;
|
||||
sym.symAddr = lowaddr;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void CodeErrorCb( void* /*data*/, const char* /*msg*/, int /*errnum*/ )
|
||||
{
|
||||
}
|
||||
|
||||
CallstackSymbolData DecodeCodeAddress( uint64_t ptr )
|
||||
{
|
||||
CallstackSymbolData sym = { "[unknown]", 0, false, 0 };
|
||||
backtrace_pcinfo( cb_bts, ptr, CodeDataCb, CodeErrorCb, &sym );
|
||||
return sym;
|
||||
}
|
||||
|
||||
static int CallstackDataCb( void* /*data*/, uintptr_t pc, uintptr_t lowaddr, const char* fn, int lineno, const char* function )
|
||||
{
|
||||
cb_data[cb_num].symLen = 0;
|
||||
@ -1122,11 +1006,6 @@ CallstackSymbolData DecodeSymbolAddress( uint64_t ptr )
|
||||
return CallstackSymbolData { symloc, 0, false, 0 };
|
||||
}
|
||||
|
||||
CallstackSymbolData DecodeCodeAddress( uint64_t ptr )
|
||||
{
|
||||
return DecodeSymbolAddress( ptr );
|
||||
}
|
||||
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||
{
|
||||
static CallstackEntry cb;
|
||||
|
@ -51,7 +51,6 @@ struct CallstackEntryData
|
||||
};
|
||||
|
||||
CallstackSymbolData DecodeSymbolAddress( uint64_t ptr );
|
||||
CallstackSymbolData DecodeCodeAddress( uint64_t ptr );
|
||||
const char* DecodeCallstackPtrFast( uint64_t ptr );
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr );
|
||||
void InitCallstack();
|
||||
|
@ -2173,16 +2173,6 @@ static void FreeAssociatedMemory( const QueueItem& item )
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QueueType::CodeInformation:
|
||||
{
|
||||
uint8_t needFree = MemRead<uint8_t>( &item.codeInformationFat.needFree );
|
||||
if( needFree )
|
||||
{
|
||||
ptr = MemRead<uint64_t>( &item.codeInformationFat.fileString );
|
||||
tracy_free( (void*)ptr );
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QueueType::SymbolCodeMetadata:
|
||||
ptr = MemRead<uint64_t>( &item.symbolCodeMetadata.ptr );
|
||||
tracy_free( (void*)ptr );
|
||||
@ -2481,14 +2471,6 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token )
|
||||
if( needFree ) tracy_free_fast( (void*)fileString );
|
||||
break;
|
||||
}
|
||||
case QueueType::CodeInformation:
|
||||
{
|
||||
auto fileString = (const char*)MemRead<uint64_t>( &item->codeInformationFat.fileString );
|
||||
auto needFree = MemRead<uint8_t>( &item->codeInformationFat.needFree );
|
||||
SendSingleString( fileString );
|
||||
if( needFree ) tracy_free_fast( (void*)fileString );
|
||||
break;
|
||||
}
|
||||
case QueueType::SymbolCodeMetadata:
|
||||
{
|
||||
auto symbol = MemRead<uint64_t>( &item->symbolCodeMetadata.symbol );
|
||||
@ -3163,15 +3145,6 @@ void Profiler::QueueSymbolQuery( uint64_t symbol )
|
||||
#endif
|
||||
}
|
||||
|
||||
void Profiler::QueueCodeLocation( uint64_t ptr )
|
||||
{
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
m_symbolQueue.emplace( SymbolQueueItem { SymbolQueueItemType::CodeLocation, ptr } );
|
||||
#else
|
||||
AckServerQuery();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Profiler::QueueExternalName( uint64_t ptr )
|
||||
{
|
||||
#ifdef TRACY_HAS_SYSTEM_TRACING
|
||||
@ -3228,19 +3201,6 @@ void Profiler::HandleSymbolQueueItem( const SymbolQueueItem& si )
|
||||
TracyLfqCommit;
|
||||
break;
|
||||
}
|
||||
case SymbolQueueItemType::CodeLocation:
|
||||
{
|
||||
const auto sym = DecodeCodeAddress( si.ptr );
|
||||
const uint64_t offset = si.ptr - sym.symAddr;
|
||||
TracyLfqPrepare( QueueType::CodeInformation );
|
||||
MemWrite( &item->codeInformationFat.ptrOffset, offset );
|
||||
MemWrite( &item->codeInformationFat.line, sym.line );
|
||||
MemWrite( &item->codeInformationFat.symAddr, sym.symAddr );
|
||||
MemWrite( &item->codeInformationFat.fileString, (uint64_t)sym.file );
|
||||
MemWrite( &item->codeInformationFat.needFree, (uint8_t)sym.needFree );
|
||||
TracyLfqCommit;
|
||||
break;
|
||||
}
|
||||
#ifdef TRACY_HAS_SYSTEM_TRACING
|
||||
case SymbolQueueItemType::ExternalName:
|
||||
{
|
||||
@ -3404,9 +3364,6 @@ bool Profiler::HandleServerQuery()
|
||||
HandleSymbolCodeQuery( ptr, extra );
|
||||
break;
|
||||
#endif
|
||||
case ServerQueryCodeLocation:
|
||||
QueueCodeLocation( ptr );
|
||||
break;
|
||||
case ServerQuerySourceCode:
|
||||
HandleSourceCodeQuery();
|
||||
break;
|
||||
|
@ -167,7 +167,6 @@ class Profiler
|
||||
{
|
||||
CallstackFrame,
|
||||
SymbolQuery,
|
||||
CodeLocation,
|
||||
ExternalName,
|
||||
KernelCode
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ namespace tracy
|
||||
|
||||
constexpr unsigned Lz4CompressBound( unsigned isize ) { return isize + ( isize / 255 ) + 16; }
|
||||
|
||||
enum : uint32_t { ProtocolVersion = 60 };
|
||||
enum : uint32_t { ProtocolVersion = 61 };
|
||||
enum : uint16_t { BroadcastVersion = 3 };
|
||||
|
||||
using lz4sz_t = uint32_t;
|
||||
@ -53,7 +53,6 @@ enum ServerQuery : uint8_t
|
||||
ServerQueryExternalName,
|
||||
ServerQuerySymbol,
|
||||
ServerQuerySymbolCode,
|
||||
ServerQueryCodeLocation,
|
||||
ServerQuerySourceCode,
|
||||
ServerQueryDataTransfer,
|
||||
ServerQueryDataTransferPart
|
||||
|
@ -61,7 +61,6 @@ enum class QueueType : uint8_t
|
||||
GpuContextName,
|
||||
CallstackFrameSize,
|
||||
SymbolInformation,
|
||||
CodeInformation,
|
||||
ExternalNameMetadata,
|
||||
SymbolCodeMetadata,
|
||||
FiberEnter,
|
||||
@ -546,19 +545,6 @@ struct QueueSymbolInformationFat : public QueueSymbolInformation
|
||||
uint8_t needFree;
|
||||
};
|
||||
|
||||
struct QueueCodeInformation
|
||||
{
|
||||
uint64_t symAddr;
|
||||
uint32_t line;
|
||||
uint64_t ptrOffset;
|
||||
};
|
||||
|
||||
struct QueueCodeInformationFat : public QueueCodeInformation
|
||||
{
|
||||
uint64_t fileString;
|
||||
uint8_t needFree;
|
||||
};
|
||||
|
||||
struct QueueCrashReport
|
||||
{
|
||||
int64_t time;
|
||||
@ -727,8 +713,6 @@ struct QueueItem
|
||||
QueueCallstackFrame callstackFrame;
|
||||
QueueSymbolInformation symbolInformation;
|
||||
QueueSymbolInformationFat symbolInformationFat;
|
||||
QueueCodeInformation codeInformation;
|
||||
QueueCodeInformationFat codeInformationFat;
|
||||
QueueCrashReport crashReport;
|
||||
QueueCrashReportThread crashReportThread;
|
||||
QueueSysTime sysTime;
|
||||
@ -803,7 +787,6 @@ static constexpr size_t QueueDataSize[] = {
|
||||
sizeof( QueueHeader ) + sizeof( QueueGpuContextName ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCallstackFrameSize ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueSymbolInformation ),
|
||||
sizeof( QueueHeader ) + sizeof( QueueCodeInformation ),
|
||||
sizeof( QueueHeader ), // ExternalNameMetadata - not for wire transfer
|
||||
sizeof( QueueHeader ), // SymbolCodeMetadata - not for wire transfer
|
||||
sizeof( QueueHeader ) + sizeof( QueueFiberEnter ),
|
||||
|
@ -171,9 +171,6 @@ void EventDebug( const QueueItem& ev )
|
||||
case QueueType::SymbolInformation:
|
||||
fprintf( f, "ev %i (SymbolInformation)\n", ev.hdr.idx );
|
||||
break;
|
||||
case QueueType::CodeInformation:
|
||||
fprintf( f, "ev %i (CodeInformation)\n", ev.hdr.idx );
|
||||
break;
|
||||
case QueueType::FiberEnter:
|
||||
fprintf( f, "ev %i (FiberEnter)\n", ev.hdr.idx );
|
||||
fprintf( f, "\ttime = %" PRIi64 "\n", ev.fiberEnter.time );
|
||||
|
@ -277,7 +277,6 @@ Worker::Worker( const char* addr, uint16_t port )
|
||||
, m_pendingSourceLocation( 0 )
|
||||
, m_pendingCallstackFrames( 0 )
|
||||
, m_pendingCallstackSubframes( 0 )
|
||||
, m_pendingCodeInformation( 0 )
|
||||
, m_pendingSymbolCode( 0 )
|
||||
, m_callstackFrameStaging( nullptr )
|
||||
, m_traceVersion( CurrentVersion )
|
||||
@ -3201,7 +3200,7 @@ void Worker::Exec()
|
||||
if( m_pendingStrings != 0 || m_pendingThreads != 0 || m_pendingSourceLocation != 0 || m_pendingCallstackFrames != 0 ||
|
||||
m_data.plots.IsPending() || m_pendingCallstackId != 0 || m_pendingExternalNames != 0 ||
|
||||
m_pendingCallstackSubframes != 0 || m_pendingFrameImageData.image != nullptr || !m_pendingSymbols.empty() ||
|
||||
m_pendingSymbolCode != 0 || m_pendingCodeInformation != 0 || !m_serverQueryQueue.empty() || !m_serverQueryQueuePrio.empty() ||
|
||||
m_pendingSymbolCode != 0 || !m_serverQueryQueue.empty() || !m_serverQueryQueuePrio.empty() ||
|
||||
m_pendingSourceLocationPayload != 0 || m_pendingSingleString.ptr != nullptr || m_pendingSecondString.ptr != nullptr ||
|
||||
!m_sourceCodeQuery.empty() || m_pendingFibers != 0 )
|
||||
{
|
||||
@ -3426,7 +3425,6 @@ void Worker::DispatchFailure( const QueueItem& ev, const char*& ptr )
|
||||
ProcessCallstackFrame( ev.callstackFrame, false );
|
||||
break;
|
||||
case QueueType::SymbolInformation:
|
||||
case QueueType::CodeInformation:
|
||||
case QueueType::AckServerQueryNoop:
|
||||
case QueueType::AckSourceCodeNotAvailable:
|
||||
case QueueType::AckSymbolCodeNotAvailable:
|
||||
@ -4915,10 +4913,6 @@ bool Worker::Process( const QueueItem& ev )
|
||||
ProcessSymbolInformation( ev.symbolInformation );
|
||||
m_serverQuerySpaceLeft++;
|
||||
break;
|
||||
case QueueType::CodeInformation:
|
||||
ProcessCodeInformation( ev.codeInformation );
|
||||
m_serverQuerySpaceLeft++;
|
||||
break;
|
||||
case QueueType::Terminate:
|
||||
m_terminate = true;
|
||||
break;
|
||||
@ -6823,67 +6817,6 @@ void Worker::ProcessSymbolInformation( const QueueSymbolInformation& ev )
|
||||
m_pendingSymbols.erase( it );
|
||||
}
|
||||
|
||||
void Worker::ProcessCodeInformation( const QueueCodeInformation& ev )
|
||||
{
|
||||
assert( m_pendingCodeInformation > 0 );
|
||||
m_pendingCodeInformation--;
|
||||
|
||||
const auto idx = GetSingleStringIdx();
|
||||
const uint64_t ptr = ev.symAddr + ev.ptrOffset;
|
||||
|
||||
if( ev.line != 0 )
|
||||
{
|
||||
assert( m_data.codeAddressToLocation.find( ptr ) == m_data.codeAddressToLocation.end() );
|
||||
const auto packed = PackFileLine( idx, ev.line );
|
||||
m_data.codeAddressToLocation.emplace( ptr, packed );
|
||||
|
||||
auto lit = m_data.locationCodeAddressList.find( packed );
|
||||
if( lit == m_data.locationCodeAddressList.end() )
|
||||
{
|
||||
m_data.locationCodeAddressList.emplace( packed, Vector<uint64_t>( ptr ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool needSort = lit->second.back() > ptr;
|
||||
lit->second.push_back( ptr );
|
||||
if( needSort ) pdqsort_branchless( lit->second.begin(), lit->second.end() );
|
||||
}
|
||||
|
||||
StringRef ref( StringRef::Idx, idx );
|
||||
auto cit = m_checkedFileStrings.find( ref );
|
||||
if( cit == m_checkedFileStrings.end() )
|
||||
{
|
||||
uint64_t baseAddr = 0;
|
||||
if( HasSymbolCode( ev.symAddr ) )
|
||||
{
|
||||
baseAddr = ev.symAddr;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto parentAddr = GetSymbolForAddress( ev.symAddr );
|
||||
if( parentAddr != 0 && HasSymbolCode( parentAddr ) )
|
||||
{
|
||||
baseAddr = parentAddr;
|
||||
}
|
||||
}
|
||||
const SymbolData* sym = baseAddr == 0 ? nullptr : GetSymbolData( baseAddr );
|
||||
if( !sym )
|
||||
{
|
||||
CacheSource( ref );
|
||||
}
|
||||
else
|
||||
{
|
||||
CacheSource( ref, sym->imageName );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ev.symAddr != 0 )
|
||||
{
|
||||
assert( m_data.codeSymbolMap.find( ptr ) == m_data.codeSymbolMap.end() );
|
||||
m_data.codeSymbolMap.emplace( ptr, ev.symAddr );
|
||||
}
|
||||
}
|
||||
|
||||
void Worker::ProcessCrashReport( const QueueCrashReport& ev )
|
||||
{
|
||||
CheckString( ev.text );
|
||||
|
@ -737,7 +737,6 @@ private:
|
||||
tracy_force_inline void ProcessCallstackFrameSize( const QueueCallstackFrameSize& ev );
|
||||
tracy_force_inline void ProcessCallstackFrame( const QueueCallstackFrame& ev, bool querySymbols );
|
||||
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 ProcessSysTime( const QueueSysTime& ev );
|
||||
tracy_force_inline void ProcessContextSwitch( const QueueContextSwitch& ev );
|
||||
@ -1000,7 +999,6 @@ private:
|
||||
uint32_t m_pendingSourceLocation;
|
||||
uint32_t m_pendingCallstackFrames;
|
||||
uint8_t m_pendingCallstackSubframes;
|
||||
uint32_t m_pendingCodeInformation;
|
||||
uint32_t m_pendingSymbolCode;
|
||||
|
||||
CallstackFrameData* m_callstackFrameStaging;
|
||||
|
Loading…
x
Reference in New Issue
Block a user