[Lldb-commits] [lldb] [lldb-dap] Refactoring lldb-dap 'launch' request to use typed RequestHandler<>. (PR #133624)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 24 17:27:10 PDT 2025


================
@@ -672,21 +670,17 @@ DAP::CreateTargetFromArguments(const llvm::json::Object &arguments,
   // enough information to determine correct arch and platform (or ELF can be
   // omitted at all), so it is good to leave the user an apportunity to specify
   // those. Any of those three can be left empty.
-  const llvm::StringRef target_triple =
-      GetString(arguments, "targetTriple").value_or("");
-  const llvm::StringRef platform_name =
-      GetString(arguments, "platformName").value_or("");
-  const llvm::StringRef program = GetString(arguments, "program").value_or("");
   auto target = this->debugger.CreateTarget(
-      program.data(), target_triple.data(), platform_name.data(),
+      configuration.program.value_or("").data(),
+      configuration.targetTriple.value_or("").data(),
+      configuration.platformName.value_or("").data(),
       true, // Add dependent modules.
       error);
 
   if (error.Fail()) {
     // Update message if there was an error.
     error.SetErrorStringWithFormat(
-        "Could not create a target for a program '%s': %s.", program.data(),
-        error.GetCString());
+        "Could not create a target for a program: %s.", error.GetCString());
----------------
ashgti wrote:

Previously the error message would print something along the lines of:

```
Could not create a target for a program 'a.out': 'a.out' does not exist.
```

I'm not sure the 'Could not create target' part adds anything, removing it the error message becomes:

```
'a.out' does not exist
```

Here is an example using:

```
        {
            "type": "lldb-dap",
            "request": "launch",
            "name": "Debug bad path",
            "program": "~/Projects/baz-bad-path"
        },
```

<img width="265" alt="Screenshot 2025-04-24 at 5 25 44 PM" src="https://github.com/user-attachments/assets/a37c5052-0d14-4a5d-8e8c-92d5ba974ca3" />


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


More information about the lldb-commits mailing list