Highlight asm lines for hovered source line.

This commit is contained in:
Bartosz Taudul 2020-04-09 21:57:28 +02:00
parent 1e965edb54
commit 0791871955
2 changed files with 28 additions and 1 deletions

View File

@ -617,6 +617,7 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
ImGui::BeginChild( "##sourceView", ImVec2( 0, 0 ), true, ImGuiWindowFlags_NoMove );
if( m_font ) ImGui::PushFont( m_font );
m_selectedAddressesHover.clear();
if( m_targetLine != 0 )
{
int lineNum = 1;
@ -910,6 +911,10 @@ void SourceView::RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint
m_displayMode = DisplayMixed;
SelectLine( lineNum, worker );
}
else
{
SelectAsmLinesHover( m_fileStringIdx, lineNum, *worker );
}
}
draw->AddLine( wpos + ImVec2( 0, ty+2 ), wpos + ImVec2( w, ty+2 ), 0x08FFFFFF );
@ -921,7 +926,11 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
auto draw = ImGui::GetWindowDrawList();
const auto w = ImGui::GetWindowWidth();
const auto wpos = ImGui::GetCursorScreenPos();
if( m_selectedAddresses.find( line.addr ) != m_selectedAddresses.end() )
if( m_selectedAddressesHover.find( line.addr ) != m_selectedAddressesHover.end() )
{
draw->AddRectFilled( wpos, wpos + ImVec2( w, ty+1 ), 0x22FFFFFF );
}
else if( m_selectedAddresses.find( line.addr ) != m_selectedAddresses.end() )
{
draw->AddRectFilled( wpos, wpos + ImVec2( w, ty+1 ), 0xFF333322 );
}
@ -1137,4 +1146,20 @@ void SourceView::SelectAsmLines( uint32_t file, uint32_t line, const Worker& wor
}
}
void SourceView::SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker& worker )
{
assert( m_selectedAddressesHover.empty() );
auto addresses = worker.GetAddressesForLocation( file, line );
if( addresses )
{
for( auto& v : *addresses )
{
if( v >= m_baseAddr && v < m_baseAddr + m_codeLen )
{
m_selectedAddressesHover.emplace( v );
}
}
}
}
}

View File

@ -68,6 +68,7 @@ private:
void SelectLine( uint32_t line, const Worker* worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
void SelectAsmLines( uint32_t file, uint32_t line, const Worker& worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
void SelectAsmLinesHover( uint32_t file, uint32_t line, const Worker& worker );
ImFont* m_font;
const char* m_file;
@ -95,6 +96,7 @@ private:
unordered_flat_map<uint32_t, uint32_t> m_sourceFiles;
unordered_flat_set<uint64_t> m_selectedAddresses;
unordered_flat_set<uint64_t> m_selectedAddressesHover;
uint32_t m_maxLine;
int m_maxMnemonicLen;