From 37b0f0a5f9ccfad3853b3b25b1a89da2095aaac3 Mon Sep 17 00:00:00 2001 From: dengwenjun Date: Mon, 2 Jun 2025 11:03:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DsmartStepInto=E5=9C=A8?= =?UTF-8?q?=E6=9F=90=E4=BA=9B=E6=83=85=E5=86=B5=E4=B8=8B=EF=BC=8C=E6=96=AD?= =?UTF-8?q?=E7=82=B9=E5=A4=B1=E6=95=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.当使用smartStepInto进行调试时,方舟收到IDE传过来的断点信息,首先去进行校验该断点的有效性,若断点无效,则去找离其最近的有效断点(大于所给行且离其最近)。 2.校验找到的有效行是否在指定的方法内,若在,则进行断点,否则则失败。 Issue:https://gitee.com/openharmony/arkcompiler_toolchain/issues/ICBIEG Signed-off-by: dengwenjun --- tooling/agent/debugger_impl.cpp | 3 ++- tooling/base/pt_params.cpp | 10 ++++++++++ tooling/base/pt_params.h | 12 ++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 6862fabc..0a37fe9f 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -1422,7 +1422,8 @@ DispatchResponse DebuggerImpl::SetBreakpointByUrl(const SetBreakpointByUrlParams } return DebuggerApi::SetBreakpoint(jsDebugger_, location, condFuncRef, isSmartBreakpoint); }; - if (!extractor->MatchWithLocation(callbackFunc, lineNumber, columnNumber, url, GetRecordName(url))) { + if (!extractor->MatchWithLocation(callbackFunc, lineNumber, columnNumber, url, GetRecordName(url), + isSmartBreakpoint, params.GetMethodName())) { LOG_DEBUGGER(ERROR) << "failed to set breakpoint location number: " << lineNumber << ":" << columnNumber; return DispatchResponse::Fail("Breakpoint not found."); diff --git a/tooling/base/pt_params.cpp b/tooling/base/pt_params.cpp index 78c2acfd..a9139880 100644 --- a/tooling/base/pt_params.cpp +++ b/tooling/base/pt_params.cpp @@ -398,6 +398,13 @@ std::unique_ptr SetBreakpointByUrlParams::Create(const } else if (ret == Result::TYPE_ERROR) { error += "Wrong type of 'condition';"; } + std::string methodName; + ret = params.GetString("methodName", &methodName); + if (ret == Result::SUCCESS) { + paramsObject->methodName_ = std::move(methodName); + } else if (ret == Result::TYPE_ERROR) { + error += "Wrong type of 'methodName';"; + } if (!error.empty()) { LOG_DEBUGGER(ERROR) << "SetBreakpointByUrlParams::Create " << error; return nullptr; @@ -574,6 +581,9 @@ void SmartStepIntoParams::AddRequireParams(PtJson ¶ms) if (!params.Contains("condition")) { params.Add("condition", ""); } + if (!params.Contains("methodName")) { + params.Add("methodName", ""); + } } std::unique_ptr StepOverParams::Create(const PtJson ¶ms) diff --git a/tooling/base/pt_params.h b/tooling/base/pt_params.h index 880addf9..fcee1d45 100644 --- a/tooling/base/pt_params.h +++ b/tooling/base/pt_params.h @@ -357,6 +357,17 @@ public: return condition_.has_value(); } + bool HasMethodName() const + { + return methodName_.has_value(); + } + + const std::string &GetMethodName() const + { + ASSERT(HasMethodName()); + return methodName_.value(); + } + private: NO_COPY_SEMANTIC(SetBreakpointByUrlParams); NO_MOVE_SEMANTIC(SetBreakpointByUrlParams); @@ -367,6 +378,7 @@ private: std::optional scriptHash_ {}; std::optional columnNumber_ {0}; std::optional condition_ {}; + std::optional methodName_ {}; }; -- Gitee