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

Allow switching between Intel and AT&T assembly syntax.

This commit is contained in:
Bartosz Taudul 2020-05-09 12:58:09 +02:00
parent 16aca7e6c8
commit 8caf6b02c6
2 changed files with 11 additions and 3 deletions

View File

@ -87,6 +87,7 @@ SourceView::SourceView( ImFont* font )
, m_asmBytes( false ) , m_asmBytes( false )
, m_asmShowSourceLocation( true ) , m_asmShowSourceLocation( true )
, m_calcInlineStats( true ) , m_calcInlineStats( true )
, m_atnt( false )
, m_showJumps( true ) , m_showJumps( true )
, m_cpuArch( CpuArchUnknown ) , m_cpuArch( CpuArchUnknown )
, m_showLatency( false ) , m_showLatency( false )
@ -522,6 +523,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
} }
if( rval != CS_ERR_OK ) return false; if( rval != CS_ERR_OK ) return false;
cs_option( handle, CS_OPT_DETAIL, CS_OPT_ON ); cs_option( handle, CS_OPT_DETAIL, CS_OPT_ON );
cs_option( handle, CS_OPT_SYNTAX, m_atnt ? CS_OPT_SYNTAX_ATT : CS_OPT_SYNTAX_INTEL );
cs_insn* insn; cs_insn* insn;
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 )
@ -1513,13 +1515,13 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
} }
ImGui::SameLine(); ImGui::SameLine();
} }
SmallCheckbox( ICON_FA_SEARCH_LOCATION " Relative locations", &m_asmRelative ); SmallCheckbox( ICON_FA_SEARCH_LOCATION " Relative loc.", &m_asmRelative );
if( !m_sourceFiles.empty() ) if( !m_sourceFiles.empty() )
{ {
ImGui::SameLine(); ImGui::SameLine();
ImGui::Spacing(); ImGui::Spacing();
ImGui::SameLine(); ImGui::SameLine();
SmallCheckbox( ICON_FA_FILE_IMPORT " Source locations", &m_asmShowSourceLocation ); SmallCheckbox( ICON_FA_FILE_IMPORT " Source loc.", &m_asmShowSourceLocation );
} }
ImGui::SameLine(); ImGui::SameLine();
ImGui::Spacing(); ImGui::Spacing();
@ -1529,6 +1531,10 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
ImGui::Spacing(); ImGui::Spacing();
ImGui::SameLine(); ImGui::SameLine();
SmallCheckbox( ICON_FA_SHARE " Jumps", &m_showJumps ); SmallCheckbox( ICON_FA_SHARE " Jumps", &m_showJumps );
ImGui::SameLine();
ImGui::Spacing();
ImGui::SameLine();
if( SmallCheckbox( "AT&T", &m_atnt ) ) Disassemble( m_baseAddr, worker );
if( m_cpuArch == CpuArchX64 || m_cpuArch == CpuArchX86 ) if( m_cpuArch == CpuArchX64 || m_cpuArch == CpuArchX86 )
{ {
@ -1610,7 +1616,8 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_map<u
{ {
symName = worker.GetString( sym->name ); symName = worker.GetString( sym->name );
} }
fprintf( f, "; Tracy Profiler disassembly of symbol %s [%s]\n\n.intel_syntax\n\n", symName, worker.GetCaptureProgram() ); fprintf( f, "; Tracy Profiler disassembly of symbol %s [%s]\n\n", symName, worker.GetCaptureProgram() );
if( !m_atnt ) fprintf( f, ".intel_syntax\n\n" );
unordered_flat_map<uint64_t, uint32_t> locMap; unordered_flat_map<uint64_t, uint32_t> locMap;
for( auto& v : m_asm ) for( auto& v : m_asm )

View File

@ -201,6 +201,7 @@ private:
bool m_asmShowSourceLocation; bool m_asmShowSourceLocation;
bool m_calcInlineStats; bool m_calcInlineStats;
uint8_t m_maxAsmBytes; uint8_t m_maxAsmBytes;
bool m_atnt;
std::vector<Line> m_lines; std::vector<Line> m_lines;
std::vector<AsmLine> m_asm; std::vector<AsmLine> m_asm;