@@ -100,7 +100,7 @@ static DisassembledInstruction ConvertSBInstructionToDisassembledInstruction(
100
100
101
101
const char *m = inst.GetMnemonic (target);
102
102
const char *o = inst.GetOperands (target);
103
- const char * c = inst.GetComment (target);
103
+ std::string c = inst.GetComment (target);
104
104
auto d = inst.GetData (target);
105
105
106
106
std::string bytes;
@@ -114,34 +114,30 @@ static DisassembledInstruction ConvertSBInstructionToDisassembledInstruction(
114
114
115
115
DisassembledInstruction disassembled_inst;
116
116
disassembled_inst.address = inst_addr;
117
- disassembled_inst.instructionBytes =
118
- bytes.size () > 0 ? bytes.substr (0 , bytes.size () - 1 ) : " " ;
119
117
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);
122
124
123
- lldb::SBSymbol symbol = addr.GetSymbol ();
124
125
// 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);
133
132
134
133
if (resolve_symbols)
135
- disassembled_inst.symbol = symbol. GetDisplayName () ;
134
+ disassembled_inst.symbol = sym_display_name ;
136
135
}
137
136
138
- si << llvm::formatv (" {0,7} {1,12}" , m, o);
139
- if (c && c[0 ]) {
137
+ if (!c.empty ()) {
140
138
si << " ; " << c;
141
139
}
142
140
143
- disassembled_inst.instruction = std::move (instruction);
144
-
145
141
protocol::Source source = CreateSource (addr, target);
146
142
lldb::SBLineEntry line_entry = GetLineEntryForAddress (target, addr);
147
143
0 commit comments