diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index dff76364e4d1b41fd337e34009b4f6636399beed..262fe864529c82d686fc39d17286623b252982d1 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -1716,5 +1716,14 @@ void JsRuntime::RegisterUncaughtExceptionHandler(void* uncaughtExceptionInfo) CHECK_POINTER(jsEnv_); jsEnv_->RegisterUncaughtExceptionHandler(*static_cast(uncaughtExceptionInfo)); } + +DebuggerPostTask JsRuntime::GetDebuggerPostTask() +{ + if (!jsEnv_) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "jsEnv_ is nullptr"); + return nullptr; + } + return jsEnv_->GetDebuggerPostTask(); +} } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/runtime/sts_runtime.cpp b/frameworks/native/runtime/sts_runtime.cpp index d84c6d2eb4154b512c0c1570e52899ce70943968..390936991d4ca0bf60685f3d4df313d9136bf8f5 100644 --- a/frameworks/native/runtime/sts_runtime.cpp +++ b/frameworks/native/runtime/sts_runtime.cpp @@ -210,6 +210,8 @@ private: AppLibPathVec STSRuntime::appLibPaths_; +AbilityRuntime::JsRuntime* STSRuntime::jsRuntime_ = nullptr; + std::unique_ptr STSRuntime::PreFork(const Options& options) { TAG_LOGD(AAFwkTag::STSRUNTIME, "PreFork begin"); @@ -254,6 +256,7 @@ void STSRuntime::PostFork(const Options &options, std::vector& aniOp std::unique_ptr STSRuntime::Create(const Options& options, JsRuntime* jsRuntime) { + STSRuntime::jsRuntime_ = static_cast(jsRuntime); TAG_LOGD(AAFwkTag::STSRUNTIME, "create ets runtime"); std::unique_ptr instance; auto preloadedInstance = Runtime::GetPreloaded(options.lang); @@ -391,7 +394,9 @@ void STSRuntime::DebuggerConnectionHandler(bool isDebugApp, bool isStartWithDebu TAG_LOGE(AAFwkTag::STSRUNTIME, "null stsEnv"); return; } - ark::ArkDebugNativeAPI::NotifyDebugMode(getproctid(), instanceId_, isStartWithDebug); + ark::ArkDebugNativeAPI::NotifyDebugMode(getproctid(), instanceId_, isStartWithDebug, + STSRuntime::jsRuntime_->GetEcmaVm(), + STSRuntime::jsRuntime_->GetDebuggerPostTask()); } void STSRuntime::UnLoadSTSAppLibrary() @@ -721,7 +726,7 @@ void STSRuntime::StopDebugMode() CHECK_POINTER(stsEnv_); if (stsEnv_->debugMode_) { ConnectServerManager::Get().RemoveInstance(instanceId_); - ark::ArkDebugNativeAPI::StopDebugger(); + ark::ArkDebugNativeAPI::StopDebugger(STSRuntime::jsRuntime_->GetEcmaVm()); } } diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index fbf74d0440fe7f680d6d775854aa89803f73fa24..04f8cbca8320277fffb81a93e2717270f090e2ad 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -159,6 +159,7 @@ public: void UpdatePkgContextInfoJson(const std::string& moduleName, const std::string& hapPath, const std::string& packageName); void RegisterUncaughtExceptionHandler(void* uncaughtExceptionInfo) override; + DebuggerPostTask GetDebuggerPostTask(); private: void FinishPreload() override; diff --git a/interfaces/inner_api/runtime/include/sts_runtime.h b/interfaces/inner_api/runtime/include/sts_runtime.h index 020b34d627b0a790df57d5daa47e8e846fc1063e..ca5a74bb2083ac19c97ddece2763eb7240d3d8d8 100644 --- a/interfaces/inner_api/runtime/include/sts_runtime.h +++ b/interfaces/inner_api/runtime/include/sts_runtime.h @@ -137,6 +137,7 @@ private: void StopDebugMode(); public: + static AbilityRuntime::JsRuntime* jsRuntime_; bool debugMode_ = false; // std::mutex mutex_; };