Cycle through assembly blocks when right-clicking source line.

This commit is contained in:
Bartosz Taudul 2021-07-26 01:21:58 +02:00
parent 55a966f9c6
commit 7304558bdf
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 42 additions and 11 deletions

View File

@ -4118,27 +4118,50 @@ void SourceView::SelectAsmLines( uint32_t file, uint32_t line, const Worker& wor
const auto& addr = *addresses; const auto& addr = *addresses;
if( changeAsmLine ) if( changeAsmLine )
{ {
for( auto& v : addr )
{
if( v >= m_baseAddr && v < m_baseAddr + m_codeLen )
{
m_selectedAddresses.emplace( v );
}
}
if( targetAddr != 0 ) if( targetAddr != 0 )
{ {
m_targetAddr = targetAddr; m_targetAddr = targetAddr;
} }
else else
{ {
for( auto& v : addr ) if( m_asmTarget.file != file || m_asmTarget.line != line )
{ {
if( v >= m_baseAddr && v < m_baseAddr + m_codeLen ) m_asmTarget.file = file;
m_asmTarget.line = line;
m_asmTarget.sel = 0;
m_asmTarget.target.clear();
std::vector<uint64_t> tmp;
tmp.reserve( m_selectedAddresses.size() );
for( auto& v : m_selectedAddresses ) tmp.emplace_back( v );
pdqsort_branchless( tmp.begin(), tmp.end() );
bool first = true;
auto lit = m_asm.begin();
for( auto& v : tmp )
{ {
m_targetAddr = v; const auto prev = lit;
break; while( lit->addr != v ) lit++;
if( first || lit - prev > 1 )
{
first = false;
m_asmTarget.target.emplace_back( v );
}
} }
m_targetAddr = m_asmTarget.target[0];
}
else
{
m_asmTarget.sel = ( m_asmTarget.sel + 1 ) % m_asmTarget.target.size();
m_targetAddr = m_asmTarget.target[m_asmTarget.sel];
} }
}
}
for( auto& v : addr )
{
if( v >= m_baseAddr && v < m_baseAddr + m_codeLen )
{
m_selectedAddresses.emplace( v );
} }
} }
} }

View File

@ -248,6 +248,14 @@ private:
GetWindowCallback m_gwcb; GetWindowCallback m_gwcb;
Tokenizer m_tokenizer; Tokenizer m_tokenizer;
struct
{
uint32_t file = 0;
uint32_t line = 0;
size_t sel;
std::vector<uint64_t> target;
} m_asmTarget;
}; };
} }