1
0
mirror of https://github.com/wolfpld/tracy synced 2025-04-29 12:23:53 +00:00

Tighter assembly address display.

This commit is contained in:
Bartosz Taudul 2020-04-09 01:31:27 +02:00
parent 436bd6b9ff
commit bae08c27c8
2 changed files with 16 additions and 9 deletions

View File

@ -661,6 +661,13 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
ImGui::BeginChild( "##asmView", ImVec2( 0, 0 ), true, ImGuiWindowFlags_NoMove ); ImGui::BeginChild( "##asmView", ImVec2( 0, 0 ), true, ImGuiWindowFlags_NoMove );
if( m_font ) ImGui::PushFont( m_font ); if( m_font ) ImGui::PushFont( m_font );
int maxAddrLen;
{
char tmp[32];
sprintf( tmp, "%" PRIx64, m_baseAddr + m_codeLen );
maxAddrLen = strlen( tmp );
}
uint64_t jumpOut = 0; uint64_t jumpOut = 0;
if( m_targetAddr != 0 ) if( m_targetAddr != 0 )
{ {
@ -671,7 +678,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
m_targetAddr = 0; m_targetAddr = 0;
ImGui::SetScrollHereY(); ImGui::SetScrollHereY();
} }
RenderAsmLine( line, 0, iptotal, worker, jumpOut ); RenderAsmLine( line, 0, iptotal, worker, jumpOut, maxAddrLen );
} }
} }
else else
@ -688,7 +695,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
{ {
for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ ) for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ )
{ {
RenderAsmLine( m_asm[i], 0, 0, worker, jumpOut ); RenderAsmLine( m_asm[i], 0, 0, worker, jumpOut, maxAddrLen );
insList.emplace_back( m_asm[i].addr ); insList.emplace_back( m_asm[i].addr );
} }
} }
@ -699,7 +706,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
auto& line = m_asm[i]; auto& line = m_asm[i];
auto it = ipcount.find( line.addr ); auto it = ipcount.find( line.addr );
const auto ipcnt = it == ipcount.end() ? 0 : it->second; const auto ipcnt = it == ipcount.end() ? 0 : it->second;
RenderAsmLine( line, ipcnt, iptotal, worker, jumpOut ); RenderAsmLine( line, ipcnt, iptotal, worker, jumpOut, maxAddrLen );
insList.emplace_back( line.addr ); insList.emplace_back( line.addr );
} }
} }
@ -709,7 +716,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
const auto ts = ImGui::CalcTextSize( " " ); const auto ts = ImGui::CalcTextSize( " " );
const auto th2 = floor( ts.y / 2 ); const auto th2 = floor( ts.y / 2 );
const auto th4 = floor( ts.y / 4 ); const auto th4 = floor( ts.y / 4 );
const auto xoff = ( iptotal == 0 ? 0 : ( 7 * ts.x + ts.y ) ) + 19 * ts.x + ( m_asmShowSourceLocation ? 36 * ts.x : 0 ); const auto xoff = ( iptotal == 0 ? 0 : ( 7 * ts.x + ts.y ) ) + (3+maxAddrLen) * ts.x + ( m_asmShowSourceLocation ? 36 * ts.x : 0 );
const auto minAddr = m_asm[clipper.DisplayStart].addr; const auto minAddr = m_asm[clipper.DisplayStart].addr;
const auto maxAddr = m_asm[clipper.DisplayEnd-1].addr; const auto maxAddr = m_asm[clipper.DisplayEnd-1].addr;
const auto mjl = m_maxJumpLevel; const auto mjl = m_maxJumpLevel;
@ -890,7 +897,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 ); 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, uint64_t& jumpOut ) void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t iptotal, const Worker& worker, uint64_t& jumpOut, int maxAddrLen )
{ {
const auto ty = ImGui::GetFontSize(); const auto ty = ImGui::GetFontSize();
auto draw = ImGui::GetWindowDrawList(); auto draw = ImGui::GetWindowDrawList();
@ -929,8 +936,8 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
sprintf( buf, "%" PRIx64, line.addr ); sprintf( buf, "%" PRIx64, line.addr );
} }
const auto asz = strlen( buf ); const auto asz = strlen( buf );
memset( buf+asz, ' ', 16-asz ); memset( buf+asz, ' ', maxAddrLen-asz );
buf[16] = '\0'; buf[maxAddrLen] = '\0';
TextDisabledUnformatted( buf ); TextDisabledUnformatted( buf );
bool lineHovered = false; bool lineHovered = false;
@ -1011,7 +1018,7 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
const auto th4 = floor( ts.y / 4 ); const auto th4 = floor( ts.y / 4 );
const auto& mjl = m_maxJumpLevel; const auto& mjl = m_maxJumpLevel;
const auto col = GetHsvColor( line.jumpAddr, 6 ); const auto col = GetHsvColor( line.jumpAddr, 6 );
const auto xoff = ( iptotal == 0 ? 0 : ( 7 * ts.x + ts.y ) ) + 19 * ts.x + ( m_asmShowSourceLocation ? 36 * ts.x : 0 ); const auto xoff = ( iptotal == 0 ? 0 : ( 7 * ts.x + ts.y ) ) + (3+maxAddrLen) * ts.x + ( m_asmShowSourceLocation ? 36 * ts.x : 0 );
draw->AddLine( wpos + ImVec2( xoff + JumpSeparation * mjl + th2, th2 ), wpos + ImVec2( xoff + JumpSeparation * mjl + th2 + JumpArrow / 2, th2 ), col ); draw->AddLine( wpos + ImVec2( xoff + JumpSeparation * mjl + th2, th2 ), wpos + ImVec2( xoff + JumpSeparation * mjl + th2 + JumpArrow / 2, th2 ), col );
draw->AddLine( wpos + ImVec2( xoff + JumpSeparation * mjl + th2, th2 ), wpos + ImVec2( xoff + JumpSeparation * mjl + th2 + th4, th2 - th4 ), col ); draw->AddLine( wpos + ImVec2( xoff + JumpSeparation * mjl + th2, th2 ), wpos + ImVec2( xoff + JumpSeparation * mjl + th2 + th4, th2 - th4 ), col );

View File

@ -64,7 +64,7 @@ private:
uint64_t RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, const Worker& worker ); uint64_t RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, const Worker& worker );
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, int maxAddrLen );
void SelectLine( uint32_t line, const Worker* worker, bool changeAsmLine = true, uint64_t targetAddr = 0 ); 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 SelectAsmLines( uint32_t file, uint32_t line, const Worker& worker, bool changeAsmLine = true, uint64_t targetAddr = 0 );