70 lines · cpp
1//===-- ConfigurationDoneRequestHandler..cpp ------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include "DAP.h"10#include "EventHelper.h"11#include "LLDBUtils.h"12#include "Protocol/ProtocolEvents.h"13#include "Protocol/ProtocolRequests.h"14#include "ProtocolUtils.h"15#include "RequestHandler.h"16#include "lldb/API/SBDebugger.h"17 18using namespace llvm;19using namespace lldb_dap::protocol;20 21namespace lldb_dap {22 23/// This request indicates that the client has finished initialization of the24/// debug adapter.25///26/// So it is the last request in the sequence of configuration requests (which27/// was started by the `initialized` event).28///29/// Clients should only call this request if the corresponding capability30/// `supportsConfigurationDoneRequest` is true.31llvm::Error32ConfigurationDoneRequestHandler::Run(const ConfigurationDoneArguments &) const {33 dap.configuration_done = true;34 35 // Ensure any command scripts did not leave us in an unexpected state.36 lldb::SBProcess process = dap.target.GetProcess();37 if (!process.IsValid() ||38 !lldb::SBDebugger::StateIsStoppedState(process.GetState()))39 return make_error<DAPError>(40 "Expected process to be stopped.\r\n\r\nProcess is in an unexpected "41 "state and may have missed an initial configuration. Please check that "42 "any debugger command scripts are not resuming the process during the "43 "launch sequence.");44 45 // Waiting until 'configurationDone' to send target based capabilities in case46 // the launch or attach scripts adjust the target. The initial dummy target47 // may have different capabilities than the final target.48 49 /// Also send here custom capabilities to the client, which is consumed by the50 /// lldb-dap specific editor extension.51 SendExtraCapabilities(dap);52 53 // Clients can request a baseline of currently existing threads after54 // we acknowledge the configurationDone request.55 // Client requests the baseline of currently existing threads after56 // a successful or attach by sending a 'threads' request57 // right after receiving the configurationDone response.58 // Obtain the list of threads before we resume the process59 dap.initial_thread_list = GetThreads(process, dap.thread_format);60 61 SendProcessEvent(dap, dap.is_attach ? Attach : Launch);62 63 if (dap.stop_at_entry)64 return SendThreadStoppedEvent(dap, /*on_entry=*/true);65 66 return ToError(process.Continue());67}68 69} // namespace lldb_dap70