| 1 | //===-- ContinueRequestHandler.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-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #include "DAP.h" |
| 10 | #include "Handler/RequestHandler.h" |
| 11 | #include "LLDBUtils.h" |
| 12 | #include "Protocol/ProtocolRequests.h" |
| 13 | #include "lldb/API/SBError.h" |
| 14 | #include "lldb/API/SBProcess.h" |
| 15 | #include "llvm/Support/Error.h" |
| 16 | |
| 17 | using namespace llvm; |
| 18 | using namespace lldb; |
| 19 | using namespace lldb_dap::protocol; |
| 20 | |
| 21 | namespace lldb_dap { |
| 22 | |
| 23 | /// The request resumes execution of all threads. If the debug adapter supports |
| 24 | /// single thread execution (see capability |
| 25 | /// `supportsSingleThreadExecutionRequests`), setting the `singleThread` |
| 26 | /// argument to true resumes only the specified thread. If not all threads were |
| 27 | /// resumed, the `allThreadsContinued` attribute of the response should be set |
| 28 | /// to false. |
| 29 | Expected<ContinueResponseBody> |
| 30 | ContinueRequestHandler::Run(const ContinueArguments &args) const { |
| 31 | SBProcess process = dap.target.GetProcess(); |
| 32 | SBError error; |
| 33 | |
| 34 | if (!SBDebugger::StateIsStoppedState(state: process.GetState())) |
| 35 | return make_error<NotStoppedError>(); |
| 36 | |
| 37 | if (args.singleThread) |
| 38 | dap.GetLLDBThread(id: args.threadId).Resume(error); |
| 39 | else |
| 40 | error = process.Continue(); |
| 41 | |
| 42 | if (error.Fail()) |
| 43 | return ToError(error); |
| 44 | |
| 45 | ContinueResponseBody body; |
| 46 | body.allThreadsContinued = !args.singleThread; |
| 47 | return body; |
| 48 | } |
| 49 | |
| 50 | } // namespace lldb_dap |
| 51 |
