[Lldb-commits] [lldb] [lldb-dap] Do not write over the existing error if launchCommands fail during debugger launch. (PR #82051)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Fri Feb 16 14:13:26 PST 2024


https://github.com/ashgti created https://github.com/llvm/llvm-project/pull/82051

This fixes an issue where the error is lost if a command while executing `launchCommands` when launching the debugger.

This should fix #82048

>From 5e3787a61c92f002746f2437e2fc8509d787a0ce Mon Sep 17 00:00:00 2001
From: John Harrison <harjohn at google.com>
Date: Fri, 16 Feb 2024 14:11:10 -0800
Subject: [PATCH] [lldb-dap] Do not write over the existing error if
 launchCommands fail during debugger launch.

This fixes an issue where the error is lost if a command while executing `launchCommands` when launching the debugger.
---
 lldb/tools/lldb-dap/lldb-dap.cpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 67022347e6d624..cc555d33b48b53 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -22,7 +22,7 @@
 // We also need to #undef GetObject (which is defined to GetObjectW) because
 // the JSON code we use also has methods named `GetObject()` and we conflict
 // against these.
-#define NOMINMAX
+#define NOMINMAXf
 #include <windows.h>
 #undef GetObject
 #include <io.h>
@@ -1779,8 +1779,10 @@ lldb::SBError LaunchProcess(const llvm::json::Object &request) {
     // Set the launch info so that run commands can access the configured
     // launch details.
     g_dap.target.SetLaunchInfo(launch_info);
-    if (llvm::Error err = g_dap.RunLaunchCommands(launchCommands))
+    if (llvm::Error err = g_dap.RunLaunchCommands(launchCommands)) {
       error.SetErrorString(llvm::toString(std::move(err)).c_str());
+      return error;
+    }
     // The custom commands might have created a new target so we should use the
     // selected target after these commands are run.
     g_dap.target = g_dap.debugger.GetSelectedTarget();



More information about the lldb-commits mailing list