From 205983e87fd0f04dd7a1ec6b2fef98f0d13254ee Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 11 May 2026 21:48:00 +0200 Subject: [PATCH] Recalculate AddrStatData in AttachRangeToLlm. For consistency, always provide the OS-level sampling data, not the hardware samples. Always disable inline propagation, which is intended as a local area help for a human. It does not make sense in context of an llm. --- profiler/src/profiler/TracySourceView.cpp | 29 ++++++++++++++++++++--- profiler/src/profiler/TracySourceView.hpp | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/profiler/src/profiler/TracySourceView.cpp b/profiler/src/profiler/TracySourceView.cpp index 8fe03c90..063c5ecd 100644 --- a/profiler/src/profiler/TracySourceView.cpp +++ b/profiler/src/profiler/TracySourceView.cpp @@ -1984,7 +1984,7 @@ std::tuple SourceView::GetJumpRange( const AsmJumpData& jump ) return std::make_tuple( minIdx, maxIdx ); } -void SourceView::AttachRangeToLlm( size_t start, size_t stop, Worker& worker, View& view, const AddrStatData& as ) +void SourceView::AttachRangeToLlm( size_t start, size_t stop, Worker& worker, View& view ) { auto sym = worker.GetSymbolData( m_symAddr ); assert( sym ); @@ -2008,6 +2008,29 @@ void SourceView::AttachRangeToLlm( size_t start, size_t stop, Worker& worker, Vi symName = worker.GetString( sym->name ); } + const bool limitView = view.m_statRange.active; + AddrStatData as; + if( m_calcInlineStats ) + { + GatherIpStats( m_symAddr, as, worker, limitView, view, m_source.filename(), false ); + GatherAdditionalIpStats( m_symAddr, as, worker, limitView, view, m_source.filename(), false ); + } + else + { + GatherIpStats( m_baseAddr, as, worker, limitView, view, m_source.filename(), false ); + auto iptr = worker.GetInlineSymbolList( m_baseAddr, m_codeLen ); + if( iptr ) + { + const auto symEnd = m_baseAddr + m_codeLen; + while( *iptr < symEnd ) + { + GatherIpStats( *iptr, as, worker, limitView, view, m_source.filename(), false ); + iptr++; + } + } + GatherAdditionalIpStats( m_baseAddr, as, worker, limitView, view, m_source.filename(), false ); + } + nlohmann::json json = { { "type", "assembly" }, { "symbol", symName }, @@ -2140,7 +2163,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker ImGui::SameLine(); if( ImGui::SmallButton( ICON_FA_ROBOT ) ) { - AttachRangeToLlm( 0, m_asm.size(), worker, view, as ); + AttachRangeToLlm( 0, m_asm.size(), worker, view ); } } @@ -2408,7 +2431,7 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker if( ImGui::MenuItem( ICON_FA_ROBOT " Attach jump range in chat" ) ) { auto [start, stop] = GetJumpRange( it->second ); - AttachRangeToLlm( start, stop, worker, view, as ); + AttachRangeToLlm( start, stop, worker, view ); } } if( needSeparator ) ImGui::Separator(); diff --git a/profiler/src/profiler/TracySourceView.hpp b/profiler/src/profiler/TracySourceView.hpp index c4b17c9a..bf7e62f7 100644 --- a/profiler/src/profiler/TracySourceView.hpp +++ b/profiler/src/profiler/TracySourceView.hpp @@ -114,7 +114,7 @@ private: tracy_force_inline float CalcJumpSeparation( float scale ); std::tuple GetJumpRange( const AsmJumpData& jump ); - void AttachRangeToLlm( size_t start, size_t stop, Worker& worker, View& view, const AddrStatData& as ); + void AttachRangeToLlm( size_t start, size_t stop, Worker& worker, View& view ); #ifndef TRACY_NO_FILESELECTOR void Save( const Worker& worker, size_t start = 0, size_t stop = std::numeric_limits::max() );