[Lldb-commits] [lldb] [lldb-dap] Show assembly depending on `stop-disassembly-display` settings (PR #136494)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 23 15:31:07 PDT 2025


================
@@ -163,6 +163,19 @@ GetEnvironmentFromArguments(const llvm::json::Object &arguments) {
   return envs;
 }
 
+std::string GetStopDisassemblyDisplay(lldb::SBDebugger &debugger) {
+  lldb::SBStructuredData result =
+      debugger.GetSetting("stop-disassembly-display");
+  const size_t result_length = result.GetStringValue(nullptr, 0);
+  if (result_length > 0) {
+    std::string result_string(result_length, '\0');
+    result.GetStringValue(result_string.data(), result_length + 1);
+    return result_string;
+  }
+
+  return "no-debuginfo";
----------------
JDevlieghere wrote:

I don't like hard-coding a default value here. If for whatever reason this ever were to change, that person needs to remember to do the same thing here. Instead, could we make this return a `std::optional<std::string>`.

Even better, instead of having this return a string, I would create a new enum for this setting in lldb-dap and have this return an enum value instead of a string.  If we move the enum from `Debugger.h` into `lldb-enumerations.h` we can parse it with an llvm::StringSwitch and reuse it across lldb-dap. 

```
  enum StopDisassemblyType {
    eStopDisassemblyTypeNever = 0,
    eStopDisassemblyTypeNoDebugInfo,
    eStopDisassemblyTypeNoSource,
    eStopDisassemblyTypeAlways
  };
```

I guess that would still require a default value, but at least it's easier to grep for the enum value than for the corresponding string. 

https://github.com/llvm/llvm-project/pull/136494


More information about the lldb-commits mailing list