@@ -726,7 +726,7 @@ void DAP::SetTarget(const lldb::SBTarget target) {
726726 }
727727}
728728
729- bool DAP::HandleObject (const Message &M) {
729+ bool DAP::HandleObject (const Message &M, bool &defer ) {
730730 TelemetryDispatcher dispatcher (&debugger);
731731 dispatcher.Set (" client_name" , transport.GetClientName ().str ());
732732 if (const auto *req = std::get_if<Request>(&M)) {
@@ -748,7 +748,7 @@ bool DAP::HandleObject(const Message &M) {
748748 dispatcher.Set (" client_data" ,
749749 llvm::Twine (" request_command:" , req->command ).str ());
750750 if (handler_pos != request_handlers.end ()) {
751- handler_pos->second ->Run (*req);
751+ defer = handler_pos->second ->Run (*req);
752752 return true ; // Success
753753 }
754754
@@ -918,17 +918,11 @@ llvm::Error DAP::Loop() {
918918
919919 // The launch sequence is special and we need to carefully handle
920920 // packets in the right order. Until we've handled configurationDone,
921- bool add_to_pending_queue = false ;
922-
923921 if (const protocol::Request *req =
924922 std::get_if<protocol::Request>(&*next)) {
925923 llvm::StringRef command = req->command ;
926924 if (command == " disconnect" )
927925 disconnecting = true ;
928- if (!configuration_done)
929- add_to_pending_queue =
930- command != " initialize" && command != " configurationDone" &&
931- command != " disconnect" && !command.ends_with (" Breakpoints" );
932926 }
933927
934928 const std::optional<CancelArguments> cancel_args =
@@ -956,8 +950,7 @@ llvm::Error DAP::Loop() {
956950
957951 {
958952 std::lock_guard<std::mutex> guard (m_queue_mutex);
959- auto &queue = add_to_pending_queue ? m_pending_queue : m_queue;
960- queue.push_back (std::move (*next));
953+ m_queue.push_back (std::move (*next));
961954 }
962955 m_queue_cv.notify_one ();
963956 }
@@ -984,9 +977,13 @@ llvm::Error DAP::Loop() {
984977 // Unlock while we're processing the event.
985978 lock.unlock ();
986979
987- if (!HandleObject (next))
980+ bool defer_message = false ;
981+ if (!HandleObject (next, defer_message))
988982 return llvm::createStringError (llvm::inconvertibleErrorCode (),
989983 " unhandled packet" );
984+ if (defer_message) {
985+ m_pending_queue.push_back (next);
986+ }
990987 }
991988
992989 return ToError (queue_reader.get ());
0 commit comments