Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 20, 2024

Conversation

ashgti
Copy link
Contributor

@ashgti ashgti commented Feb 16, 2024

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

This should fix #82048

@llvmbot
Copy link
Collaborator

llvmbot commented Feb 16, 2024

@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)

Changes

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

This should fix #82048


Full diff: https://github.com/llvm/llvm-project/pull/82051.diff

1 Files Affected:

  • (modified) lldb/tools/lldb-dap/lldb-dap.cpp (+4-2)
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();

Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs a test and this will be good to go.

Copy link

github-actions bot commented Feb 16, 2024

✅ With the latest revision this PR passed the Python code formatter.

…l during debugger launch.

This fixes an issue where the error is lost if a command while executing `launchCommands` when launching the debugger.
@ashgti
Copy link
Contributor Author

ashgti commented Feb 16, 2024

Needs a test and this will be good to go.

Done, added tests

@ashgti ashgti requested a review from clayborg February 17, 2024 00:41
Copy link
Collaborator

@clayborg clayborg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Always good to have a test.

@ashgti ashgti merged commit ae8facc into llvm:main Feb 20, 2024
4 checks passed
SquallATF pushed a commit to SquallATF/llvm-project that referenced this pull request Jun 30, 2024
…l during debugger launch. (llvm#82051)

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

This should fix llvm#82048
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[lldb-dap] launchCommands failures always show an error "invalid process"
3 participants