From 8e59e820cf74d9a0b030b031149fa39e5f62d415 Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Fri, 16 Dec 2022 11:00:17 +0800 Subject: [PATCH 1/2] add import variables to module scope Issue:#I66E0O Signed-off-by: yang-19970325 Change-Id: I1427272f991bdbcf16e2c0193adf6f869ab192eb --- tooling/agent/debugger_impl.cpp | 5 +++-- tooling/backend/debugger_executor.cpp | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index e61c2816..d24ce70a 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -1036,8 +1036,9 @@ std::unique_ptr DebuggerImpl::GetModuleScopeChain() .SetDescription(RemoteObject::ObjectDescription); moduleScope->SetType(Scope::Type::Module()).SetObject(std::move(module)); runtime_->properties_[runtime_->curObjectId_++] = Global(vm_, moduleObj); - JSThread *thread = vm_->GetJSThread(); - DebuggerApi::GetModuleVariables(vm_, moduleObj, thread); + JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm_); + DebuggerApi::GetExportVariables(vm_, moduleObj, currentModule); + DebuggerApi::GetImportVariables(vm_, moduleObj, currentModule); return moduleScope; } diff --git a/tooling/backend/debugger_executor.cpp b/tooling/backend/debugger_executor.cpp index b1ae45a2..312b5c3e 100644 --- a/tooling/backend/debugger_executor.cpp +++ b/tooling/backend/debugger_executor.cpp @@ -205,7 +205,14 @@ Local DebuggerExecutor::GetModuleValue(const EcmaVM *vm, const Frame { Local result; std::string varName = name->ToString(); - result = DebuggerApi::GetModuleValue(vm, frameHandler, varName); + Method *method = DebuggerApi::GetMethod(frameHandler); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + if (jsPandaFile != nullptr && jsPandaFile->IsBundlePack()) { + return result; + } + + JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm); + result = DebuggerApi::GetModuleValue(vm, currentModule, varName); return result; } @@ -213,7 +220,14 @@ bool DebuggerExecutor::SetModuleValue(const EcmaVM *vm, const FrameHandler *fram Local name, Local value) { std::string varName = name->ToString(); - DebuggerApi::SetModuleValue(vm, frameHandler, varName, value); + Method *method = DebuggerApi::GetMethod(frameHandler); + const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); + if (jsPandaFile != nullptr && jsPandaFile->IsBundlePack()) { + return -1; + } + + JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm); + DebuggerApi::SetModuleValue(vm, currentModule, varName, value); return true; } } // namespace panda::ecmascript::tooling -- Gitee From 63d9ac928419eeb9a1728673dbf2c8950ed030bb Mon Sep 17 00:00:00 2001 From: yang-19970325 Date: Fri, 16 Dec 2022 20:08:31 +0800 Subject: [PATCH 2/2] fix asan_FUZZ Case failed Issue:#I66J4X Signed-off-by: yang-19970325 Change-Id: I5661b5c557186f644d3330ce6477296363dfb634 --- .../pttypesprivatepropertydesp_fuzzer/BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + .../BUILD.gn | 1 + tooling/agent/debugger_impl.cpp | 5 ++--- tooling/backend/debugger_executor.cpp | 18 ++---------------- 9 files changed, 11 insertions(+), 19 deletions(-) diff --git a/test/fuzztest/pttypesprivatepropertydesp_fuzzer/BUILD.gn b/test/fuzztest/pttypesprivatepropertydesp_fuzzer/BUILD.gn index de81dc70..3ae4f796 100755 --- a/test/fuzztest/pttypesprivatepropertydesp_fuzzer/BUILD.gn +++ b/test/fuzztest/pttypesprivatepropertydesp_fuzzer/BUILD.gn @@ -32,6 +32,7 @@ ohos_fuzztest("PtTypesPrivatePropertyDespFuzzTest") { "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//third_party/libuv:uv", sdk_libc_secshared_dep, ] } diff --git a/test/fuzztest/pttypesprivatepropertydespcreate_fuzzer/BUILD.gn b/test/fuzztest/pttypesprivatepropertydespcreate_fuzzer/BUILD.gn index 7202bf83..deb246dd 100755 --- a/test/fuzztest/pttypesprivatepropertydespcreate_fuzzer/BUILD.gn +++ b/test/fuzztest/pttypesprivatepropertydespcreate_fuzzer/BUILD.gn @@ -31,6 +31,7 @@ ohos_fuzztest("PtTypesPrivatePropertyDespCreateFuzzTest") { "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//third_party/libuv:uv", sdk_libc_secshared_dep, ] } diff --git a/test/fuzztest/pttypesprivatepropertydespget_fuzzer/BUILD.gn b/test/fuzztest/pttypesprivatepropertydespget_fuzzer/BUILD.gn index 17b5e1b8..179a1553 100755 --- a/test/fuzztest/pttypesprivatepropertydespget_fuzzer/BUILD.gn +++ b/test/fuzztest/pttypesprivatepropertydespget_fuzzer/BUILD.gn @@ -31,6 +31,7 @@ ohos_fuzztest("PtTypesPrivatePropertyDespGetFuzzTest") { "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//third_party/libuv:uv", sdk_libc_secshared_dep, ] } diff --git a/test/fuzztest/pttypesprivatepropertydespname_fuzzer/BUILD.gn b/test/fuzztest/pttypesprivatepropertydespname_fuzzer/BUILD.gn index 1859c76c..4dab358c 100755 --- a/test/fuzztest/pttypesprivatepropertydespname_fuzzer/BUILD.gn +++ b/test/fuzztest/pttypesprivatepropertydespname_fuzzer/BUILD.gn @@ -31,6 +31,7 @@ ohos_fuzztest("PtTypesPrivatePropertyDespNameFuzzTest") { "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//third_party/libuv:uv", sdk_libc_secshared_dep, ] } diff --git a/test/fuzztest/pttypesprivatepropertydespset_fuzzer/BUILD.gn b/test/fuzztest/pttypesprivatepropertydespset_fuzzer/BUILD.gn index 8d727dde..04173090 100755 --- a/test/fuzztest/pttypesprivatepropertydespset_fuzzer/BUILD.gn +++ b/test/fuzztest/pttypesprivatepropertydespset_fuzzer/BUILD.gn @@ -31,6 +31,7 @@ ohos_fuzztest("PtTypesPrivatePropertyDespSetFuzzTest") { "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//third_party/libuv:uv", sdk_libc_secshared_dep, ] } diff --git a/test/fuzztest/pttypesprivatepropertydesptojson_fuzzer/BUILD.gn b/test/fuzztest/pttypesprivatepropertydesptojson_fuzzer/BUILD.gn index 347383e7..3508c980 100755 --- a/test/fuzztest/pttypesprivatepropertydesptojson_fuzzer/BUILD.gn +++ b/test/fuzztest/pttypesprivatepropertydesptojson_fuzzer/BUILD.gn @@ -31,6 +31,7 @@ ohos_fuzztest("PtTypesPrivatePropertyDespToJsonFuzzTest") { "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//third_party/libuv:uv", sdk_libc_secshared_dep, ] } diff --git a/test/fuzztest/pttypesprivatepropertydespvalue_fuzzer/BUILD.gn b/test/fuzztest/pttypesprivatepropertydespvalue_fuzzer/BUILD.gn index 855b4416..89021933 100755 --- a/test/fuzztest/pttypesprivatepropertydespvalue_fuzzer/BUILD.gn +++ b/test/fuzztest/pttypesprivatepropertydespvalue_fuzzer/BUILD.gn @@ -31,6 +31,7 @@ ohos_fuzztest("PtTypesPrivatePropertyDespValueFuzzTest") { "//arkcompiler/ets_runtime:libark_jsruntime", "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//base/hiviewdfx/hilog/interfaces/native/innerkits:libhilog", + "//third_party/libuv:uv", sdk_libc_secshared_dep, ] } diff --git a/tooling/agent/debugger_impl.cpp b/tooling/agent/debugger_impl.cpp index d24ce70a..e61c2816 100644 --- a/tooling/agent/debugger_impl.cpp +++ b/tooling/agent/debugger_impl.cpp @@ -1036,9 +1036,8 @@ std::unique_ptr DebuggerImpl::GetModuleScopeChain() .SetDescription(RemoteObject::ObjectDescription); moduleScope->SetType(Scope::Type::Module()).SetObject(std::move(module)); runtime_->properties_[runtime_->curObjectId_++] = Global(vm_, moduleObj); - JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm_); - DebuggerApi::GetExportVariables(vm_, moduleObj, currentModule); - DebuggerApi::GetImportVariables(vm_, moduleObj, currentModule); + JSThread *thread = vm_->GetJSThread(); + DebuggerApi::GetModuleVariables(vm_, moduleObj, thread); return moduleScope; } diff --git a/tooling/backend/debugger_executor.cpp b/tooling/backend/debugger_executor.cpp index 312b5c3e..b1ae45a2 100644 --- a/tooling/backend/debugger_executor.cpp +++ b/tooling/backend/debugger_executor.cpp @@ -205,14 +205,7 @@ Local DebuggerExecutor::GetModuleValue(const EcmaVM *vm, const Frame { Local result; std::string varName = name->ToString(); - Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); - if (jsPandaFile != nullptr && jsPandaFile->IsBundlePack()) { - return result; - } - - JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm); - result = DebuggerApi::GetModuleValue(vm, currentModule, varName); + result = DebuggerApi::GetModuleValue(vm, frameHandler, varName); return result; } @@ -220,14 +213,7 @@ bool DebuggerExecutor::SetModuleValue(const EcmaVM *vm, const FrameHandler *fram Local name, Local value) { std::string varName = name->ToString(); - Method *method = DebuggerApi::GetMethod(frameHandler); - const JSPandaFile *jsPandaFile = method->GetJSPandaFile(); - if (jsPandaFile != nullptr && jsPandaFile->IsBundlePack()) { - return -1; - } - - JSTaggedValue currentModule = DebuggerApi::GetCurrentModule(vm); - DebuggerApi::SetModuleValue(vm, currentModule, varName, value); + DebuggerApi::SetModuleValue(vm, frameHandler, varName, value); return true; } } // namespace panda::ecmascript::tooling -- Gitee