From 643b350ea6da1892e74c0cd9c4419a6aeaaf16d8 Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Wed, 27 Sep 2023 16:10:26 +0800 Subject: [PATCH] Signed-off-by: yang-19970325 Change-Id: Ib20f8ccf6e0578fea615f433606c41442160f55c Change-Id: Ia5f9647756469a955e474aca2a66b2aa32d89fb7 --- tooling/agent/debugger_impl.cpp | 5 +++++ tooling/backend/js_single_stepper.cpp | 29 +++++++++++++++++++++++++++ tooling/backend/js_single_stepper.h | 1 + 3 files changed, 35 insertions(+) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 80e2064e..04759f97 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 3e5555b9..9c1a5af1 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 d098a265..61a019cf 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_; -- Gitee