Skip to content

[lldb][lldb-dap] Respect x86 disassembly flavor setting #134722

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lldb/source/Commands/CommandObjectDisassemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void CommandObjectDisassemble::CommandOptions::OptionParsingStarting(
// architecture. For now GetDisassemblyFlavor is really only valid for x86
// (and for the llvm assembler plugin, but I'm papering over that since that
// is the only disassembler plugin we have...
// this logic is also duplicated in `Handler/DisassembleRequestHandler`
if (target->GetArchitecture().GetTriple().getArch() == llvm::Triple::x86 ||
target->GetArchitecture().GetTriple().getArch() ==
llvm::Triple::x86_64) {
Expand Down
19 changes: 18 additions & 1 deletion lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,24 @@ void DisassembleRequestHandler::operator()(

const auto inst_count =
GetInteger<int64_t>(arguments, "instructionCount").value_or(0);
lldb::SBInstructionList insts = dap.target.ReadInstructions(addr, inst_count);

std::string flavor_string;
const auto target_triple = llvm::StringRef(dap.target.GetTriple());
// This handles both 32 and 64bit x86 architecture. The logic is duplicated in
// `CommandObjectDisassemble::CommandOptions::OptionParsingStarting`
if (target_triple.starts_with("x86")) {
const lldb::SBStructuredData flavor =
dap.debugger.GetSetting("target.x86-disassembly-flavor");

const size_t str_length = flavor.GetStringValue(nullptr, 0);
if (str_length != 0) {
flavor_string.resize(str_length + 1);
flavor.GetStringValue(flavor_string.data(), flavor_string.length());
}
}

lldb::SBInstructionList insts =
dap.target.ReadInstructions(addr, inst_count, flavor_string.c_str());

if (!insts.IsValid()) {
response["success"] = false;
Expand Down
Loading