mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-30 09:14:36 +00:00
Print Arm machine code as a 4-byte number would be printed.
This commit is contained in:
parent
7dfdad2e02
commit
3495a5a678
@ -1652,9 +1652,10 @@ void SourceView::RenderSymbolSourceView( uint32_t iptotal, unordered_flat_map<ui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int PrintHexBytes( char* buf, const uint8_t* bytes, size_t len )
|
static constexpr char HexPrint[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
||||||
|
|
||||||
|
static int PrintHexBytesRaw( char* buf, const uint8_t* bytes, size_t len )
|
||||||
{
|
{
|
||||||
static constexpr char HexPrint[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
|
|
||||||
const auto start = buf;
|
const auto start = buf;
|
||||||
for( size_t i=0; i<len; i++ )
|
for( size_t i=0; i<len; i++ )
|
||||||
{
|
{
|
||||||
@ -1667,6 +1668,37 @@ static int PrintHexBytes( char* buf, const uint8_t* bytes, size_t len )
|
|||||||
return buf - start;
|
return buf - start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int PrintHexBytesArm( char* buf, const uint8_t* bytes )
|
||||||
|
{
|
||||||
|
const auto start = buf;
|
||||||
|
for( int i=3; i>=0; i-- )
|
||||||
|
{
|
||||||
|
const auto byte = bytes[i];
|
||||||
|
*buf++ = HexPrint[byte >> 4];
|
||||||
|
*buf++ = HexPrint[byte & 0xF];
|
||||||
|
*buf++ = ' ';
|
||||||
|
}
|
||||||
|
*--buf = '\0';
|
||||||
|
return buf - start;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int PrintHexBytes( char* buf, const uint8_t* bytes, size_t len, CpuArchitecture arch )
|
||||||
|
{
|
||||||
|
switch( arch )
|
||||||
|
{
|
||||||
|
case CpuArchX86:
|
||||||
|
case CpuArchX64:
|
||||||
|
return PrintHexBytesRaw( buf, bytes, len );
|
||||||
|
case CpuArchArm32:
|
||||||
|
case CpuArchArm64:
|
||||||
|
assert( len == 4 );
|
||||||
|
return PrintHexBytesArm( buf, bytes );
|
||||||
|
default:
|
||||||
|
assert( false );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, uint32_t ipmax, const Worker& worker, View& view )
|
uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<uint64_t, uint32_t> ipcount, uint32_t ipmax, const Worker& worker, View& view )
|
||||||
{
|
{
|
||||||
if( m_disasmFail >= 0 )
|
if( m_disasmFail >= 0 )
|
||||||
@ -1686,7 +1718,7 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
|
|||||||
auto bytesLeft = std::min( 16u, m_codeLen - m_disasmFail );
|
auto bytesLeft = std::min( 16u, m_codeLen - m_disasmFail );
|
||||||
auto code = worker.GetSymbolCode( m_baseAddr, m_codeLen );
|
auto code = worker.GetSymbolCode( m_baseAddr, m_codeLen );
|
||||||
assert( code );
|
assert( code );
|
||||||
PrintHexBytes( tmp, (const uint8_t*)code, bytesLeft );
|
PrintHexBytesRaw( tmp, (const uint8_t*)code, bytesLeft );
|
||||||
TextFocused( "Failure bytes:", tmp );
|
TextFocused( "Failure bytes:", tmp );
|
||||||
TextDisabledUnformatted( "Click to copy to clipboard." );
|
TextDisabledUnformatted( "Click to copy to clipboard." );
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
@ -2639,7 +2671,7 @@ void SourceView::RenderAsmLine( AsmLine& line, uint32_t ipcnt, uint32_t iptotal,
|
|||||||
auto code = (const uint8_t*)worker.GetSymbolCode( m_baseAddr, m_codeLen );
|
auto code = (const uint8_t*)worker.GetSymbolCode( m_baseAddr, m_codeLen );
|
||||||
assert( code );
|
assert( code );
|
||||||
char tmp[64];
|
char tmp[64];
|
||||||
const auto len = PrintHexBytes( tmp, code + line.addr - m_baseAddr, line.len );
|
const auto len = PrintHexBytes( tmp, code + line.addr - m_baseAddr, line.len, worker.GetCpuArch() );
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
TextColoredUnformatted( ImVec4( 0.5, 0.5, 1, 1 ), tmp );
|
TextColoredUnformatted( ImVec4( 0.5, 0.5, 1, 1 ), tmp );
|
||||||
ImGui::SameLine( 0, 0 );
|
ImGui::SameLine( 0, 0 );
|
||||||
|
Loading…
Reference in New Issue
Block a user