[Lldb-commits] [lldb] [lldb-dap] Adding support for cancelling a request. (PR #130169)
Pavel Labath via lldb-commits
lldb-commits at lists.llvm.org
Wed Apr 2 04:37:51 PDT 2025
================
@@ -778,28 +817,121 @@ llvm::Error DAP::Disconnect(bool terminateDebuggee) {
return ToError(error);
}
+bool DAP::IsCancelled(const protocol::Request &req) {
+ std::lock_guard<std::mutex> lock(m_cancelled_requests_mutex);
+ return m_cancelled_requests.contains(req.seq);
+}
+
+void DAP::ClearCancelRequest(const CancelArguments &args) {
+ std::lock_guard<std::mutex> cancalled_requests_lock(
+ m_cancelled_requests_mutex);
+ if (args.requestId)
+ m_cancelled_requests.erase(*args.requestId);
+}
+
+template <typename T>
+static std::optional<T> getArgumentsIfRequest(const Message &pm,
+ llvm::StringLiteral command) {
+ auto *const req = std::get_if<Request>(&pm);
+ if (!req || req->command != command)
+ return std::nullopt;
+
+ T args;
+ llvm::json::Path::Root root;
+ if (!fromJSON(req->arguments, args, root)) {
+ return std::nullopt;
+ }
+
+ return std::move(args);
+}
+
llvm::Error DAP::Loop() {
- auto cleanup = llvm::make_scope_exit([this]() {
+ std::future<llvm::Error> queue_reader = std::async([&]() -> llvm::Error {
----------------
labath wrote:
I think this should explicitly use the std::launch::async flag as it won't work in the "deferred" policy and "If more than one flag is set, it is implementation-defined which policy is selected."
https://github.com/llvm/llvm-project/pull/130169
More information about the lldb-commits
mailing list