================
@@ -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
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to