mirror of
https://github.com/wolfpld/tracy
synced 2025-04-29 12:23:53 +00:00
Tighten mnemonic display.
This commit is contained in:
parent
bae08c27c8
commit
6dd765c101
@ -172,6 +172,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
|
|||||||
size_t cnt = cs_disasm( handle, (const uint8_t*)code, len, symAddr, 0, &insn );
|
size_t cnt = cs_disasm( handle, (const uint8_t*)code, len, symAddr, 0, &insn );
|
||||||
if( cnt > 0 )
|
if( cnt > 0 )
|
||||||
{
|
{
|
||||||
|
int mLenMax = 0;
|
||||||
m_asm.reserve( cnt );
|
m_asm.reserve( cnt );
|
||||||
for( size_t i=0; i<cnt; i++ )
|
for( size_t i=0; i<cnt; i++ )
|
||||||
{
|
{
|
||||||
@ -236,6 +237,8 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_asm.emplace_back( AsmLine { op.address, jumpAddr, op.mnemonic, op.op_str } );
|
m_asm.emplace_back( AsmLine { op.address, jumpAddr, op.mnemonic, op.op_str } );
|
||||||
|
const auto mLen = strlen( op.mnemonic );
|
||||||
|
if( mLen > mLenMax ) mLenMax = mLen;
|
||||||
|
|
||||||
uint32_t srcline;
|
uint32_t srcline;
|
||||||
const auto srcidx = worker.GetLocationForAddress( op.address, srcline );
|
const auto srcidx = worker.GetLocationForAddress( op.address, srcline );
|
||||||
@ -250,6 +253,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cs_free( insn, cnt );
|
cs_free( insn, cnt );
|
||||||
|
m_maxMnemonicLen = mLenMax + 2;
|
||||||
if( !m_jumpTable.empty() )
|
if( !m_jumpTable.empty() )
|
||||||
{
|
{
|
||||||
struct JumpRange
|
struct JumpRange
|
||||||
@ -1032,8 +1036,8 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
|
|||||||
|
|
||||||
const auto msz = line.mnemonic.size();
|
const auto msz = line.mnemonic.size();
|
||||||
memcpy( buf, line.mnemonic.c_str(), msz );
|
memcpy( buf, line.mnemonic.c_str(), msz );
|
||||||
memset( buf+msz, ' ', 16-msz );
|
memset( buf+msz, ' ', m_maxMnemonicLen-msz );
|
||||||
memcpy( buf+16, line.operands.c_str(), line.operands.size() + 1 );
|
memcpy( buf+m_maxMnemonicLen, line.operands.c_str(), line.operands.size() + 1 );
|
||||||
ImGui::TextUnformatted( buf );
|
ImGui::TextUnformatted( buf );
|
||||||
|
|
||||||
if( line.jumpAddr != 0 )
|
if( line.jumpAddr != 0 )
|
||||||
|
@ -95,6 +95,8 @@ private:
|
|||||||
|
|
||||||
unordered_flat_map<uint32_t, uint32_t> m_sourceFiles;
|
unordered_flat_map<uint32_t, uint32_t> m_sourceFiles;
|
||||||
unordered_flat_set<uint64_t> m_selectedAddresses;
|
unordered_flat_set<uint64_t> m_selectedAddresses;
|
||||||
|
|
||||||
|
int m_maxMnemonicLen;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user