mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Tighten assembly source location display.
This commit is contained in:
parent
6dd765c101
commit
a715df6338
@ -240,10 +240,12 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
|
|||||||
const auto mLen = strlen( op.mnemonic );
|
const auto mLen = strlen( op.mnemonic );
|
||||||
if( mLen > mLenMax ) mLenMax = mLen;
|
if( mLen > mLenMax ) mLenMax = mLen;
|
||||||
|
|
||||||
|
uint32_t mLineMax = 0;
|
||||||
uint32_t srcline;
|
uint32_t srcline;
|
||||||
const auto srcidx = worker.GetLocationForAddress( op.address, srcline );
|
const auto srcidx = worker.GetLocationForAddress( op.address, srcline );
|
||||||
if( srcline != 0 )
|
if( srcline != 0 )
|
||||||
{
|
{
|
||||||
|
if( srcline > mLineMax ) mLineMax = srcline;
|
||||||
const auto idx = srcidx.Idx();
|
const auto idx = srcidx.Idx();
|
||||||
auto sit = m_sourceFiles.find( idx );
|
auto sit = m_sourceFiles.find( idx );
|
||||||
if( sit == m_sourceFiles.end() )
|
if( sit == m_sourceFiles.end() )
|
||||||
@ -251,6 +253,9 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
|
|||||||
m_sourceFiles.emplace( idx, srcline );
|
m_sourceFiles.emplace( idx, srcline );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
char tmp[16];
|
||||||
|
sprintf( tmp, "%" PRIu32, mLineMax );
|
||||||
|
m_maxLine = strlen( tmp ) + 1;
|
||||||
}
|
}
|
||||||
cs_free( insn, cnt );
|
cs_free( insn, cnt );
|
||||||
m_maxMnemonicLen = mLenMax + 2;
|
m_maxMnemonicLen = mLenMax + 2;
|
||||||
@ -961,13 +966,13 @@ void SourceView::RenderAsmLine( const AsmLine& line, uint32_t ipcnt, uint32_t ip
|
|||||||
const auto linesz = strlen( lineString );
|
const auto linesz = strlen( lineString );
|
||||||
char buf[32];
|
char buf[32];
|
||||||
const auto fnsz = strlen( fileName );
|
const auto fnsz = strlen( fileName );
|
||||||
if( fnsz < 32 - 8 )
|
if( fnsz < 30 - m_maxLine )
|
||||||
{
|
{
|
||||||
sprintf( buf, "%s:%i", fileName, srcline );
|
sprintf( buf, "%s:%i", fileName, srcline );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf( buf, "...%s:%i", fileName+fnsz-(32-3-1-8), srcline );
|
sprintf( buf, "...%s:%i", fileName+fnsz-(30-3-1-m_maxLine), srcline );
|
||||||
}
|
}
|
||||||
const auto bufsz = strlen( buf );
|
const auto bufsz = strlen( buf );
|
||||||
TextDisabledUnformatted( buf );
|
TextDisabledUnformatted( buf );
|
||||||
|
@ -96,6 +96,7 @@ 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;
|
||||||
|
|
||||||
|
uint32_t m_maxLine;
|
||||||
int m_maxMnemonicLen;
|
int m_maxMnemonicLen;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user