brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.9 KiB · 2b48350 Raw
52 lines · cpp
1//===-- NextRequestHandler.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/ProtocolTypes.h"13#include "RequestHandler.h"14#include "llvm/Support/Error.h"15 16using namespace llvm;17using namespace lldb;18using namespace lldb_dap::protocol;19 20namespace lldb_dap {21 22/// The request executes one step (in the given granularity) for the specified23/// thread and allows all other threads to run freely by resuming them. If the24/// debug adapter supports single thread execution (see capability25/// `supportsSingleThreadExecutionRequests`), setting the `singleThread`26/// argument to true prevents other suspended threads from resuming. The debug27/// adapter first sends the response and then a `stopped` event (with reason28/// `step`) after the step has completed.29Error NextRequestHandler::Run(const NextArguments &args) const {30  lldb::SBThread thread = dap.GetLLDBThread(args.threadId);31  if (!thread.IsValid())32    return make_error<DAPError>("invalid thread");33 34  if (!SBDebugger::StateIsStoppedState(dap.target.GetProcess().GetState()))35    return make_error<NotStoppedError>();36 37  // Remember the thread ID that caused the resume so we can set the38  // "threadCausedFocus" boolean value in the "stopped" events.39  dap.focus_tid = thread.GetThreadID();40  lldb::SBError error;41  if (args.granularity == eSteppingGranularityInstruction) {42    thread.StepInstruction(/*step_over=*/true, error);43  } else {44    thread.StepOver(args.singleThread ? eOnlyThisThread : eOnlyDuringStepping,45                    error);46  }47 48  return ToError(error);49}50 51} // namespace lldb_dap52