diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index 78e4391075317d2c10eb744e2da771342fb3d8ab..52564816af5868c435fe6d2196176767b34e8f6d 100755 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -167,8 +167,9 @@ void DebuggerImpl::SaveParsedScriptsAndUrl(const std::string &fileName, const st bool DebuggerImpl::NotifyScriptParsedBySendable(JSHandle method) { + JSThread *thread = vm_->GetJSThread(); // Find extractor and retrieve infos - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); if (jsPandaFile == nullptr) { LOG_DEBUGGER(ERROR) << "JSPandaFile is nullptr"; return false; @@ -195,7 +196,7 @@ bool DebuggerImpl::NotifyScriptParsedBySendable(JSHandle method) } // Parse and save this file const std::string &source = extractor->GetSourceCode(methodId); - const std::string &recordName = std::string(method->GetRecordNameStr()); + const std::string &recordName = std::string(method->GetRecordNameStr(thread)); SaveParsedScriptsAndUrl(fileName, url, recordName, source); return true; } @@ -2003,7 +2004,8 @@ bool DebuggerImpl::GenerateAsyncFrame(StackFrame *stackFrame, const FrameHandler } Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + JSThread *thread = vm_->GetJSThread(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(DEBUG) << "GenerateAsyncFrame: extractor is null"; @@ -2011,7 +2013,7 @@ bool DebuggerImpl::GenerateAsyncFrame(StackFrame *stackFrame, const FrameHandler } // functionName - std::string functionName = method->ParseFunctionName(); + std::string functionName = method->ParseFunctionName(thread); std::string url = extractor->GetSourceFile(methodId); int32_t scriptId = -1; @@ -2066,7 +2068,8 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, const FrameHandler *f } Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + JSThread *thread = vm_->GetJSThread(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(DEBUG) << "GenerateCallFrame: extractor is null"; @@ -2074,7 +2077,7 @@ bool DebuggerImpl::GenerateCallFrame(CallFrame *callFrame, const FrameHandler *f } // functionName - std::string functionName = method->ParseFunctionName(); + std::string functionName = method->ParseFunctionName(thread); // location std::unique_ptr location = std::make_unique(); @@ -2146,7 +2149,8 @@ std::unique_ptr DebuggerImpl::GetLocalScopeChain(const FrameHandler *fram Method *method = DebuggerApi::GetMethod(frameHandler); auto methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + JSThread *thread = vm_->GetJSThread(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(ERROR) << "GetScopeChain: extractor is null"; @@ -2198,9 +2202,9 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr std::vector> closureScopes; Method *method = DebuggerApi::GetMethod(frameHandler); EntityId methodId = method->GetMethodId(); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); - DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); JSThread *thread = vm_->GetJSThread(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); + DebugInfoExtractor *extractor = GetExtractor(jsPandaFile); if (extractor == nullptr) { LOG_DEBUGGER(ERROR) << "GetClosureScopeChains: extractor is null"; @@ -2219,14 +2223,15 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr bool thisFound = (*thisObj)->HasValue(); bool closureVarFound = false; // currentEnv = currentEnv->parent until currentEnv is not lexicalEnv - for (; currentEnv.IsLexicalEnv(); currentEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject())->GetParentEnv()) { + for (; currentEnv.IsLexicalEnv(); + currentEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject())->GetParentEnv(thread)) { LexicalEnv *lexicalEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject()); envHandle.Update(currentEnv); - if (lexicalEnv->GetScopeInfo().IsHole()) { + if (lexicalEnv->GetScopeInfo(thread).IsHole()) { continue; } auto closureScope = std::make_unique(); - auto result = JSNativePointer::Cast(lexicalEnv->GetScopeInfo().GetTaggedObject())->GetExternalPointer(); + auto result = JSNativePointer::Cast(lexicalEnv->GetScopeInfo(thread).GetTaggedObject())->GetExternalPointer(); ScopeDebugInfo *scopeDebugInfo = reinterpret_cast(result); std::unique_ptr closure = std::make_unique(); Local closureScopeObj = ObjectRef::New(vm_); @@ -2238,7 +2243,7 @@ std::vector> DebuggerImpl::GetClosureScopeChains(const Fr } currentEnv = envHandle.GetTaggedValue(); lexicalEnv = LexicalEnv::Cast(currentEnv.GetTaggedObject()); - valueHandle.Update(lexicalEnv->GetProperties(slot)); + valueHandle.Update(lexicalEnv->GetProperties(thread, slot)); Local value = JSNApiHelper::ToLocal(valueHandle); Local varName = StringRef::NewFromUtf8(vm_, name.c_str()); nameCount[name]++; diff --git a/tooling/backend/debugger_executor.cpp b/tooling/backend/debugger_executor.cpp index c7d2a6c0eccd0dad862658389a46cf137416bfc7..976ef29d86984f77854d5bad14fbec01a1e3d93a 100644 --- a/tooling/backend/debugger_executor.cpp +++ b/tooling/backend/debugger_executor.cpp @@ -167,7 +167,8 @@ Local DebuggerExecutor::GetLexicalValue(const EcmaVM *vm, const Fram { Local result; - auto [level, slot] = DebuggerApi::GetLevelSlot(frameHandler, name->ToString(vm)); + JSThread *thread = vm->GetJSThread(); + auto [level, slot] = DebuggerApi::GetLevelSlot(thread, frameHandler, name->ToString(vm)); if (level == -1) { return result; } @@ -180,7 +181,8 @@ bool DebuggerExecutor::SetLexicalValue(const EcmaVM *vm, const FrameHandler *fra Local name, Local value) { std::string varName = name->ToString(vm); - auto [level, slot] = DebuggerApi::GetLevelSlot(frameHandler, varName); + JSThread *thread = vm->GetJSThread(); + auto [level, slot] = DebuggerApi::GetLevelSlot(thread, frameHandler, varName); if (level == -1) { return false; } @@ -208,11 +210,11 @@ Local DebuggerExecutor::GetModuleValue(const EcmaVM *vm, const Frame Local result; std::string varName = name->ToString(vm); Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + JSThread *thread = vm->GetJSThread(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { return result; } - JSThread *thread = vm->GetJSThread(); JSHandle currentModule(thread, DebuggerApi::GetCurrentModule(vm)); if (currentModule->IsSourceTextModule()) { result = DebuggerApi::GetModuleValue(vm, currentModule, varName); @@ -225,11 +227,11 @@ bool DebuggerExecutor::SetModuleValue(const EcmaVM *vm, const FrameHandler *fram { std::string varName = name->ToString(vm); Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + JSThread *thread = vm->GetJSThread(); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(thread); if (jsPandaFile != nullptr && (jsPandaFile->IsBundlePack() || !jsPandaFile->IsNewVersion())) { return false; } - JSThread *thread = vm->GetJSThread(); JSHandle currentModule(thread, DebuggerApi::GetCurrentModule(vm)); bool result = false; if (currentModule->IsSourceTextModule()) {