1//===-- StepOutRequestHandler.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 "EventHelper.h"
11#include "LLDBUtils.h"
12#include "Protocol/ProtocolRequests.h"
13#include "RequestHandler.h"
14#include "llvm/Support/Error.h"
15
16using namespace llvm;
17using namespace lldb_dap::protocol;
18
19namespace lldb_dap {
20
21/// The request resumes the given thread to step out (return) from a
22/// function/method and allows all other threads to run freely by resuming
23/// them.
24///
25/// If the debug adapter supports single thread execution (see capability
26/// `supportsSingleThreadExecutionRequests`), setting the `singleThread`
27/// argument to true prevents other suspended threads from resuming.
28///
29/// The debug adapter first sends the response and then a `stopped` event (with
30/// reason `step`) after the step has completed."
31Error StepOutRequestHandler::Run(const StepOutArguments &arguments) const {
32 lldb::SBThread thread = dap.GetLLDBThread(id: arguments.threadId);
33 if (!thread.IsValid())
34 return make_error<DAPError>(Args: "invalid thread");
35
36 if (!lldb::SBDebugger::StateIsStoppedState(
37 state: dap.target.GetProcess().GetState()))
38 return make_error<NotStoppedError>();
39
40 // Remember the thread ID that caused the resume so we can set the
41 // "threadCausedFocus" boolean value in the "stopped" events.
42 dap.focus_tid = thread.GetThreadID();
43 lldb::SBError error;
44 thread.StepOut(error);
45
46 return ToError(error);
47}
48
49} // namespace lldb_dap
50

source code of lldb/tools/lldb-dap/Handler/StepOutRequestHandler.cpp