Skip to content

[lldb-dap] Correct the disconnect helper on server shutdown. #142508

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

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

ashgti
Copy link
Contributor

@ashgti ashgti commented Jun 3, 2025

Previously, we incorrectly handled the disconnect operation if we signal lldb-dap running in server mode.

Updated to correctly disconnect the attach vs launch behavior on server shutdown.

Previously, we incorrectly handled the disconnect operation if we signal lldb-dap running in server mode.

Updated to correctly disconnect the attach vs launch behavior on server shutdown.
@llvmbot
Copy link
Member

llvmbot commented Jun 3, 2025

@llvm/pr-subscribers-lldb

Author: John Harrison (ashgti)

Changes

Previously, we incorrectly handled the disconnect operation if we signal lldb-dap running in server mode.

Updated to correctly disconnect the attach vs launch behavior on server shutdown.


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

3 Files Affected:

  • (modified) lldb/test/API/tools/lldb-dap/server/TestDAP_server.py (+1-1)
  • (modified) lldb/tools/lldb-dap/DAP.cpp (+1-1)
  • (modified) lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp (+1-1)
diff --git a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
index 7a9a4f434e04b..ed17044a220d4 100644
--- a/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
+++ b/lldb/test/API/tools/lldb-dap/server/TestDAP_server.py
@@ -102,7 +102,7 @@ def test_server_interrupt(self):
         process.send_signal(signal.SIGINT)
 
         self.dap_server.wait_for_terminated()
-        self.assertIsNone(
+        self.assertIsNotNone(
             self.dap_server.exit_status,
             "Process exited before interrupting lldb-dap server",
         )
diff --git a/lldb/tools/lldb-dap/DAP.cpp b/lldb/tools/lldb-dap/DAP.cpp
index 394e8f0e6c851..2537e007d691b 100644
--- a/lldb/tools/lldb-dap/DAP.cpp
+++ b/lldb/tools/lldb-dap/DAP.cpp
@@ -820,7 +820,7 @@ void DAP::SendTerminatedEvent() {
   });
 }
 
-llvm::Error DAP::Disconnect() { return Disconnect(is_attach); }
+llvm::Error DAP::Disconnect() { return Disconnect(!is_attach); }
 
 llvm::Error DAP::Disconnect(bool terminateDebuggee) {
   lldb::SBError error;
diff --git a/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp b/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
index 81e94c7551836..8314a1011a57e 100644
--- a/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
@@ -20,7 +20,7 @@ namespace lldb_dap {
 /// Disconnect request; value of command field is 'disconnect'.
 Error DisconnectRequestHandler::Run(
     const std::optional<DisconnectArguments> &arguments) const {
-  bool terminateDebuggee = dap.is_attach ? false : true;
+  bool terminateDebuggee = !dap.is_attach;
 
   if (arguments && arguments->terminateDebuggee)
     terminateDebuggee = *arguments->terminateDebuggee;

@ashgti ashgti requested review from eronnen and da-viper June 3, 2025 00:45
@ashgti ashgti merged commit 4d42c8e into llvm:main Jun 3, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants