diff --git a/manual/tracy.tex b/manual/tracy.tex index b22de228..82f6a8db 100644 --- a/manual/tracy.tex +++ b/manual/tracy.tex @@ -2631,7 +2631,7 @@ Unlike other profilers, Tracy doesn't include inlined function statistics in the If executable code retrieval was performed, as described in section~\ref{executableretrieval}, and the view has symbol context available, you will be presented with an additional option, \emph{\faMicrochip{}~Show assembly}. Selecting it will replace the source code view with disassembly of the relevant portion of the program that was profiled. -Machine code instructions jumping to a predefined address will display symbol name of the jump target. If the destination location is within the currently displayed symbol an \texttt{->}~arrow will be prepended to the name. Hovering the \faMousePointer{}~mouse pointer over such symbol name will highlight the target location. Clicking on it with the \LMB{}~left mouse button will focus the view on the destination instruction. +Machine code instructions jumping to a predefined address will display symbol name of the jump target. If the destination location is within the currently displayed symbol an \texttt{->}~arrow will be prepended to the name. Hovering the \faMousePointer{}~mouse pointer over such symbol name will highlight the target location. Clicking on it with the \LMB{}~left mouse button will focus the view on the destination instruction, or switch view to the destination symbol. Unlike the source file view, portions of the executable are stored within the captured profile and don't rely on the local disk files being available. diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index b3461dc2..06e82f56 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -277,6 +277,7 @@ void SourceView::Render( const Worker& worker ) TextColoredUnformatted( ImVec4( 1.f, 1.f, 0.2f, 1.f ), ICON_FA_EXCLAMATION_TRIANGLE ); } + uint64_t jumpOut = 0; ImGui::BeginChild( "##sourceView", ImVec2( 0, 0 ), true ); if( m_font ) ImGui::PushFont( m_font ); if( m_showAsm ) @@ -290,7 +291,7 @@ void SourceView::Render( const Worker& worker ) m_targetAddr = 0; ImGui::SetScrollHereY(); } - RenderAsmLine( line, 0, iptotal, worker ); + RenderAsmLine( line, 0, iptotal, worker, jumpOut ); } } else @@ -302,7 +303,7 @@ void SourceView::Render( const Worker& worker ) { for( auto i=clipper.DisplayStart; isecond; - RenderAsmLine( line, ipcnt, iptotal, worker ); + RenderAsmLine( line, ipcnt, iptotal, worker, jumpOut ); } } } @@ -359,6 +360,15 @@ void SourceView::Render( const Worker& worker ) } if( m_font ) ImGui::PopFont(); ImGui::EndChild(); + + if( jumpOut != 0 ) + { + auto sym = worker.GetSymbolData( jumpOut ); + if( sym ) + { + Open( worker.GetString( sym->file ), sym->line, jumpOut, jumpOut, worker ); + } + } } void SourceView::RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint32_t iptotal ) @@ -405,7 +415,7 @@ void SourceView::RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint draw->AddLine( wpos + ImVec2( 0, ty+2 ), wpos + ImVec2( w, ty+2 ), 0x08FFFFFF ); } -void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, const Worker& worker ) +void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, const Worker& worker, uint64_t& jumpOut ) { const auto ty = ImGui::GetFontSize(); auto draw = ImGui::GetWindowDrawList(); @@ -481,6 +491,7 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip else { ImGui::TextDisabled( "[%s+%" PRIu32"]", worker.GetString( sym->name ), offset ); + if( ImGui::IsItemClicked() ) jumpOut = line.jumpAddr; } } } diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index c27b18dd..1628a8d9 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -35,7 +35,7 @@ public: private: void RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint32_t iptotal ); - void RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, const Worker& worker ); + void RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, const Worker& worker, uint64_t& jumpOut ); bool Disassemble( uint64_t symAddr, const Worker& worker );