Change GetCallstackJson interface to data ptr + size.

This commit is contained in:
Bartosz Taudul
2026-03-18 00:52:17 +01:00
parent 0905e203e3
commit 145efd63c9
4 changed files with 8 additions and 6 deletions

View File

@@ -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<CallstackFrameId>& 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 );

View File

@@ -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() }
}
};

View File

@@ -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();

View File

@@ -926,7 +926,7 @@ void View::UpdateTitle()
}
}
nlohmann::json View::GetCallstackJson( const VarArray<CallstackFrameId>& 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<CallstackFrameId>& 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 )
{