fix cppcrash when exit

Signed-off-by: h00611971 <huangfeijie@huawei.com>
This commit is contained in:
h00611971
2021-12-24 16:08:10 +08:00
parent 4884f69792
commit 03595c9cda
2 changed files with 22 additions and 0 deletions
+1
View File
@@ -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<JSValueRef> data, Local<JSValueRef> transfer);
static Local<JSValueRef> DeserializeValue(const EcmaVM *vm, void* recoder);
+21
View File
@@ -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<StopDebug>(sym.Value())("PandaDebugger");
auto runtime = Runtime::GetCurrent();
runtime->SetDebugMode(false);
return true;
}
bool JSNApi::Execute(EcmaVM *vm, Local<StringRef> fileName, Local<StringRef> entry)
{
std::string file = fileName->ToString();