@@ -100,7 +100,7 @@ static DisassembledInstruction ConvertSBInstructionToDisassembledInstruction(
100100
101101 const char *m = inst.GetMnemonic (target);
102102 const char *o = inst.GetOperands (target);
103- const char * c = inst.GetComment (target);
103+ std::string c = inst.GetComment (target);
104104 auto d = inst.GetData (target);
105105
106106 std::string bytes;
@@ -114,34 +114,30 @@ static DisassembledInstruction ConvertSBInstructionToDisassembledInstruction(
114114
115115 DisassembledInstruction disassembled_inst;
116116 disassembled_inst.address = inst_addr;
117- disassembled_inst.instructionBytes =
118- bytes.size () > 0 ? bytes.substr (0 , bytes.size () - 1 ) : " " ;
119117
120- std::string instruction;
121- llvm::raw_string_ostream si (instruction);
118+ if (!bytes.empty ()) // remove last whitespace
119+ bytes.pop_back ();
120+ disassembled_inst.instructionBytes = std::move (bytes);
121+
122+ llvm::raw_string_ostream si (disassembled_inst.instruction );
123+ si << llvm::formatv (" {0,-7} {1,-25}" , m, o);
122124
123- lldb::SBSymbol symbol = addr.GetSymbol ();
124125 // Only add the symbol on the first line of the function.
125- if (symbol.IsValid () && symbol.GetStartAddress () == addr) {
126- // If we have a valid symbol, append it as a label prefix for the first
127- // instruction. This is so you can see the start of a function/callsite
128- // in the assembly, at the moment VS Code (1.80) does not visualize the
129- // symbol associated with the assembly instruction.
130- si << (symbol.GetMangledName () != nullptr ? symbol.GetMangledName ()
131- : symbol.GetName ())
132- << " : " ;
126+ // in the comment section
127+ if (lldb::SBSymbol symbol = addr.GetSymbol ();
128+ symbol.GetStartAddress () == addr) {
129+ const llvm::StringRef sym_display_name = symbol.GetDisplayName ();
130+ c.append (" " );
131+ c.append (sym_display_name);
133132
134133 if (resolve_symbols)
135- disassembled_inst.symbol = symbol. GetDisplayName () ;
134+ disassembled_inst.symbol = sym_display_name ;
136135 }
137136
138- si << llvm::formatv (" {0,7} {1,12}" , m, o);
139- if (c && c[0 ]) {
137+ if (!c.empty ()) {
140138 si << " ; " << c;
141139 }
142140
143- disassembled_inst.instruction = std::move (instruction);
144-
145141 protocol::Source source = CreateSource (addr, target);
146142 lldb::SBLineEntry line_entry = GetLineEntryForAddress (target, addr);
147143
0 commit comments