mirror of
https://github.com/wolfpld/tracy.git
synced 2026-01-18 17:11:26 +01:00
Allow attaching symbol source code to LLM, with execution costs.
This commit is contained in:
@@ -1865,7 +1865,7 @@ static uint32_t GetGoodnessColor( float inRatio )
|
||||
return GoodnessColor[ratio];
|
||||
}
|
||||
|
||||
void SourceView::RenderSymbolSourceView( const AddrStatData& as, Worker& worker, const View& view, bool hasInlines )
|
||||
void SourceView::RenderSymbolSourceView( const AddrStatData& as, Worker& worker, View& view, bool hasInlines )
|
||||
{
|
||||
const auto scale = GetScale();
|
||||
if( hasInlines && !m_calcInlineStats && ( ( as.ipTotalAsm.local + as.ipTotalAsm.ext ) > 0 || ( view.m_statRange.active && worker.GetSamplesForSymbol( m_baseAddr ) ) ) )
|
||||
@@ -1929,6 +1929,43 @@ void SourceView::RenderSymbolSourceView( const AddrStatData& as, Worker& worker,
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
}
|
||||
if( s_config.llm )
|
||||
{
|
||||
ImGui::SameLine();
|
||||
if( ImGui::SmallButton( ICON_FA_ROBOT "##src" ) )
|
||||
{
|
||||
nlohmann::json json = {
|
||||
{ "type", "source", },
|
||||
{ "file", m_source.filename() },
|
||||
{ "code", nlohmann::json::array() }
|
||||
};
|
||||
|
||||
auto& code = json["code"];
|
||||
auto& lines = m_source.get();
|
||||
|
||||
int idx = 1;
|
||||
for( auto& line : lines )
|
||||
{
|
||||
nlohmann::json l = {
|
||||
{ "line", idx },
|
||||
{ "text", std::string( line.begin, line.end ) }
|
||||
};
|
||||
|
||||
auto it = as.ipCountSrc.find( idx );
|
||||
if( it != as.ipCountSrc.end() )
|
||||
{
|
||||
char buf[32];
|
||||
snprintf( buf, sizeof(buf), "%.4f%%", 100.f * it->second.local / as.ipTotalSrc.local );
|
||||
l["cost"] = buf;
|
||||
}
|
||||
|
||||
code.push_back( l );
|
||||
idx++;
|
||||
}
|
||||
|
||||
view.AddLlmAttachment( json );
|
||||
}
|
||||
}
|
||||
ImGui::SameLine();
|
||||
TextDisabledUnformatted( ICON_FA_FILE " File:" );
|
||||
ImGui::SameLine();
|
||||
|
||||
@@ -183,7 +183,7 @@ private:
|
||||
void RenderSimpleSourceView();
|
||||
void RenderSymbolView( Worker& worker, View& view );
|
||||
|
||||
void RenderSymbolSourceView( const AddrStatData& as, Worker& worker, const View& view, bool hasInlines );
|
||||
void RenderSymbolSourceView( const AddrStatData& as, Worker& worker, View& view, bool hasInlines );
|
||||
uint64_t RenderSymbolAsmView( const AddrStatData& as, Worker& worker, View& view );
|
||||
|
||||
void RenderLine( const Tokenizer::Line& line, int lineNum, const AddrStat& ipcnt, const AddrStatData& as, Worker* worker, const View* view );
|
||||
|
||||
Reference in New Issue
Block a user