Fix cocos debugging stuck

Issue:#I6KYVY

Signed-off-by: yangyang <yangyang585@huawei.com>
Change-Id: Ibba9256ad7c05d349f9f8fb611c6f584a45857a4
This commit is contained in:
yangyang 2023-03-08 15:57:31 +08:00
parent 4a79dda7f0
commit 66acc10ad0
6 changed files with 23 additions and 5 deletions

View File

@ -113,6 +113,9 @@ bool DebuggerApi::IsNativeMethod(const EcmaVM *ecmaVm)
bool DebuggerApi::IsNativeMethod(const FrameHandler *frameHandler)
{
if (!frameHandler->HasFrame()) {
return false;
}
Method* method = frameHandler->GetMethod();
return method->IsNativeWithCallField();
}
@ -213,6 +216,11 @@ bool DebuggerApi::RemoveBreakpoint(JSDebugger *debugger, const JSPtLocation &loc
return debugger->RemoveBreakpoint(location);
}
void DebuggerApi::RemoveAllBreakpoints(JSDebugger *debugger)
{
return debugger->RemoveAllBreakpoints();
}
// ScopeInfo
Local<JSValueRef> DebuggerApi::GetProperties(const EcmaVM *ecmaVm, const FrameHandler *frameHandler,
int32_t level, uint32_t slot)
@ -694,9 +702,11 @@ Local<JSValueRef> DebuggerApi::EvaluateViaFuncCall(EcmaVM *ecmaVm, Local<Functio
bool prevDebugMode = mgr->IsDebugMode();
mgr->SetEvalFrameHandler(frameHandler);
mgr->SetDebugMode(false); // in order to catch exception
ecmaVm->GetJSThread()->CheckSwitchDebuggerBCStub();
std::vector<Local<JSValueRef>> args;
auto result = funcRef->Call(ecmaVm, JSValueRef::Undefined(ecmaVm), args.data(), args.size());
mgr->SetDebugMode(prevDebugMode);
ecmaVm->GetJSThread()->CheckSwitchDebuggerBCStub();
mgr->SetEvalFrameHandler(nullptr);
return result;

View File

@ -113,6 +113,7 @@ public:
static bool SetBreakpoint(JSDebugger *debugger, const JSPtLocation &location,
Local<FunctionRef> condFuncRef);
static bool RemoveBreakpoint(JSDebugger *debugger, const JSPtLocation &location);
static void RemoveAllBreakpoints(JSDebugger *debugger);
static void HandleUncaughtException(const EcmaVM *ecmaVm, std::string &message);
static Local<JSValueRef> EvaluateViaFuncCall(EcmaVM *ecmaVm, Local<FunctionRef> funcRef,
std::shared_ptr<FrameHandler> &frameHandler);

View File

@ -66,6 +66,11 @@ bool JSDebugger::RemoveBreakpoint(const JSPtLocation &location)
return true;
}
void JSDebugger::RemoveAllBreakpoints()
{
breakpoints_.clear();
}
void JSDebugger::BytecodePcChanged(JSThread *thread, JSHandle<Method> method, uint32_t bcOffset)
{
ASSERT(bcOffset < method->GetCodeSize() && "code size of current Method less then bcOffset");

View File

@ -118,6 +118,7 @@ public:
bool SetBreakpoint(const JSPtLocation &location, Local<FunctionRef> condFuncRef) override;
bool RemoveBreakpoint(const JSPtLocation &location) override;
void RemoveAllBreakpoints() override;
void BytecodePcChanged(JSThread *thread, JSHandle<Method> method, uint32_t bcOffset) override;
void LoadModule(std::string_view filename, std::string_view entryPoint) override
{

View File

@ -95,13 +95,11 @@ public:
/**
* \brief Register debug hooks in the ecmavm
* @param hooks Pointer to object that implements PtHooks interface
* @return Error if any errors occur
*/
virtual void RegisterHooks(PtHooks *hooks) = 0;
/**
* \brief Unregister debug hooks in the ecmavm
* @return Error if any errors occur
*/
virtual void UnregisterHooks() = 0;
@ -120,6 +118,12 @@ public:
*/
virtual bool RemoveBreakpoint(const JSPtLocation &location) = 0;
/**
* \brief Remove all breakpoints from \param location
* @param location Breakpoint location
*/
virtual void RemoveAllBreakpoints() = 0;
virtual ~JSDebugInterface() = default;
NO_COPY_SEMANTIC(JSDebugInterface);

View File

@ -60,9 +60,6 @@ public:
}
isDebugMode_ = isDebugMode;
if (jsThread_ != nullptr && jsThread_->IsAsmInterpreter()) {
jsThread_->CheckSwitchDebuggerBCStub();
}
}
bool IsDebugMode() const