From e2898843957b5a4cfc750d6794105255bde38a4f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 14 Aug 2022 14:01:01 +0200 Subject: [PATCH] Display jump target even if there's no source location. --- server/TracySourceView.cpp | 66 +++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 26 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index b988918c..53a952d8 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -2622,38 +2622,52 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker { uint32_t srcline; const auto srcidx = worker.GetLocationForAddress( m_jumpPopupAddr, srcline ); - if( srcline != 0 ) + const auto fileName = srcline != 0 ? worker.GetString( srcidx ) : nullptr; + const auto fileColor = srcline != 0 ? GetHsvColor( srcidx.Idx(), 0 ) : 0; + SmallColorBox( fileColor ); + ImGui::SameLine(); + char buf[1024]; + if( fileName ) { - 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 ) ) + } + else + { + uint32_t jumpOffset = 0; + uint64_t jumpBase = worker.GetSymbolForAddress( m_jumpPopupAddr, jumpOffset ); + auto jumpSym = jumpBase == 0 ? worker.GetSymbolData( m_jumpPopupAddr ) : worker.GetSymbolData( jumpBase ); + if( jumpSym ) { - if( SourceFileValid( fileName, worker.GetCaptureTime(), view, worker ) ) + snprintf( buf, 1024, "%s+%" PRIu32, worker.GetString( jumpSym->name ), jumpOffset ); + } + else + { + ImGui::TextDisabled( "0x%" PRIx64, m_jumpPopupAddr ); + } + } + if( ImGui::BeginMenu( buf ) ) + { + if( fileName && SourceFileValid( fileName, worker.GetCaptureTime(), view, worker ) ) + { + m_sourceTooltip.Parse( fileName, worker, view ); + if( !m_sourceTooltip.empty() ) { - m_sourceTooltip.Parse( fileName, worker, view ); - if( !m_sourceTooltip.empty() ) - { - SetFont(); - PrintSourceFragment( m_sourceTooltip, srcline ); - UnsetFont(); - } - } - else - { - TextDisabledUnformatted( "Source not available" ); - } - ImGui::EndMenu(); - if( ImGui::IsItemClicked() ) - { - m_targetAddr = m_jumpPopupAddr; - m_selectedAddresses.clear(); - m_selectedAddresses.emplace( m_jumpPopupAddr ); + SetFont(); + PrintSourceFragment( m_sourceTooltip, srcline ); + UnsetFont(); } } + else + { + TextDisabledUnformatted( "Source not available" ); + } + ImGui::EndMenu(); + if( ImGui::IsItemClicked() ) + { + m_targetAddr = m_jumpPopupAddr; + m_selectedAddresses.clear(); + m_selectedAddresses.emplace( m_jumpPopupAddr ); + } } ImGui::EndMenu(); }