Only change assembly target line when necessary.

This commit is contained in:
Bartosz Taudul 2020-04-08 23:30:42 +02:00
parent 3a1f980a36
commit 450229f5e4
2 changed files with 9 additions and 6 deletions

View File

@ -68,7 +68,7 @@ void SourceView::OpenSymbol( const char* fileName, int line, uint64_t baseAddr,
ParseSource( fileName, &worker ); ParseSource( fileName, &worker );
Disassemble( baseAddr, worker ); Disassemble( baseAddr, worker );
SelectLine( line, &worker ); SelectLine( line, &worker, true, symAddr );
if( !m_lines.empty() ) if( !m_lines.empty() )
{ {
@ -940,14 +940,14 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
if( m_file == fileName ) if( m_file == fileName )
{ {
m_targetLine = srcline; m_targetLine = srcline;
SelectLine( srcline, &worker ); SelectLine( srcline, &worker, false );
m_displayMode = DisplayMixed; m_displayMode = DisplayMixed;
} }
else if( SourceFileValid( fileName, worker.GetCaptureTime() ) ) else if( SourceFileValid( fileName, worker.GetCaptureTime() ) )
{ {
ParseSource( fileName, &worker ); ParseSource( fileName, &worker );
m_targetLine = srcline; m_targetLine = srcline;
SelectLine( srcline, &worker ); SelectLine( srcline, &worker, false );
m_displayMode = DisplayMixed; m_displayMode = DisplayMixed;
} }
} }
@ -1032,7 +1032,7 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
draw->AddLine( wpos + ImVec2( 0, ty+2 ), wpos + ImVec2( w, ty+2 ), 0x08FFFFFF ); draw->AddLine( wpos + ImVec2( 0, ty+2 ), wpos + ImVec2( w, ty+2 ), 0x08FFFFFF );
} }
void SourceView::SelectLine( uint32_t line, const Worker* worker ) void SourceView::SelectLine( uint32_t line, const Worker* worker, bool changeAsmLine, uint64_t targetAddr )
{ {
m_selectedLine = line; m_selectedLine = line;
m_selectedAddresses.clear(); m_selectedAddresses.clear();
@ -1042,7 +1042,10 @@ void SourceView::SelectLine( uint32_t line, const Worker* worker )
if( addresses ) if( addresses )
{ {
const auto& addr = *addresses; const auto& addr = *addresses;
if( !ImGui::GetIO().KeyCtrl ) m_targetAddr = addr[0]; if( changeAsmLine && !ImGui::GetIO().KeyCtrl )
{
m_targetAddr = targetAddr != 0 ? targetAddr : addr[0];
}
for( auto& v : addr ) for( auto& v : addr )
{ {
m_selectedAddresses.emplace( v ); m_selectedAddresses.emplace( v );

View File

@ -66,7 +66,7 @@ private:
void RenderLine( const Line& line, int lineNum, uint32_t ipcnt, uint32_t iptotal, const Worker* worker ); void RenderLine( const Line& line, int lineNum, 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 ); void RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, const Worker& worker, uint64_t& jumpOut );
void SelectLine( uint32_t line, const Worker* worker ); void SelectLine( uint32_t line, const Worker* worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );
ImFont* m_font; ImFont* m_font;
const char* m_file; const char* m_file;