Add local call stack navigation menu to asm lines.

This commit is contained in:
Bartosz Taudul 2022-10-14 17:37:06 +02:00
parent 0f283d5825
commit a226446a92
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 65 additions and 3 deletions

View File

@ -2807,6 +2807,60 @@ uint64_t SourceView::RenderSymbolAsmView( const AddrStatData& as, Worker& worker
}
ImGui::EndPopup();
}
if( ImGui::BeginPopup( "localCallstackPopup" ) )
{
const auto lcs = m_localCallstackPopup;
for( uint8_t i=0; i<lcs->size; i++ )
{
ImGui::PushID( i );
ImGui::TextDisabled( "%i.", i+1 );
ImGui::SameLine();
const auto symName = worker.GetString( lcs->data[i].name );
const auto normalized = view.GetShortenName() != ShortenName::Never ? ShortenZoneName( ShortenName::OnlyNormalize, symName ) : symName;
const auto fn = worker.GetString( lcs->data[i].file );
const auto srcline = lcs->data[i].line;
if( ImGui::Selectable( normalized ) )
{
m_targetLine = srcline;
if( m_source.filename() == fn )
{
SelectLine( srcline, &worker, false );
m_displayMode = DisplayMixed;
}
else if( SourceFileValid( fn, worker.GetCaptureTime(), view, worker ) )
{
ParseSource( fn, worker, view );
SelectLine( srcline, &worker, false );
SelectViewMode();
}
}
if( ImGui::IsItemHovered() )
{
ImGui::BeginTooltip();
if( SourceFileValid( fn, worker.GetCaptureTime(), view, worker ) )
{
m_sourceTooltip.Parse( fn, worker, view );
if( !m_sourceTooltip.empty() )
{
ImGui::PushFont( m_smallFont );
ImGui::TextDisabled( "%s:%i", fn, srcline );
ImGui::PopFont();
ImGui::Separator();
SetFont();
PrintSourceFragment( m_sourceTooltip, srcline );
UnsetFont();
}
}
else
{
TextDisabledUnformatted( "Source not available" );
}
ImGui::EndTooltip();
}
ImGui::PopID();
}
ImGui::EndPopup();
}
SetFont();
}
@ -3790,18 +3844,17 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
}
ImGui::EndTooltip();
SetFont();
if( ImGui::IsItemClicked( 0 ) || ImGui::IsItemClicked( 1 ) )
if( ImGui::IsItemClicked( 0 ) )
{
m_targetLine = srcline;
if( m_source.filename() == fileName )
{
if( ImGui::IsMouseClicked( 0 ) ) m_targetLine = srcline;
SelectLine( srcline, &worker, false );
m_displayMode = DisplayMixed;
}
else if( SourceFileValid( fileName, worker.GetCaptureTime(), view, worker ) )
{
ParseSource( fileName, worker, view );
m_targetLine = srcline;
SelectLine( srcline, &worker, false );
SelectViewMode();
}
@ -3813,6 +3866,13 @@ void SourceView::RenderAsmLine( AsmLine& line, const AddrStat& ipcnt, const Addr
m_hoveredLine = srcline;
m_hoveredSource = srcidx.Idx();
}
if( frame && frame->data[0].name.Active() && ImGui::IsItemClicked( 1 ) )
{
ImGui::OpenPopup( "localCallstackPopup" );
m_localCallstackPopup = frame;
m_selectedAddresses.clear();
m_selectedAddresses.emplace( line.addr );
}
}
}
else

View File

@ -21,6 +21,7 @@ namespace tracy
class View;
class Worker;
struct CallstackFrameData;
class SourceView
{
@ -234,6 +235,7 @@ private:
uint8_t m_maxAsmBytes;
bool m_atnt;
uint64_t m_jumpPopupAddr;
const CallstackFrameData* m_localCallstackPopup;
bool m_hwSamples, m_hwSamplesRelative;
bool m_childCalls;
bool m_childCallList;