diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 3d3ff4c131c1a57a5dfb5f1a971e8842f8c66258..208c0234c1eadfca4ff7df86de3bcc1d23d62a62 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -2077,6 +2077,7 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr std::unique_ptr closure = std::make_unique(); Local closureScopeObj = ObjectRef::New(vm_); + std::unordered_map nameCount; for (const auto &[name, slot] : scopeDebugInfo->scopeInfo) { if (IsVariableSkipped(name.c_str())) { continue; @@ -2086,6 +2087,11 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr valueHandle.Update(lexicalEnv->GetProperties(slot)); Local value = JSNApiHelper::ToLocal(valueHandle); Local varName = StringRef::NewFromUtf8(vm_, name.c_str()); + nameCount[name]++; + if (nameCount[name] > 1) { + CString fullName = name + "$" + ToCString(slot); + varName = StringRef::NewFromUtf8(vm_, fullName.c_str()); + } // found 'this' and 'this' is not set in GetLocalScopechain if (!thisFound && name == "this") { *thisObj = RemoteObject::FromTagged(vm_, value);