diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index 46eb241c..d1a7f9e9 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -1598,80 +1598,7 @@ 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", symName, worker.GetCaptureProgram().c_str() ); - if( !m_atnt ) fprintf( f, ".intel_syntax\n\n" ); - - for( auto& v : m_asm ) - { - auto it = m_locMap.find( v.addr ); - if( it != m_locMap.end() ) - { - fprintf( f, ".L%" PRIu32 ":\n", it->second ); - } - bool hasJump = false; - if( v.jumpAddr != 0 ) - { - auto lit = m_locMap.find( v.jumpAddr ); - if( lit != m_locMap.end() ) - { - fprintf( f, "\t%-*s.L%" 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 ); - } - } + Save( worker ); } #endif @@ -3494,4 +3421,82 @@ void SourceView::CheckWrite( int line, RegsX86 reg, int limit ) } } +void SourceView::Save( const Worker& worker ) +{ + nfdchar_t* fn; + auto res = NFD_SaveDialog( "asm", nullptr, &fn ); + if( res == NFD_OKAY ) + { + FILE* f = nullptr; + const auto sz = strlen( fn ); + if( sz < 5 || memcmp( fn + sz - 4, ".asm", 4 ) != 0 ) + { + char tmp[1024]; + sprintf( tmp, "%s.asm", fn ); + f = fopen( tmp, "wb" ); + } + else + { + f = fopen( fn, "wb" ); + } + if( f ) + { + char tmp[16]; + auto sym = worker.GetSymbolData( m_symAddr ); + assert( sym ); + const char* symName; + if( sym->isInline ) + { + 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", symName, worker.GetCaptureProgram().c_str() ); + if( !m_atnt ) fprintf( f, ".intel_syntax\n\n" ); + + for( auto& v : m_asm ) + { + auto it = m_locMap.find( v.addr ); + if( it != m_locMap.end() ) + { + fprintf( f, ".L%" PRIu32 ":\n", it->second ); + } + bool hasJump = false; + if( v.jumpAddr != 0 ) + { + auto lit = m_locMap.find( v.jumpAddr ); + if( lit != m_locMap.end() ) + { + fprintf( f, "\t%-*s.L%" 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 ); + } + } +} + } diff --git a/server/TracySourceView.hpp b/server/TracySourceView.hpp index 65649ad2..9530fc90 100644 --- a/server/TracySourceView.hpp +++ b/server/TracySourceView.hpp @@ -167,6 +167,8 @@ private: void CheckRead( int line, RegsX86 reg, int limit ); void CheckWrite( int line, RegsX86 reg, int limit ); + void Save( const Worker& worker ); + struct TokenizerState { void Reset()