|
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
9 | 9 | #include "DAP.h" |
10 | | -#include "JSONUtils.h" |
11 | | -#include "RequestHandler.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; |
12 | 20 |
|
13 | 21 | namespace lldb_dap { |
14 | 22 |
|
15 | | -// "ContinueRequest": { |
16 | | -// "allOf": [ { "$ref": "#/definitions/Request" }, { |
17 | | -// "type": "object", |
18 | | -// "description": "Continue request; value of command field is 'continue'. |
19 | | -// The request starts the debuggee to run again.", |
20 | | -// "properties": { |
21 | | -// "command": { |
22 | | -// "type": "string", |
23 | | -// "enum": [ "continue" ] |
24 | | -// }, |
25 | | -// "arguments": { |
26 | | -// "$ref": "#/definitions/ContinueArguments" |
27 | | -// } |
28 | | -// }, |
29 | | -// "required": [ "command", "arguments" ] |
30 | | -// }] |
31 | | -// }, |
32 | | -// "ContinueArguments": { |
33 | | -// "type": "object", |
34 | | -// "description": "Arguments for 'continue' request.", |
35 | | -// "properties": { |
36 | | -// "threadId": { |
37 | | -// "type": "integer", |
38 | | -// "description": "Continue execution for the specified thread (if |
39 | | -// possible). If the backend cannot continue on a single |
40 | | -// thread but will continue on all threads, it should |
41 | | -// set the allThreadsContinued attribute in the response |
42 | | -// to true." |
43 | | -// } |
44 | | -// }, |
45 | | -// "required": [ "threadId" ] |
46 | | -// }, |
47 | | -// "ContinueResponse": { |
48 | | -// "allOf": [ { "$ref": "#/definitions/Response" }, { |
49 | | -// "type": "object", |
50 | | -// "description": "Response to 'continue' request.", |
51 | | -// "properties": { |
52 | | -// "body": { |
53 | | -// "type": "object", |
54 | | -// "properties": { |
55 | | -// "allThreadsContinued": { |
56 | | -// "type": "boolean", |
57 | | -// "description": "If true, the continue request has ignored the |
58 | | -// specified thread and continued all threads |
59 | | -// instead. If this attribute is missing a value |
60 | | -// of 'true' is assumed for backward |
61 | | -// compatibility." |
62 | | -// } |
63 | | -// } |
64 | | -// } |
65 | | -// }, |
66 | | -// "required": [ "body" ] |
67 | | -// }] |
68 | | -// } |
69 | | -void ContinueRequestHandler::operator()( |
70 | | - const llvm::json::Object &request) const { |
71 | | - llvm::json::Object response; |
72 | | - FillResponse(request, response); |
73 | | - lldb::SBProcess process = dap.target.GetProcess(); |
74 | | - lldb::SBError error = process.Continue(); |
75 | | - llvm::json::Object body; |
76 | | - body.try_emplace("allThreadsContinued", true); |
77 | | - response.try_emplace("body", std::move(body)); |
78 | | - dap.SendJSON(llvm::json::Value(std::move(response))); |
| 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 (args.singleThread) |
| 35 | + dap.GetLLDBThread(args.threadId).Resume(error); |
| 36 | + else |
| 37 | + error = process.Continue(); |
| 38 | + |
| 39 | + if (error.Fail()) |
| 40 | + return ToError(error); |
| 41 | + |
| 42 | + ContinueResponseBody body; |
| 43 | + body.allThreadsContinued = args.singleThread; |
| 44 | + return body; |
79 | 45 | } |
| 46 | + |
80 | 47 | } // namespace lldb_dap |
0 commit comments