diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index c068e351..59feaf44 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -388,7 +388,7 @@ private: void SmallCallstackButton( const char* name, uint32_t callstack, int& idx, bool tooltip = true ); void DrawCallstackCalls( uint32_t callstack, uint16_t limit ) const; void DrawCallstackCalls( const CallstackFrameId* data, size_t size, uint16_t limit ) const; - nlohmann::json GetCallstackJson( const VarArray& cs ); + nlohmann::json GetCallstackJson( const CallstackFrameId* data, size_t size ) const; void SetViewToLastFrames(); int64_t GetZoneChildTime( const ZoneEvent& zone ); int64_t GetZoneChildTime( const GpuEvent& zone ); diff --git a/profiler/src/profiler/TracyView_Callstack.cpp b/profiler/src/profiler/TracyView_Callstack.cpp index b8f439c6..20720dfc 100644 --- a/profiler/src/profiler/TracyView_Callstack.cpp +++ b/profiler/src/profiler/TracyView_Callstack.cpp @@ -108,7 +108,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton ) if( s_config.llm ) { auto Attach = [&]() { - auto json = GetCallstackJson( cs ); + auto json = GetCallstackJson( cs.data(), cs.size() ); if( hasCrashed ) { json["crashed"] = true; @@ -214,7 +214,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton ) }, { { "role", "user" }, - { "content", GetCallstackJson( cs )["frames"].dump() } + { "content", GetCallstackJson( cs.data(), cs.size() )["frames"].dump() } } }; diff --git a/profiler/src/profiler/TracyView_Samples.cpp b/profiler/src/profiler/TracyView_Samples.cpp index 8837403f..b829f35d 100644 --- a/profiler/src/profiler/TracyView_Samples.cpp +++ b/profiler/src/profiler/TracyView_Samples.cpp @@ -964,7 +964,7 @@ void View::DrawSampleParents() ImGui::SameLine(); if( ImGui::SmallButton( ICON_FA_ROBOT ) ) { - AddLlmAttachment( GetCallstackJson( cs ) ); + AddLlmAttachment( GetCallstackJson( cs.data(), cs.size() ) ); } } ImGui::SameLine(); diff --git a/profiler/src/profiler/TracyView_Utility.cpp b/profiler/src/profiler/TracyView_Utility.cpp index 37dbf982..a7782486 100644 --- a/profiler/src/profiler/TracyView_Utility.cpp +++ b/profiler/src/profiler/TracyView_Utility.cpp @@ -926,7 +926,7 @@ void View::UpdateTitle() } } -nlohmann::json View::GetCallstackJson( const VarArray& cs ) +nlohmann::json View::GetCallstackJson( const CallstackFrameId* data, size_t size ) const { nlohmann::json json = { { "type", "callstack" }, @@ -934,9 +934,11 @@ nlohmann::json View::GetCallstackJson( const VarArray& cs ) }; auto& frames = json["frames"]; + auto end = data + size; int fidx = 0; - for( auto& entry : cs ) + while( data < end ) { + auto& entry = *data++; auto frameData = m_worker.GetCallstackFrame( entry ); if( !frameData ) {