Skip to content

Commit cd6b5af

Browse files
da-viperJDevlieghere
authored andcommitted
[lldb][lldb-dap] Respect x86 disassembly flavor setting (llvm#134722)
Ensure the disassembly respects the "target.x86-disassembly-flavor" setting for x86 and x86_64 targets. Depends on llvm#134626 --------- Signed-off-by: Ebuka Ezike <[email protected]> Co-authored-by: Jonas Devlieghere <[email protected]>
1 parent e8f5d1a commit cd6b5af

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lldb/source/Commands/CommandObjectDisassemble.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ void CommandObjectDisassemble::CommandOptions::OptionParsingStarting(
190190
// architecture. For now GetDisassemblyFlavor is really only valid for x86
191191
// (and for the llvm assembler plugin, but I'm papering over that since that
192192
// is the only disassembler plugin we have...
193+
// This logic is duplicated in `Handler/DisassembleRequestHandler`.
193194
if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 ||
194195
target->GetArchitecture().GetTriple().getArch() ==
195196
llvm::Triple::x86_64) {

lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,24 @@ void DisassembleRequestHandler::operator()(
116116

117117
const auto inst_count =
118118
GetInteger<int64_t>(arguments, "instructionCount").value_or(0);
119-
lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, inst_count);
119+
120+
std::string flavor_string;
121+
const auto target_triple = llvm::StringRef(dap.target.GetTriple());
122+
// This handles both 32 and 64bit x86 architecture. The logic is duplicated in
123+
// `CommandObjectDisassemble::CommandOptions::OptionParsingStarting`
124+
if (target_triple.starts_with("x86")) {
125+
const lldb::SBStructuredData flavor =
126+
dap.debugger.GetSetting("target.x86-disassembly-flavor");
127+
128+
const size_t str_length = flavor.GetStringValue(nullptr, 0);
129+
if (str_length != 0) {
130+
flavor_string.resize(str_length + 1);
131+
flavor.GetStringValue(flavor_string.data(), flavor_string.length());
132+
}
133+
}
134+
135+
lldb::SBInstructionList insts =
136+
dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str());
120137

121138
if (!insts.IsValid()) {
122139
response["success"] = false;

0 commit comments

Comments
 (0)