From c9e3a0150c4fe97675a798173af32c19b9a7fbe0 Mon Sep 17 00:00:00 2001 From: wengchangcheng Date: Sat, 28 May 2022 10:08:52 +0800 Subject: [PATCH] Descriptor: fix profiler dependent debugger details: add ProfilerNotify without check debug mode issue: https://gitee.com/openharmony/ark_js_runtime/issues/I59OYR Signed-off-by: wengchangcheng Change-Id: I9bd2a88ff032e3d8f113a436e86fd397fac73770 --- ecmascript/tooling/agent/heapprofiler_impl.h | 4 ++-- ecmascript/tooling/front_end.h | 1 + ecmascript/tooling/protocol_handler.cpp | 10 +++++++++- ecmascript/tooling/protocol_handler.h | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ecmascript/tooling/agent/heapprofiler_impl.h b/ecmascript/tooling/agent/heapprofiler_impl.h index 38bb317fc..bc2d77aa4 100644 --- a/ecmascript/tooling/agent/heapprofiler_impl.h +++ b/ecmascript/tooling/agent/heapprofiler_impl.h @@ -100,7 +100,7 @@ public: bool WriteChunk(char* data, int size) override { auto ecmaVm = static_cast(frontend_)->GetEcmaVM(); - frontend_->SendNotification(ecmaVm, AddHeapSnapshotChunk::Create(data, size)); + frontend_->SendProfilerNotify(ecmaVm, AddHeapSnapshotChunk::Create(data, size)); return true; } bool Good() override @@ -129,7 +129,7 @@ public: if (done == total) { reportHeapSnapshotProgress->SetFinished(true); } - frontend_->SendNotification(ecmaVm, std::move(reportHeapSnapshotProgress)); + frontend_->SendProfilerNotify(ecmaVm, std::move(reportHeapSnapshotProgress)); } private: diff --git a/ecmascript/tooling/front_end.h b/ecmascript/tooling/front_end.h index 826af75ba..b41870a4d 100644 --- a/ecmascript/tooling/front_end.h +++ b/ecmascript/tooling/front_end.h @@ -32,6 +32,7 @@ public: virtual void SendResponse(const DispatchRequest &request, const DispatchResponse &response, std::unique_ptr result) = 0; virtual void SendNotification(const EcmaVM *ecmaVm, std::unique_ptr events) = 0; + virtual void SendProfilerNotify(const EcmaVM *ecmaVm, std::unique_ptr events) = 0; private: NO_COPY_SEMANTIC(FrontEnd); diff --git a/ecmascript/tooling/protocol_handler.cpp b/ecmascript/tooling/protocol_handler.cpp index f64a399b0..3d7c560d7 100644 --- a/ecmascript/tooling/protocol_handler.cpp +++ b/ecmascript/tooling/protocol_handler.cpp @@ -77,7 +77,15 @@ void ProtocolHandler::SendResponse(const DispatchRequest &request, const Dispatc void ProtocolHandler::SendNotification(const EcmaVM *ecmaVm, std::unique_ptr events) { - if (!ecmaVm->GetJsDebuggerManager()->IsDebugMode() || events == nullptr) { + if (!ecmaVm->GetJsDebuggerManager()->IsDebugMode()) { + return; + } + SendProfilerNotify(ecmaVm, std::move(events)); +} + +void ProtocolHandler::SendProfilerNotify(const EcmaVM *ecmaVm, std::unique_ptr events) +{ + if (events == nullptr) { return; } LOG(DEBUG, DEBUGGER) << "ProtocolHandler::SendNotification: " << events->GetName(); diff --git a/ecmascript/tooling/protocol_handler.h b/ecmascript/tooling/protocol_handler.h index 6373311cb..5be754cad 100644 --- a/ecmascript/tooling/protocol_handler.h +++ b/ecmascript/tooling/protocol_handler.h @@ -34,6 +34,7 @@ public: void SendResponse(const DispatchRequest &request, const DispatchResponse &response, std::unique_ptr result) override; void SendNotification(const EcmaVM *ecmaVm, std::unique_ptr events) override; + void SendProfilerNotify(const EcmaVM *ecmaVm, std::unique_ptr events) override; const EcmaVM *GetEcmaVM() const { return vm_; -- Gitee