diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 80e2064efe56947dcd9be7ddc1b3b1ea87d4f1fd..04759f97bb26bfd3839c828234f6671509e7eedd 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -131,6 +131,11 @@ bool DebuggerImpl::NotifySingleStep(const JSPtLocation &location) return false; } + if (singleStepper_->IsClearSingleStepper(location.GetBytecodeOffset())) { + singleStepper_.reset(); + return false; + } + // step not complete if (!singleStepper_->StepComplete(location.GetBytecodeOffset())) { return false; diff --git a/tooling/backend/js_single_stepper.cpp b/tooling/backend/js_single_stepper.cpp index 3e5555b9870038c5c3461bb26128cfbcd11fa1e9..9c1a5af16f374b841c6642bed0b9a29a7be5e895 100644 --- a/tooling/backend/js_single_stepper.cpp +++ b/tooling/backend/js_single_stepper.cpp @@ -72,6 +72,35 @@ bool SingleStepper::StepComplete(uint32_t bcOffset) const return true; } +bool SingleStepper::IsClearSingleStepper(uint32_t bcOffset) const +{ + std::unique_ptr ptMethod = DebuggerApi::GetMethod(ecmaVm_); + uint32_t stackDepth = GetStackDepth(); + + switch (type_) { + case Type::STEP_INTO: { + if (method_->GetJSPandaFile() != ptMethod->GetJSPandaFile() && stackDepth != stackDepth_ + 1) { + return true; + } + break; + } + case Type::STEP_OVER: { + if (method_->GetJSPandaFile() != ptMethod->GetJSPandaFile() && stackDepth <= stackDepth_) { + return true; + } + break; + } + case Type::STEP_OUT: { + break; + } + default: { + return false; + } + } + + return false; +} + std::unique_ptr SingleStepper::GetStepIntoStepper(const EcmaVM *ecmaVm) { return GetStepper(ecmaVm, SingleStepper::Type::STEP_INTO); diff --git a/tooling/backend/js_single_stepper.h b/tooling/backend/js_single_stepper.h index d098a26502a9ef3f37689b227740ea85d3522f72..61a019cfbb7c9e4e2f76aa5b41e6514341361180 100644 --- a/tooling/backend/js_single_stepper.h +++ b/tooling/backend/js_single_stepper.h @@ -40,6 +40,7 @@ public: NO_MOVE_SEMANTIC(SingleStepper); bool StepComplete(uint32_t bcOffset) const; + bool IsClearSingleStepper(uint32_t bcOffset) const; Type GetStepperType() const { return type_;