[Lldb-commits] [lldb] [lldb-dap] Adding support for cancelling a request. (PR #130169)

John Harrison via lldb-commits lldb-commits at lists.llvm.org
Fri Mar 21 14:10:40 PDT 2025


================
@@ -671,8 +695,33 @@ void DAP::SetTarget(const lldb::SBTarget target) {
   }
 }
 
-bool DAP::HandleObject(const protocol::Message &M) {
-  if (const auto *req = std::get_if<protocol::Request>(&M)) {
+bool DAP::HandleObject(const Message &M) {
+  if (const auto *req = std::get_if<Request>(&M)) {
+    {
+      std::lock_guard<std::mutex> lock(m_active_request_mutex);
+      m_active_request = req;
+    }
+
+    auto cleanup = llvm::make_scope_exit([&]() {
+      std::scoped_lock<std::mutex> active_request_lock(m_active_request_mutex);
+      m_active_request = nullptr;
+    });
+
+    {
+      // If there is a pending cancelled request, preempt the request and mark
+      // it cancelled.
+      std::lock_guard<std::mutex> lock(m_cancelled_requests_mutex);
+      if (m_cancelled_requests.find(req->seq) != m_cancelled_requests.end()) {
+        Response cancelled = CancelledResponse(req->seq, req->command);
+        Send(cancelled);
+        return true;
+      }
+    }
+
+    // Clear interrupt marker prior to handling the next request.
+    if (debugger.InterruptRequested())
+      debugger.CancelInterruptRequest();
----------------
ashgti wrote:

Moved this up to 702

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


More information about the lldb-commits mailing list