https://github.com/royitaqi created 
https://github.com/llvm/llvm-project/pull/156231

Currently, in Server Mode (i.e. `--connection`), the destroy callbacks of all 
debuggers are called at the lldb-dap process's termination. This causes delayed 
logging and release of resources. This can also cause congestion if all 
debuggers have the same destroy callbacks, which will fight for the same 
resources (e.g. web requests) at the same time.

Instead, these can be done earlier, during the disconnect request handling. 
This way, as soon as the debug session is over, logging and release of release 
of resources can happen.  Congestion is also naturally avoided, because it's 
unlikely that all debug sessions finish at the same time.

>From 60a32e358c0d80f02fbfec4950b64bd2cba96359 Mon Sep 17 00:00:00 2001
From: Roy Shi <roy...@meta.com>
Date: Sun, 31 Aug 2025 01:45:23 -0700
Subject: [PATCH] [lldb-dap] Destroy debugger at disconnect request

---
 lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp 
b/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
index 8314a1011a57e..0dfa0b28a20a6 100644
--- a/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
+++ b/lldb/tools/lldb-dap/Handler/DisconnectRequestHandler.cpp
@@ -20,6 +20,11 @@ namespace lldb_dap {
 /// Disconnect request; value of command field is 'disconnect'.
 Error DisconnectRequestHandler::Run(
     const std::optional<DisconnectArguments> &arguments) const {
+  // Destroy the debugger at disconnection. This will trigger the debugger's
+  // destroy callbacks for earlier logging and clean-ups, rather than waiting
+  // until the lldb-dap process's termination.
+  lldb::SBDebugger::Destroy(dap.debugger);
+
   bool terminateDebuggee = !dap.is_attach;
 
   if (arguments && arguments->terminateDebuggee)

_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to