diff --git a/ecmascript/tooling/agent/debugger_impl.cpp b/ecmascript/tooling/agent/debugger_impl.cpp index 4b3347c940c7917b17a13d31351d385f8a749c0b..da2718e684547406b87993d6257082ca59fe2c8a 100644 --- a/ecmascript/tooling/agent/debugger_impl.cpp +++ b/ecmascript/tooling/agent/debugger_impl.cpp @@ -27,6 +27,7 @@ DebuggerImpl::DispatcherImpl::DispatcherImpl(FrontEnd *frontend, std::unique_ptr : DispatcherBase(frontend), debugger_(std::move(debugger)) { dispatcherTable_["enable"] = &DebuggerImpl::DispatcherImpl::Enable; + dispatcherTable_["disable"] = &DebuggerImpl::DispatcherImpl::Disable; dispatcherTable_["evaluateOnCallFrame"] = &DebuggerImpl::DispatcherImpl::EvaluateOnCallFrame; dispatcherTable_["getPossibleBreakpoints"] = &DebuggerImpl::DispatcherImpl::GetPossibleBreakpoints; dispatcherTable_["getScriptSource"] = &DebuggerImpl::DispatcherImpl::GetScriptSource; @@ -69,6 +70,12 @@ void DebuggerImpl::DispatcherImpl::Enable(const DispatchRequest &request) SendResponse(request, response, std::move(result)); } +void DebuggerImpl::DispatcherImpl::Disable(const DispatchRequest &request) +{ + DispatchResponse response = debugger_->Disable(); + SendResponse(request, response, nullptr); +} + void DebuggerImpl::DispatcherImpl::EvaluateOnCallFrame(const DispatchRequest &request) { std::unique_ptr params = @@ -226,6 +233,16 @@ DispatchResponse DebuggerImpl::Enable([[maybe_unused]] std::unique_ptr(backend_->GetEcmaVm()); + ecmaVm->GetJsDebuggerManager()->SetDebugMode(true); + backend_->NotifyAllScriptParsed(); + return DispatchResponse::Ok(); +} + +DispatchResponse DebuggerImpl::Disable() +{ + auto ecmaVm = const_cast(backend_->GetEcmaVm()); + ecmaVm->GetJsDebuggerManager()->SetDebugMode(false); return DispatchResponse::Ok(); } diff --git a/ecmascript/tooling/agent/debugger_impl.h b/ecmascript/tooling/agent/debugger_impl.h index 35e6fcda0f30afa5e52e658d5825078e3fb47342..564aaf78f55fb4bc116b7fb61d15022c88d883af 100644 --- a/ecmascript/tooling/agent/debugger_impl.h +++ b/ecmascript/tooling/agent/debugger_impl.h @@ -28,6 +28,7 @@ public: ~DebuggerImpl() = default; DispatchResponse Enable(std::unique_ptr params, UniqueDebuggerId *id); + DispatchResponse Disable(); DispatchResponse EvaluateOnCallFrame(std::unique_ptr params, std::unique_ptr *result); DispatchResponse GetPossibleBreakpoints(std::unique_ptr params, @@ -51,6 +52,7 @@ public: ~DispatcherImpl() override = default; void Dispatch(const DispatchRequest &request) override; void Enable(const DispatchRequest &request); + void Disable(const DispatchRequest &request); void EvaluateOnCallFrame(const DispatchRequest &request); void GetPossibleBreakpoints(const DispatchRequest &request); void GetScriptSource(const DispatchRequest &request); diff --git a/ecmascript/tooling/agent/runtime_impl.cpp b/ecmascript/tooling/agent/runtime_impl.cpp index 74f57a06a4e59f79650126350863350277661e31..474c6cd820fd6fb3a10e23baa3d8b8f37e9d9773 100644 --- a/ecmascript/tooling/agent/runtime_impl.cpp +++ b/ecmascript/tooling/agent/runtime_impl.cpp @@ -23,6 +23,7 @@ RuntimeImpl::DispatcherImpl::DispatcherImpl(FrontEnd *frontend, std::unique_ptr< : DispatcherBase(frontend), runtime_(std::move(runtime)) { dispatcherTable_["enable"] = &RuntimeImpl::DispatcherImpl::Enable; + dispatcherTable_["disable"] = &RuntimeImpl::DispatcherImpl::Disable; dispatcherTable_["getProperties"] = &RuntimeImpl::DispatcherImpl::GetProperties; dispatcherTable_["runIfWaitingForDebugger"] = &RuntimeImpl::DispatcherImpl::RunIfWaitingForDebugger; dispatcherTable_["callFunctionOn"] = &RuntimeImpl::DispatcherImpl::CallFunctionOn; @@ -49,6 +50,12 @@ void RuntimeImpl::DispatcherImpl::Enable(const DispatchRequest &request) SendResponse(request, response, nullptr); } +void RuntimeImpl::DispatcherImpl::Disable(const DispatchRequest &request) +{ + DispatchResponse response = runtime_->Disable(); + SendResponse(request, response, nullptr); +} + void RuntimeImpl::DispatcherImpl::RunIfWaitingForDebugger(const DispatchRequest &request) { DispatchResponse response = runtime_->RunIfWaitingForDebugger(); @@ -111,9 +118,11 @@ void RuntimeImpl::DispatcherImpl::GetHeapUsage(const DispatchRequest &request) DispatchResponse RuntimeImpl::Enable() { - auto ecmaVm = const_cast(backend_->GetEcmaVm()); - ecmaVm->GetJsDebuggerManager()->SetDebugMode(true); - backend_->NotifyAllScriptParsed(); + return DispatchResponse::Ok(); +} + +DispatchResponse RuntimeImpl::Disable() +{ return DispatchResponse::Ok(); } diff --git a/ecmascript/tooling/agent/runtime_impl.h b/ecmascript/tooling/agent/runtime_impl.h index c23264513d2c4f9d57901238105946eb17bfd028..1ca1f5c1574e3d65640df4999d1615ac0c15fee8 100644 --- a/ecmascript/tooling/agent/runtime_impl.h +++ b/ecmascript/tooling/agent/runtime_impl.h @@ -28,6 +28,7 @@ public: ~RuntimeImpl() = default; DispatchResponse Enable(); + DispatchResponse Disable(); DispatchResponse RunIfWaitingForDebugger(); DispatchResponse GetProperties( std::unique_ptr params, @@ -47,6 +48,7 @@ public: ~DispatcherImpl() override = default; void Dispatch(const DispatchRequest &request) override; + void Disable(const DispatchRequest &request); void Enable(const DispatchRequest &request); void RunIfWaitingForDebugger(const DispatchRequest &request); void GetProperties(const DispatchRequest &request); diff --git a/ecmascript/tooling/base/pt_events.cpp b/ecmascript/tooling/base/pt_events.cpp index 884a48c0e2563681b5d3d979f2ceecdebf37b1f5..d5d113749fdd5bb747166ac52e0b32f48f73f0f5 100644 --- a/ecmascript/tooling/base/pt_events.cpp +++ b/ecmascript/tooling/base/pt_events.cpp @@ -732,7 +732,6 @@ std::unique_ptr AddHeapSnapshotChunk::Create(char* data, i return addHeapSnapshotChunk; } - std::unique_ptr AddHeapSnapshotChunk::Create(const EcmaVM *ecmaVm, const Local ¶ms) {