Skip to content

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
@da-viper da-viper force-pushed the fix-disassemble-request-flavor branch from c3b2816 to c69872d Compare April 16, 2025 19:53
@da-viper da-viper merged commit 7670af5 into llvm:main Apr 27, 2025
10 checks passed
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
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]>
@da-viper da-viper deleted the fix-disassemble-request-flavor branch May 11, 2025 11:39
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