diff --git a/ecmascript/napi/include/jsnapi.h b/ecmascript/napi/include/jsnapi.h index a65a826d..28256454 100644 --- a/ecmascript/napi/include/jsnapi.h +++ b/ecmascript/napi/include/jsnapi.h @@ -866,6 +866,7 @@ public: static void EnableUserUncaughtErrorHandler(EcmaVM *vm); static bool StartDebugger(const char *library_path, EcmaVM *vm, bool isDebugMode); + static bool StopDebugger(const char *library_path); // Serialize & Deserialize. static void* SerializeValue(const EcmaVM *vm, Local data, Local transfer); static Local DeserializeValue(const EcmaVM *vm, void* recoder); diff --git a/ecmascript/napi/jsnapi.cpp b/ecmascript/napi/jsnapi.cpp index a5f88fbd..20b742ca 100644 --- a/ecmascript/napi/jsnapi.cpp +++ b/ecmascript/napi/jsnapi.cpp @@ -239,6 +239,27 @@ bool JSNApi::StartDebugger(const char *library_path, EcmaVM *vm, bool isDebugMod return ret; } +bool JSNApi::StopDebugger(const char *library_path) +{ + auto handle = panda::os::library_loader::Load(std::string(library_path)); + if (!handle) { + return false; + } + + using StopDebug = void (*)(const std::string &); + + auto sym = panda::os::library_loader::ResolveSymbol(handle.Value(), "StopDebug"); + if (!sym) { + LOG(ERROR, RUNTIME) << sym.Error().ToString(); + return false; + } + + reinterpret_cast(sym.Value())("PandaDebugger"); + auto runtime = Runtime::GetCurrent(); + runtime->SetDebugMode(false); + return true; +} + bool JSNApi::Execute(EcmaVM *vm, Local fileName, Local entry) { std::string file = fileName->ToString();