diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 05a3d2e4..1b69e080 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -18,6 +18,10 @@ #include "IconsFontAwesome5.h" +#ifndef TRACY_NO_FILESELECTOR +# include "../nfd/nfd.h" +#endif + namespace tracy { @@ -1561,6 +1565,97 @@ uint64_t SourceView::RenderSymbolAsmView( uint32_t iptotal, unordered_flat_mapisInline ) + { + auto parent = worker.GetSymbolData( m_baseAddr ); + if( parent ) + { + symName = worker.GetString( parent->name ); + } + else + { + sprintf( tmp, "0x%" PRIx64, m_baseAddr ); + symName = tmp; + } + } + else + { + symName = worker.GetString( sym->name ); + } + fprintf( f, "; Tracy Profiler disassembly of symbol %s [%s]\n\n.intel_syntax\n\n", symName, worker.GetCaptureProgram() ); + + unordered_flat_map locMap; + for( auto& v : m_asm ) + { + if( m_jumpTable.find( v.addr ) != m_jumpTable.end() ) + { + const auto idx = locMap.size(); + locMap.emplace( v.addr, idx ); + } + } + for( auto& v : m_asm ) + { + auto it = locMap.find( v.addr ); + if( it != locMap.end() ) + { + fprintf( f, ".LOC_%" PRIu32 ":\n", it->second ); + } + bool hasJump = false; + if( v.jumpAddr != 0 ) + { + auto lit = locMap.find( v.jumpAddr ); + if( lit != locMap.end() ) + { + fprintf( f, "\t%-*s.LOC_%" PRIu32 "\n", m_maxMnemonicLen, v.mnemonic.c_str(), lit->second ); + hasJump = true; + } + } + if( !hasJump ) + { + if( v.operands.empty() ) + { + fprintf( f, "\t%s\n", v.mnemonic.c_str() ); + } + else + { + fprintf( f, "\t%-*s%s\n", m_maxMnemonicLen, v.mnemonic.c_str(), v.operands.c_str() ); + } + } + } + fclose( f ); + } + } + } +#endif + const float bottom = m_asmSampleSelect.empty() ? 0 : ImGui::GetFrameHeight(); ImGui::BeginChild( "##asmView", ImVec2( 0, -bottom ), true, ImGuiWindowFlags_NoMove ); if( m_font ) ImGui::PushFont( m_font );