diff --git a/TracyLua.hpp b/TracyLua.hpp index ed23abf5..52d9e4e4 100644 --- a/TracyLua.hpp +++ b/TracyLua.hpp @@ -182,8 +182,9 @@ static inline void SendLuaCallstack( lua_State* L, uint32_t depth ) auto& tail = token->get_tail_index(); auto item = token->enqueue_begin( magic ); MemWrite( &item->hdr.type, QueueType::CallstackAlloc ); - MemWrite( &item->callstack.ptr, (uint64_t)ptr ); - MemWrite( &item->callstack.thread, GetThreadHandle() ); + MemWrite( &item->callstackAlloc.ptr, (uint64_t)ptr ); + MemWrite( &item->callstackAlloc.nativePtr, (uint64_t)Callstack( depth ) ); + MemWrite( &item->callstackAlloc.thread, GetThreadHandle() ); tail.store( magic + 1, std::memory_order_release ); } diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 3b4d847b..5128cc67 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -1325,10 +1325,15 @@ static void FreeAssociatedMemory( const QueueItem& item ) tracy_free( (void*)ptr ); break; case QueueType::Callstack: - case QueueType::CallstackAlloc: ptr = MemRead( &item.callstack.ptr ); tracy_free( (void*)ptr ); break; + case QueueType::CallstackAlloc: + ptr = MemRead( &item.callstackAlloc.ptr ); + tracy_free( (void*)ptr ); + ptr = MemRead( &item.callstackAlloc.nativePtr ); + tracy_free( (void*)ptr ); + break; default: assert( false ); break; @@ -1404,9 +1409,12 @@ Profiler::DequeueStatus Profiler::Dequeue( moodycamel::ConsumerToken& token ) tracy_free( (void*)ptr ); break; case QueueType::CallstackAlloc: - ptr = MemRead( &item->callstack.ptr ); + ptr = MemRead( &item->callstackAlloc.ptr ); SendCallstackAlloc( ptr ); tracy_free( (void*)ptr ); + ptr = MemRead( &item->callstackAlloc.nativePtr ); + SendCallstackPayload( ptr ); + tracy_free( (void*)ptr ); break; default: assert( false ); diff --git a/common/TracyProtocol.hpp b/common/TracyProtocol.hpp index 2c450005..2a437d27 100644 --- a/common/TracyProtocol.hpp +++ b/common/TracyProtocol.hpp @@ -9,7 +9,7 @@ namespace tracy { -enum : uint32_t { ProtocolVersion = 4 }; +enum : uint32_t { ProtocolVersion = 5 }; using lz4sz_t = uint32_t; diff --git a/common/TracyQueue.hpp b/common/TracyQueue.hpp index bcc15efe..148d47b9 100644 --- a/common/TracyQueue.hpp +++ b/common/TracyQueue.hpp @@ -249,6 +249,13 @@ struct QueueCallstack uint64_t thread; }; +struct QueueCallstackAlloc +{ + uint64_t ptr; + uint64_t nativePtr; + uint64_t thread; +}; + struct QueueCallstackFrameSize { uint64_t ptr; @@ -312,6 +319,7 @@ struct QueueItem QueueMemFree memFree; QueueCallstackMemory callstackMemory; QueueCallstack callstack; + QueueCallstackAlloc callstackAlloc; QueueCallstackFrameSize callstackFrameSize; QueueCallstackFrame callstackFrame; QueueCrashReport crashReport; @@ -331,7 +339,7 @@ static const size_t QueueDataSize[] = { sizeof( QueueHeader ) + sizeof( QueueZoneBegin ), // allocated source location, callstack sizeof( QueueHeader ) + sizeof( QueueCallstackMemory ), sizeof( QueueHeader ) + sizeof( QueueCallstack ), - sizeof( QueueHeader ) + sizeof( QueueCallstack ), // callstack alloc + sizeof( QueueHeader ) + sizeof( QueueCallstackAlloc ), // above items must be first sizeof( QueueHeader ), // terminate sizeof( QueueHeader ), // keep alive