From 76c6e6d40bfb6bb216a3fafa4bc803e50854a396 Mon Sep 17 00:00:00 2001 From: zhouwenxuan Date: Tue, 5 Sep 2023 17:33:17 +0800 Subject: [PATCH 1/2] Clear arkdb alarm issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/I7YS3M Signed-off-by: zhouwenxuan --- tooling/client/BUILD.gn | 10 +++++----- tooling/client/ark_cli/BUILD.gn | 14 +++++++------- tooling/client/domain/debugger_client.cpp | 5 ++--- tooling/client/utils/utils.cpp | 2 -- tooling/client/utils/utils.h | 3 --- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/tooling/client/BUILD.gn b/tooling/client/BUILD.gn index 45e6acc2..c6b71690 100644 --- a/tooling/client/BUILD.gn +++ b/tooling/client/BUILD.gn @@ -43,10 +43,10 @@ ohos_source_set("libark_client_set") { deps += hiviewdfx_deps include_dirs = [ - "//arkcompiler/toolchain/inspector", - "//arkcompiler/toolchain/websocket", - "//arkcompiler/toolchain/tooling/base", - "//arkcompiler/toolchain/tooling/client", + "./", + "../base", + "../../inspector", + "../../websocket", "//third_party/cJSON", ] @@ -62,8 +62,8 @@ ohos_source_set("libark_client_set") { ] deps += [ + "../:libark_ecma_debugger_set", "$ark_third_party_root/openssl:libcrypto_shared", - "//arkcompiler/toolchain/tooling:libark_ecma_debugger_set", "//third_party/libuv:uv", sdk_libc_secshared_dep, ] diff --git a/tooling/client/ark_cli/BUILD.gn b/tooling/client/ark_cli/BUILD.gn index 286eef7d..0cc992b7 100644 --- a/tooling/client/ark_cli/BUILD.gn +++ b/tooling/client/ark_cli/BUILD.gn @@ -84,17 +84,17 @@ ohos_executable("arkdb") { ] include_dirs = [ - "//arkcompiler/toolchain/tooling", - "//arkcompiler/toolchain/inspector", - "//arkcompiler/toolchain/websocket", - "//arkcompiler/toolchain/tooling/base", - "//arkcompiler/toolchain/tooling/client", - "//arkcompiler/toolchain/tooling/client/ark_cli", + "./", + "../", + "../../base", + "../../../inspector", + "../../../tooling", + "../../../websocket", "//third_party/cJSON", "//third_party/libuv/include", ] - deps = [ "//arkcompiler/toolchain/tooling/client:libark_client_set" ] + deps = [ "../:libark_client_set" ] external_deps = [ "ets_runtime:libark_jsruntime", diff --git a/tooling/client/domain/debugger_client.cpp b/tooling/client/domain/debugger_client.cpp index 1e9215e0..8ae04cf7 100644 --- a/tooling/client/domain/debugger_client.cpp +++ b/tooling/client/domain/debugger_client.cpp @@ -14,12 +14,11 @@ */ #include "domain/debugger_client.h" -#include "pt_json.h" + #include "log_wrapper.h" +#include "pt_json.h" #include -#include -#include using PtJson = panda::ecmascript::tooling::PtJson; namespace OHOS::ArkCompiler::Toolchain { diff --git a/tooling/client/utils/utils.cpp b/tooling/client/utils/utils.cpp index cb1635f7..be6572a9 100644 --- a/tooling/client/utils/utils.cpp +++ b/tooling/client/utils/utils.cpp @@ -17,8 +17,6 @@ #include "log_wrapper.h" #include -#include -#include namespace OHOS::ArkCompiler::Toolchain { bool Utils::GetCurrentTime(char *date, char *tim, size_t size) diff --git a/tooling/client/utils/utils.h b/tooling/client/utils/utils.h index 64b1b6d3..5ada563c 100644 --- a/tooling/client/utils/utils.h +++ b/tooling/client/utils/utils.h @@ -22,9 +22,6 @@ namespace OHOS::ArkCompiler::Toolchain { class Utils { public: static bool GetCurrentTime(char *date, char *tim, size_t size); - -private: - }; } // OHOS::ArkCompiler::Toolchain #endif \ No newline at end of file -- Gitee From 9120580e22ef161c977c85add4821f8b43e83fac Mon Sep 17 00:00:00 2001 From: zhouwenxuan Date: Tue, 5 Sep 2023 17:33:17 +0800 Subject: [PATCH 2/2] Clear arkdb alarm issue: https://gitee.com/openharmony/arkcompiler_toolchain/issues/I7YS3M Signed-off-by: zhouwenxuan Signed-off-by: duning Change-Id: I429e9a07125a49c2d42d09067dac1e620e0fef54 --- tooling/client/BUILD.gn | 1 + tooling/client/ark_cli/cli_command.cpp | 28 +++++-- tooling/client/domain/debugger_client.cpp | 4 +- tooling/client/manager/breakpoint_manager.cpp | 79 +++++++++++++++++++ tooling/client/manager/breakpoint_manager.h | 53 +++++++++++++ tooling/client/manager/domain_manager.cpp | 3 + 6 files changed, 161 insertions(+), 7 deletions(-) create mode 100644 tooling/client/manager/breakpoint_manager.cpp create mode 100644 tooling/client/manager/breakpoint_manager.h diff --git a/tooling/client/BUILD.gn b/tooling/client/BUILD.gn index c6b71690..cf815bf7 100644 --- a/tooling/client/BUILD.gn +++ b/tooling/client/BUILD.gn @@ -57,6 +57,7 @@ ohos_source_set("libark_client_set") { "domain/runtime_client.cpp", "manager/domain_manager.cpp", "manager/variable_manager.cpp", + "manager/breakpoint_manager.cpp", "utils/utils.cpp", "websocket/websocket_client.cpp", ] diff --git a/tooling/client/ark_cli/cli_command.cpp b/tooling/client/ark_cli/cli_command.cpp index 431438d8..01f931d9 100644 --- a/tooling/client/ark_cli/cli_command.cpp +++ b/tooling/client/ark_cli/cli_command.cpp @@ -25,6 +25,7 @@ #include "manager/variable_manager.h" #include "domain/runtime_client.h" #include "cli_command.h" +#include "manager/breakpoint_manager.h" namespace OHOS::ArkCompiler::Toolchain { DomainManager g_domainManager; @@ -232,22 +233,37 @@ ErrCode CliCommand::DebuggerCommand(const std::string &cmd) { std::cout << "exe success, cmd is " << cmd << std::endl; std::string request; + DebugerClient debuggerCli; + Breakpoint &breakpoint=Breakpoint::getInstance(); + if(cmd=="display"){ + breakpoint.show(); + return ERR_OK; + } + if(cmd=="delete"){ + std::string bnumber=GetArgList()[0]; + unsigned int num=std::stoi(bnumber); + if(num<=breakpoint.breaklist.size()&&num>0){ + debuggerCli.AddBreakPointInfo(breakpoint.breaklist[num-1].breakpointId,"0"); + breakpoint.deletebreaklocation(num); + } + else + return ERR_FAIL; + } bool result = false; LOGE("DebuggerCommand: %{public}d", id_); - DebuggerClient debuggerCli; - if (GetArgList().size() == 2) { // 2: two parameters - debuggerCli.AddBreakPointInfo(GetArgList()[0], std::stoi(GetArgList()[1])); + if (GetArgList().size() == 2) { + debuggerCli.AddBreakPointInfo(GetArgList()[0], GetArgList()[1]); } result = debuggerCli.DispatcherCmd(id_, cmd, &request); if (result) { g_cliSocket.ClientSendReq(request); - if (g_domainManager.GetDomainById(id_).empty()) { + if (g_domainManager.GetDomainById(id_) == "") { g_domainManager.SetDomainById(id_, "Debugger"); } } else { - return ErrCode::ERR_FAIL; + return ERR_FAIL; } - return ErrCode::ERR_OK; + return ERR_OK; } ErrCode CliCommand::RuntimeCommand(const std::string &cmd) diff --git a/tooling/client/domain/debugger_client.cpp b/tooling/client/domain/debugger_client.cpp index 8ae04cf7..6031af72 100644 --- a/tooling/client/domain/debugger_client.cpp +++ b/tooling/client/domain/debugger_client.cpp @@ -91,8 +91,10 @@ std::string DebuggerClient::DeleteCommand(int id) std::unique_ptr request = PtJson::CreateObject(); request->Add("id", id); request->Add("method", "Debugger.removeBreakpoint"); - std::unique_ptr params = PtJson::CreateObject(); + std::string breakpointId; + breakpointId=breakPointInfoList_.back().url; + params->Add("breakpointId",breakpointId.c_str()); request->Add("params", params); return request->Stringify(); } diff --git a/tooling/client/manager/breakpoint_manager.cpp b/tooling/client/manager/breakpoint_manager.cpp new file mode 100644 index 00000000..93e64165 --- /dev/null +++ b/tooling/client/manager/breakpoint_manager.cpp @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include + +#include "log_wrapper.h" +#include "manager/breakpoint_manager.h" +#include "toolchain_cli/cli_command.h" +using PtJson = panda::ecmascript::tooling::PtJson; +using Result = panda::ecmascript::tooling::Result; +namespace OHOS::ArkCompiler::Toolchain { + void Breakpoint::HandleMessage(const std::unique_ptr json){ + if (json == nullptr) { + LOGE("toolchain_client: json parse error"); + return; + } + + if (!json->IsObject()) { + LOGE("toolchain_client: json parse format error"); + json->ReleaseRoot(); + return; + } + Result ret; + std::unique_ptr result; + ret = json->GetObject("result", &result); + if (ret != Result::SUCCESS) { + LOGE("toolchain_client: find result error"); + return; + } + std::string breakpointId; + Breaklocation breaklocation; + ret = result->GetString("breakpointId", &breakpointId); + int flag=0; + if(ret == Result::SUCCESS) { + breaklocation.breakpointId=breakpointId; + int length=breakpointId.size(); + for(int i=0;i::iterator it=breaklist.begin()+num-1; + breaklist.erase(it); + } +} \ No newline at end of file diff --git a/tooling/client/manager/breakpoint_manager.h b/tooling/client/manager/breakpoint_manager.h new file mode 100644 index 00000000..57c29e7c --- /dev/null +++ b/tooling/client/manager/breakpoint_manager.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ECMASCRIPT_TOOLING_CLIENT_MANAGER_BREAKPOINT_MANAGER_H +#define ECMASCRIPT_TOOLING_CLIENT_MANAGER_BREAKPOINT_MANAGER_H + +#include +#include +#include +#include +#include +#include "pt_json.h" +#include "pt_types.h" +namespace OHOS::ArkCompiler::Toolchain { +using PtJson = panda::ecmascript::tooling::PtJson; +using Result = panda::ecmascript::tooling::Result; +struct Breaklocation{ + std::string breakpointId; + std::string url; + std::string lineNumber; + std::string columnNumber; +}; +class Breakpoint{ +public: + Breakpoint(const Breakpoint&) = delete; + Breakpoint& operator=(const Breakpoint&) = delete; + + static Breakpoint& getInstance() { + static Breakpoint instance; + return instance; + } + + std::vector breaklist; + void HandleMessage(const std::unique_ptr json); + void show(); + void deletebreaklocation(unsigned int num); +private: + Breakpoint() = default; + ~Breakpoint() = default; +}; +} +#endif \ No newline at end of file diff --git a/tooling/client/manager/domain_manager.cpp b/tooling/client/manager/domain_manager.cpp index 8f84887b..3a49d19a 100644 --- a/tooling/client/manager/domain_manager.cpp +++ b/tooling/client/manager/domain_manager.cpp @@ -18,6 +18,7 @@ #include "manager/variable_manager.h" #include "domain/runtime_client.h" #include "domain_manager.h" +#include "manager/breakpoint_manager.h" using PtJson = panda::ecmascript::tooling::PtJson; using Result = panda::ecmascript::tooling::Result; @@ -72,6 +73,8 @@ void DomainManager::DispatcherReply(char* msg) LOGI("Runtime replay message is %{public}s", json->Stringify().c_str()); } } else if (domain == "Debugger") { + Breakpoint &breakpoint = Breakpoint::getInstance(); + breakpoint.HandleMessage(std::move(json)); LOGI("Debugger replay message is %{public}s", json->Stringify().c_str()); } } -- Gitee