From 6e2b6e949a89127edd5b7e7ea2680b9cc2fc31fc Mon Sep 17 00:00:00 2001 From: huangfeijie Date: Wed, 14 Jun 2023 16:12:54 +0800 Subject: [PATCH] issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/I7DGU9 Bugfix for closure variables Bugfix for closure variables Signed-off-by: huangfeijie --- tooling/agent/debugger_impl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index fecfb8de..c464de75 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -1126,7 +1126,7 @@ void DebuggerImpl::GetClosureVariables(const FrameHandler *frameHandler, Local &localObj) { JSTaggedValue env = DebuggerApi::GetEnv(frameHandler); - if (env.IsTaggedArray() && DebuggerApi::GetBytecodeOffset(frameHandler) != 0) { + for (; env.IsTaggedArray(); env = LexicalEnv::Cast(env.GetTaggedObject())->GetParentEnv()) { LexicalEnv *lexEnv = LexicalEnv::Cast(env.GetTaggedObject()); if (lexEnv->GetScopeInfo().IsHole()) { return; @@ -1141,6 +1141,10 @@ void DebuggerImpl::GetClosureVariables(const FrameHandler *frameHandler, Local value = JSNApiHelper::ToLocal( JSHandle(thread, lexEnv->GetProperties(slot))); + if (value->IsFunction()) { + continue; + } + if (varName == "this") { if (thisVal->IsHole()) { LOG_DEBUGGER(INFO) << "find 'this' in current lexical env"; -- Gitee