mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Make it possible to store multiple frames at single frame address.
This commit is contained in:
@@ -37,9 +37,9 @@ void InitCallstack()
|
||||
SymSetOptions( SYMOPT_LOAD_LINES );
|
||||
}
|
||||
|
||||
CallstackEntry DecodeCallstackPtr( uint64_t ptr )
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||
{
|
||||
CallstackEntry ret;
|
||||
static CallstackEntry ret;
|
||||
|
||||
const auto proc = GetCurrentProcess();
|
||||
|
||||
@@ -82,7 +82,7 @@ CallstackEntry DecodeCallstackPtr( uint64_t ptr )
|
||||
|
||||
ret.file = file;
|
||||
|
||||
return ret;
|
||||
return { &ret, 1 };
|
||||
}
|
||||
|
||||
#elif TRACY_HAS_CALLSTACK >= 2
|
||||
@@ -219,12 +219,12 @@ static void CallstackErrorCb( void* data, const char* msg, int errnum )
|
||||
cb_num = 1;
|
||||
}
|
||||
|
||||
CallstackEntry DecodeCallstackPtr( uint64_t ptr )
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr )
|
||||
{
|
||||
cb_num = 0;
|
||||
backtrace_pcinfo( cb_bts, ptr, CallstackDataCb, CallstackErrorCb, nullptr );
|
||||
assert( cb_num == 1 );
|
||||
return cb_data[0];
|
||||
return { cb_data, cb_num };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,13 @@ struct CallstackEntry
|
||||
uint32_t line;
|
||||
};
|
||||
|
||||
CallstackEntry DecodeCallstackPtr( uint64_t ptr );
|
||||
struct CallstackEntryData
|
||||
{
|
||||
const CallstackEntry* data;
|
||||
uint8_t size;
|
||||
};
|
||||
|
||||
CallstackEntryData DecodeCallstackPtr( uint64_t ptr );
|
||||
void InitCallstack();
|
||||
|
||||
#if TRACY_HAS_CALLSTACK == 1
|
||||
|
||||
+32
-16
@@ -1487,22 +1487,35 @@ void Profiler::SendCallstackPayload( uint64_t _ptr )
|
||||
void Profiler::SendCallstackFrame( uint64_t ptr )
|
||||
{
|
||||
#ifdef TRACY_HAS_CALLSTACK
|
||||
auto frame = DecodeCallstackPtr( ptr );
|
||||
const auto frameData = DecodeCallstackPtr( ptr );
|
||||
|
||||
SendString( uint64_t( frame.name ), frame.name, QueueType::CustomStringData );
|
||||
SendString( uint64_t( frame.file ), frame.file, QueueType::CustomStringData );
|
||||
{
|
||||
QueueItem item;
|
||||
MemWrite( &item.hdr.type, QueueType::CallstackFrameSize );
|
||||
MemWrite( &item.callstackFrameSize.ptr, ptr );
|
||||
MemWrite( &item.callstackFrameSize.size, frameData.size );
|
||||
|
||||
QueueItem item;
|
||||
MemWrite( &item.hdr.type, QueueType::CallstackFrame );
|
||||
MemWrite( &item.callstackFrame.ptr, ptr );
|
||||
MemWrite( &item.callstackFrame.name, (uint64_t)frame.name );
|
||||
MemWrite( &item.callstackFrame.file, (uint64_t)frame.file );
|
||||
MemWrite( &item.callstackFrame.line, frame.line );
|
||||
AppendData( &item, QueueDataSize[(int)QueueType::CallstackFrameSize] );
|
||||
}
|
||||
|
||||
AppendData( &item, QueueDataSize[(int)QueueType::CallstackFrame] );
|
||||
for( uint8_t i=0; i<frameData.size; i++ )
|
||||
{
|
||||
const auto& frame = frameData.data[i];
|
||||
|
||||
tracy_free( (void*)frame.name );
|
||||
tracy_free( (void*)frame.file );
|
||||
SendString( uint64_t( frame.name ), frame.name, QueueType::CustomStringData );
|
||||
SendString( uint64_t( frame.file ), frame.file, QueueType::CustomStringData );
|
||||
|
||||
QueueItem item;
|
||||
MemWrite( &item.hdr.type, QueueType::CallstackFrame );
|
||||
MemWrite( &item.callstackFrame.name, (uint64_t)frame.name );
|
||||
MemWrite( &item.callstackFrame.file, (uint64_t)frame.file );
|
||||
MemWrite( &item.callstackFrame.line, frame.line );
|
||||
|
||||
AppendData( &item, QueueDataSize[(int)QueueType::CallstackFrame] );
|
||||
|
||||
tracy_free( (void*)frame.name );
|
||||
tracy_free( (void*)frame.file );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1720,10 +1733,13 @@ void Profiler::SendCallstack( int depth, uint64_t thread, const char* skipBefore
|
||||
uintptr_t i;
|
||||
for( i=0; i<sz; i++ )
|
||||
{
|
||||
auto frame = DecodeCallstackPtr( uint64_t( data[i] ) );
|
||||
const bool found = strcmp( frame.name, skipBefore ) == 0;
|
||||
tracy_free( (void*)frame.name );
|
||||
tracy_free( (void*)frame.file );
|
||||
auto frameData = DecodeCallstackPtr( uint64_t( data[i] ) );
|
||||
const bool found = strcmp( frameData.data[0].name, skipBefore ) == 0;
|
||||
for( uint8_t j=0; j<frameData.size; j++ )
|
||||
{
|
||||
tracy_free( (void*)frameData.data[j].name );
|
||||
tracy_free( (void*)frameData.data[j].file );
|
||||
}
|
||||
if( found )
|
||||
{
|
||||
i++;
|
||||
|
||||
Reference in New Issue
Block a user