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

Conversation

da-viper
Copy link
Contributor

@da-viper da-viper commented Apr 7, 2025

Ensure the disassembly respects the "target.x86-disassembly-flavor" setting for x86 and x86_64 targets.

Depends on #134626

@llvmbot
Copy link
Member

llvmbot commented Apr 7, 2025

@llvm/pr-subscribers-lldb

Author: Ebuka Ezike (da-viper)

Changes

Ensure the disassembly respects the "target.x86-disassembly-flavor" setting for x86 and x86_64 targets.

Depends on #134626


Full diff: https://github.com/llvm/llvm-project/pull/134722.diff

1 Files Affected:

  • (modified) lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp (+16-1)
diff --git a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
index f0cb7be70210d..0fd9390623046 100644
--- a/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisassembleRequestHandler.cpp
@@ -116,7 +116,22 @@ 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());
+  if (target_triple.starts_with("x86_64") || 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;

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 <yerimyah1@gmail.com>
@da-viper da-viper force-pushed the fix-disassemble-request-flavor branch from c3b2816 to c69872d Compare April 16, 2025 19:53
da-viper and others added 2 commits April 25, 2025 17:38
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants