From 7893a8363359d835043ec2cdc07647f8db0989ef Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Wed, 6 Apr 2022 02:01:29 +0200 Subject: [PATCH] Display jump arrow context (src and target source code). --- server/TracySourceView.cpp | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 23091cc6..68e6752f 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -2518,7 +2518,77 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker Save( worker, minIdx, maxIdx ); ImGui::CloseCurrentPopup(); } + ImGui::Separator(); #endif + if( ImGui::BeginMenu( "Sources" ) ) + { + for( auto& src : it->second.source ) + { + uint32_t srcline; + const auto srcidx = worker.GetLocationForAddress( src, srcline ); + if( srcline == 0 ) + { + SmallColorBox( 0 ); + ImGui::SameLine(); + ImGui::TextDisabled( "0x%" PRIx64, src ); + } + else + { + const auto fileName = worker.GetString( srcidx ); + const auto fileColor = GetHsvColor( srcidx.Idx(), 0 ); + SmallColorBox( fileColor ); + ImGui::SameLine(); + char buf[1024]; + snprintf( buf, 1024, "%s:%i", fileName, srcline ); + ImGui::PushID( src ); + if( ImGui::BeginMenu( buf ) ) + { + if( SourceFileValid( fileName, worker.GetCaptureTime(), view, worker ) ) + { + m_sourceTooltip.Parse( fileName, worker, view ); + if( !m_sourceTooltip.empty() ) + { + SetFont(); + PrintSourceFragment( m_sourceTooltip, srcline ); + UnsetFont(); + } + } + ImGui::EndMenu(); + } + ImGui::PopID(); + } + } + ImGui::EndMenu(); + } + if( ImGui::BeginMenu( "Target" ) ) + { + uint32_t srcline; + const auto srcidx = worker.GetLocationForAddress( m_jumpPopupAddr, srcline ); + if( srcline != 0 ) + { + const auto fileName = worker.GetString( srcidx ); + const auto fileColor = GetHsvColor( srcidx.Idx(), 0 ); + SmallColorBox( fileColor ); + ImGui::SameLine(); + char buf[1024]; + snprintf( buf, 1024, "%s:%i", fileName, srcline ); + if( ImGui::BeginMenu( buf ) ) + { + if( SourceFileValid( fileName, worker.GetCaptureTime(), view, worker ) ) + { + m_sourceTooltip.Parse( fileName, worker, view ); + if( !m_sourceTooltip.empty() ) + { + SetFont(); + PrintSourceFragment( m_sourceTooltip, srcline ); + UnsetFont(); + } + } + ImGui::EndMenu(); + } + } + ImGui::EndMenu(); + } ImGui::EndPopup(); } SetFont();