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); }