!6998 fix cppcrash while teminate worker

Merge pull request !6998 from fangting/master
This commit is contained in:
openharmony_ci 2024-04-23 06:13:50 +00:00 committed by Gitee
commit 5a8303acb6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 15 additions and 4 deletions

View File

@ -36,4 +36,12 @@ namespace panda::ecmascript::tooling {
}
return jsDebuggerManagerMap_[tid];
}
void JsDebuggerManager::DeleteJsDebuggerManager(int tid)
{
std::unique_lock<std::shared_mutex> lock(mutex_);
auto it = jsDebuggerManagerMap_.find(tid);
if (it != jsDebuggerManagerMap_.end()) {
jsDebuggerManagerMap_.erase(it);
}
}
} // namespace panda::ecmascript::tooling

View File

@ -212,6 +212,7 @@ public:
static void AddJsDebuggerManager(int tid, JsDebuggerManager *jsDebuggerManager);
static JsDebuggerManager* GetJsDebuggerManager(int tid);
static void DeleteJsDebuggerManager(int tid);
private:
bool isDebugMode_ {false};

View File

@ -105,7 +105,7 @@ using DebuggerPostTask = std::function<void(std::function<void()> &&)>;
extern "C" {
bool StartDebug(const std::string& componentName, void* vm, bool isDebugMode, int32_t instanceId,
const DebuggerPostTask& debuggerPostTask, int port);
void StopDebug(const std::string& componentName);
void StopDebug(void* vm);
void WaitForDebugger(void* vm);
}
} // namespace OHOS::ArkCompiler::Toolchain

View File

@ -3610,7 +3610,7 @@ bool JSNApi::StopDebugger([[maybe_unused]] EcmaVM *vm)
const auto &handle = vm->GetJsDebuggerManager()->GetDebugLibraryHandle();
using StopDebug = void (*)(const std::string &);
using StopDebug = void (*)(void *);
auto sym = panda::os::library_loader::ResolveSymbol(handle, "StopDebug");
if (!sym) {
@ -3618,9 +3618,11 @@ bool JSNApi::StopDebugger([[maybe_unused]] EcmaVM *vm)
return false;
}
reinterpret_cast<StopDebug>(sym.Value())("PandaDebugger");
reinterpret_cast<StopDebug>(sym.Value())(vm);
vm->GetJsDebuggerManager()->SetDebugMode(false);
int tid = vm->GetTid();
JsDebuggerManager::DeleteJsDebuggerManager(tid);
return true;
#else
if (vm == nullptr) {
@ -3628,7 +3630,7 @@ bool JSNApi::StopDebugger([[maybe_unused]] EcmaVM *vm)
}
CROSS_THREAD_AND_EXCEPTION_CHECK_WITH_RETURN(vm, false);
OHOS::ArkCompiler::Toolchain::StopDebug(DEBUGGER_NAME);
OHOS::ArkCompiler::Toolchain::StopDebug(vm);
vm->GetJsDebuggerManager()->SetDebugMode(false);
return true;
#endif // PANDA_TARGET_IOS