brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · 6742c79 Raw
64 lines · cpp
1//===-- StepInRequestHandler.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/ProtocolRequests.h"13#include "Protocol/ProtocolTypes.h"14#include "RequestHandler.h"15 16using namespace llvm;17using namespace lldb;18using namespace lldb_dap::protocol;19 20namespace lldb_dap {21 22// The request resumes the given thread to step into a function/method and23// allows all other threads to run freely by resuming them. If the debug adapter24// supports single thread execution (see capability25// `supportsSingleThreadExecutionRequests`), setting the `singleThread` argument26// to true prevents other suspended threads from resuming. If the request cannot27// step into a target, `stepIn` behaves like the `next` request. The debug28// adapter first sends the response and then a `stopped` event (with reason29// `step`) after the step has completed. If there are multiple function/method30// calls (or other targets) on the source line, the argument `targetId` can be31// used to control into which target the `stepIn` should occur. The list of32// possible targets for a given source line can be retrieved via the33// `stepInTargets` request.34Error StepInRequestHandler::Run(const StepInArguments &args) const {35  SBThread thread = dap.GetLLDBThread(args.threadId);36  if (!thread.IsValid())37    return make_error<DAPError>("invalid thread");38 39  // Remember the thread ID that caused the resume so we can set the40  // "threadCausedFocus" boolean value in the "stopped" events.41  dap.focus_tid = thread.GetThreadID();42 43  if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))44    return make_error<NotStoppedError>();45 46  lldb::SBError error;47  if (args.granularity == eSteppingGranularityInstruction) {48    thread.StepInstruction(/*step_over=*/false, error);49    return ToError(error);50  }51 52  std::string step_in_target;53  auto it = dap.step_in_targets.find(args.targetId.value_or(0));54  if (it != dap.step_in_targets.end())55    step_in_target = it->second;56 57  RunMode run_mode = args.singleThread ? eOnlyThisThread : eOnlyDuringStepping;58  thread.StepInto(step_in_target.c_str(), LLDB_INVALID_LINE_NUMBER, error,59                  run_mode);60  return ToError(error);61}62 63} // namespace lldb_dap64