From 3fffef381f570bc0d3f289df1737a8f7799e4079 Mon Sep 17 00:00:00 2001 From: fangting Date: Tue, 9 Sep 2025 16:31:29 +0800 Subject: [PATCH] disable debugger before disconnect device Issue:#ICX5EP Signed-off-by: fangting --- tooling/dynamic/agent/debugger_impl.cpp | 1 + tooling/dynamic/test/debugger_impl_test.cpp | 27 +++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/tooling/dynamic/agent/debugger_impl.cpp b/tooling/dynamic/agent/debugger_impl.cpp index dc691ef0..c0a9be8d 100755 --- a/tooling/dynamic/agent/debugger_impl.cpp +++ b/tooling/dynamic/agent/debugger_impl.cpp @@ -1003,6 +1003,7 @@ DispatchResponse DebuggerImpl::DispatcherImpl::DropFrame(const DispatchRequest & // inner message, not SendResponse to outer void DebuggerImpl::DispatcherImpl::ClientDisconnect([[maybe_unused]] const DispatchRequest &request) { + debugger_->Disable(); debugger_->ClientDisconnect(); } diff --git a/tooling/dynamic/test/debugger_impl_test.cpp b/tooling/dynamic/test/debugger_impl_test.cpp index b9ca3db2..94673285 100644 --- a/tooling/dynamic/test/debugger_impl_test.cpp +++ b/tooling/dynamic/test/debugger_impl_test.cpp @@ -1764,6 +1764,33 @@ HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_ClientDisconnect) } } +HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_ClientDisconnect_02) +{ + std::string outStrForCallbackCheck = ""; + std::function callback = + [&outStrForCallbackCheck]([[maybe_unused]] const void *ptr, const std::string &inStrOfReply) { + outStrForCallbackCheck = inStrOfReply;}; + ProtocolChannel *protocolChannel = new ProtocolHandler(callback, ecmaVm); + auto runtimeImpl = std::make_unique(ecmaVm, protocolChannel); + auto debuggerImpl = std::make_unique(ecmaVm, protocolChannel, runtimeImpl.get()); + auto dispatcherImpl = std::make_unique(protocolChannel, std::move(debuggerImpl)); + ecmaVm->GetJsDebuggerManager()->SetDebugMode(true); + std::string msg = std::string() + + R"({ + "id":0, + "method":"Debugger.clientDisconnect", + "params":{} + })"; + DispatchRequest request(msg); + + dispatcherImpl->Dispatch(request); + EXPECT_FALSE(ecmaVm->GetJsDebuggerManager()->IsDebugMode()); + if (protocolChannel) { + delete protocolChannel; + protocolChannel = nullptr; + } +} + HWTEST_F_L0(DebuggerImplTest, Dispatcher_Dispatch_CallFunctionOn__001) { std::string outStrForCallbackCheck = ""; -- Gitee