|
8 | 8 |
|
9 | 9 | #include "DAP.h"
|
10 | 10 | #include "EventHelper.h"
|
11 |
| -#include "JSONUtils.h" |
| 11 | +#include "Protocol/ProtocolRequests.h" |
12 | 12 | #include "RequestHandler.h"
|
| 13 | +#include "llvm/Support/Error.h" |
| 14 | + |
| 15 | +using namespace llvm; |
| 16 | +using namespace lldb_dap::protocol; |
13 | 17 |
|
14 | 18 | namespace lldb_dap {
|
15 | 19 |
|
16 |
| -// "StepOutRequest": { |
17 |
| -// "allOf": [ { "$ref": "#/definitions/Request" }, { |
18 |
| -// "type": "object", |
19 |
| -// "description": "StepOut request; value of command field is 'stepOut'. The |
20 |
| -// request starts the debuggee to run again for one step. The debug adapter |
21 |
| -// first sends the StepOutResponse and then a StoppedEvent (event type |
22 |
| -// 'step') after the step has completed.", "properties": { |
23 |
| -// "command": { |
24 |
| -// "type": "string", |
25 |
| -// "enum": [ "stepOut" ] |
26 |
| -// }, |
27 |
| -// "arguments": { |
28 |
| -// "$ref": "#/definitions/StepOutArguments" |
29 |
| -// } |
30 |
| -// }, |
31 |
| -// "required": [ "command", "arguments" ] |
32 |
| -// }] |
33 |
| -// }, |
34 |
| -// "StepOutArguments": { |
35 |
| -// "type": "object", |
36 |
| -// "description": "Arguments for 'stepOut' request.", |
37 |
| -// "properties": { |
38 |
| -// "threadId": { |
39 |
| -// "type": "integer", |
40 |
| -// "description": "Execute 'stepOut' for this thread." |
41 |
| -// } |
42 |
| -// }, |
43 |
| -// "required": [ "threadId" ] |
44 |
| -// }, |
45 |
| -// "StepOutResponse": { |
46 |
| -// "allOf": [ { "$ref": "#/definitions/Response" }, { |
47 |
| -// "type": "object", |
48 |
| -// "description": "Response to 'stepOut' request. This is just an |
49 |
| -// acknowledgement, so no body field is required." |
50 |
| -// }] |
51 |
| -// } |
52 |
| -void StepOutRequestHandler::operator()( |
53 |
| - const llvm::json::Object &request) const { |
54 |
| - llvm::json::Object response; |
55 |
| - FillResponse(request, response); |
56 |
| - const auto *arguments = request.getObject("arguments"); |
57 |
| - lldb::SBThread thread = dap.GetLLDBThread(*arguments); |
58 |
| - if (thread.IsValid()) { |
59 |
| - // Remember the thread ID that caused the resume so we can set the |
60 |
| - // "threadCausedFocus" boolean value in the "stopped" events. |
61 |
| - dap.focus_tid = thread.GetThreadID(); |
62 |
| - thread.StepOut(); |
63 |
| - } else { |
64 |
| - response["success"] = llvm::json::Value(false); |
65 |
| - } |
66 |
| - dap.SendJSON(llvm::json::Value(std::move(response))); |
| 20 | +/// The request resumes the given thread to step out (return) from a |
| 21 | +/// function/method and allows all other threads to run freely by resuming |
| 22 | +/// them. |
| 23 | +/// |
| 24 | +/// If the debug adapter supports single thread execution (see capability |
| 25 | +/// `supportsSingleThreadExecutionRequests`), setting the `singleThread` |
| 26 | +/// argument to true prevents other suspended threads from resuming. |
| 27 | +/// |
| 28 | +/// The debug adapter first sends the response and then a `stopped` event (with |
| 29 | +/// reason `step`) after the step has completed." |
| 30 | +Error StepOutRequestHandler::Run(const StepOutArguments &arguments) const { |
| 31 | + lldb::SBThread thread = dap.GetLLDBThread(arguments.threadId); |
| 32 | + if (!thread.IsValid()) |
| 33 | + return make_error<DAPError>("invalid thread"); |
| 34 | + |
| 35 | + // Remember the thread ID that caused the resume so we can set the |
| 36 | + // "threadCausedFocus" boolean value in the "stopped" events. |
| 37 | + dap.focus_tid = thread.GetThreadID(); |
| 38 | + thread.StepOut(); |
| 39 | + |
| 40 | + return Error::success(); |
67 | 41 | }
|
68 | 42 |
|
69 | 43 | } // namespace lldb_dap
|
0 commit comments