From fb072ae0f0549cfa3c19156488ba0b2c3451fe88 Mon Sep 17 00:00:00 2001 From: wanghuan2022 Date: Thu, 21 Dec 2023 22:11:33 +0800 Subject: [PATCH] =?UTF-8?q?[Bug]:=20=E4=BF=AE=E5=A4=8Drelease=E5=BA=94?= =?UTF-8?q?=E7=94=A8=E5=BD=95=E5=88=B6heapProfiler=E6=9C=9F=E9=97=B4?= =?UTF-8?q?=E5=88=9B=E5=BB=BAworker=EF=BC=8C=E4=B8=8D=E4=BC=9AwaitForDebug?= =?UTF-8?q?ger=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit desc: 修复release应用录制heapProfiler期间创建worker,不会waitForDebugger的问题 solu: 调整waitForDebugger的判断 && 去掉多余参数 issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8QDCY Signed-off-by: wanghuan2022 Change-Id: I575bb8a89f1f2ca3d06371b28da0909efa4b7526 --- frameworks/native/runtime/js_runtime.cpp | 2 +- frameworks/native/runtime/js_worker.cpp | 3 +-- .../js_environment/src/js_environment.cpp | 20 +++++-------------- .../interfaces/inner_api/js_environment.h | 4 ++-- .../js_environment_test.cpp | 4 ++-- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index 5a447cf78a..6e84a4f0e3 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -363,7 +363,7 @@ void JsRuntime::StartProfiler( } HILOG_DEBUG("profiler:%{public}d interval:%{public}d.", profiler, interval); - jsEnv_->StartProfiler(ARK_DEBUGGER_LIB_PATH, instanceId_, profiler, interval, gettid()); + jsEnv_->StartProfiler(ARK_DEBUGGER_LIB_PATH, instanceId_, profiler, interval, gettid(), isDebugApp); } bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector& buffer) diff --git a/frameworks/native/runtime/js_worker.cpp b/frameworks/native/runtime/js_worker.cpp index e2082bc816..9ef1471ba2 100644 --- a/frameworks/native/runtime/js_worker.cpp +++ b/frameworks/native/runtime/js_worker.cpp @@ -97,8 +97,7 @@ void InitWorkerFunc(NativeEngine* nativeEngine) }; panda::JSNApi::DebugOption debugOption = {ARK_DEBUGGER_LIB_PATH, needBreakPoint}; auto vm = const_cast(arkNativeEngine->GetEcmaVm()); - panda::JSNApi::NotifyDebugMode( - instanceId, vm, ARK_DEBUGGER_LIB_PATH, debugOption, instanceId, workerPostTask, g_debugApp, needBreakPoint); + panda::JSNApi::NotifyDebugMode(instanceId, vm, debugOption, instanceId, workerPostTask, g_debugApp); } } diff --git a/js_environment/frameworks/js_environment/src/js_environment.cpp b/js_environment/frameworks/js_environment/src/js_environment.cpp index 1acf7b9329..b54a7cd0d5 100644 --- a/js_environment/frameworks/js_environment/src/js_environment.cpp +++ b/js_environment/frameworks/js_environment/src/js_environment.cpp @@ -178,17 +178,7 @@ bool JsEnvironment::StartDebugger( JSENV_LOG_E("Abnormal parsing of tid results."); return false; } - panda::JSNApi::DebugOption debugOption = {libraryPath, needBreakPoint}; - auto debuggerPostTask = [weak = weak_from_this()](std::function&& task) { - auto jsEnv = weak.lock(); - if (jsEnv == nullptr) { - JSENV_LOG_E("JsEnv is invalid."); - return; - } - jsEnv->PostTask(task, "JsEnvironment:StartDebugger"); - }; - debugMode_ = panda::JSNApi::StartDebuggerForSocketPair( - static_cast(identifierId), debugOption, socketFd, debuggerPostTask); + debugMode_ = panda::JSNApi::StartDebuggerForSocketPair(static_cast(identifierId), socketFd); return debugMode_; } @@ -260,7 +250,7 @@ bool JsEnvironment::LoadScript(const std::string& path, uint8_t* buffer, size_t } void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId, PROFILERTYPE profiler, - int32_t interval, uint32_t tid) + int32_t interval, uint32_t tid, bool isDebugApp) { if (vm_ == nullptr) { JSENV_LOG_E("Invalid vm."); @@ -281,7 +271,7 @@ void JsEnvironment::StartProfiler(const char* libraryPath, uint32_t instanceId, option.profilerType = ConvertProfilerType(profiler); option.interval = interval; - panda::DFXJSNApi::StartProfiler(vm_, option, tid, instanceId, debuggerPostTask); + panda::DFXJSNApi::StartProfiler(vm_, option, tid, instanceId, debuggerPostTask, isDebugApp); } void JsEnvironment::DestroyHeapProfiler() @@ -331,7 +321,7 @@ void JsEnvironment::NotifyDebugMode( JSENV_LOG_E("Invalid vm."); return; } - panda::JSNApi::DebugOption debugOption = {libraryPath, debugMode}; + panda::JSNApi::DebugOption debugOption = {libraryPath, debug ? debugMode : false}; auto debuggerPostTask = [weak = weak_from_this()](std::function&& task) { auto jsEnv = weak.lock(); if (jsEnv == nullptr) { @@ -340,7 +330,7 @@ void JsEnvironment::NotifyDebugMode( } jsEnv->PostTask(task, "JsEnvironment:NotifyDebugMode"); }; - panda::JSNApi::NotifyDebugMode(tid, vm_, libraryPath, debugOption, instanceId, debuggerPostTask, debug, debugMode); + panda::JSNApi::NotifyDebugMode(tid, vm_, debugOption, instanceId, debuggerPostTask, debug); } int32_t JsEnvironment::ParseHdcRegisterOption(std::string& option) diff --git a/js_environment/interfaces/inner_api/js_environment.h b/js_environment/interfaces/inner_api/js_environment.h index e4cafb8869..801160b8cc 100644 --- a/js_environment/interfaces/inner_api/js_environment.h +++ b/js_environment/interfaces/inner_api/js_environment.h @@ -85,8 +85,8 @@ public: bool LoadScript(const std::string& path, uint8_t* buffer, size_t len, bool isBundle); - void StartProfiler( - const char* libraryPath, uint32_t instanceId, PROFILERTYPE profiler, int32_t interval, uint32_t tid); + void StartProfiler(const char* libraryPath, + uint32_t instanceId, PROFILERTYPE profiler, int32_t interval, uint32_t tid, bool isDebugApp); void DestroyHeapProfiler(); diff --git a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp index 41e275f136..642a6465d7 100644 --- a/js_environment/test/unittest/js_environment_test/js_environment_test.cpp +++ b/js_environment/test/unittest/js_environment_test/js_environment_test.cpp @@ -311,7 +311,7 @@ HWTEST_F(JsEnvironmentTest, StartProfiler_0100, TestSize.Level1) ASSERT_NE(jsEnv, nullptr); const char* libraryPath = "LIBRARYPATH"; - jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_CPU, 0, 0); + jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_CPU, 0, 0, true); ASSERT_EQ(jsEnv->GetVM(), nullptr); } @@ -330,7 +330,7 @@ HWTEST_F(JsEnvironmentTest, StartProfiler_0200, TestSize.Level1) ASSERT_EQ(ret, true); const char* libraryPath = "LIBRARYPATH"; - jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_HEAP, 0, 0); + jsEnv->StartProfiler(libraryPath, 0, JsEnvironment::PROFILERTYPE::PROFILERTYPE_HEAP, 0, 0, true); ASSERT_NE(jsEnv->GetVM(), nullptr); }