1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef ECMASCRIPT_TOOLING_CLIENT_DOMAIN_DEBUGGER_CLIENT_H 17 #define ECMASCRIPT_TOOLING_CLIENT_DOMAIN_DEBUGGER_CLIENT_H 18 19 #include <iostream> 20 #include <vector> 21 22 #include "tooling/dynamic/base/pt_json.h" 23 24 using PtJson = panda::ecmascript::tooling::PtJson; 25 using Result = panda::ecmascript::tooling::Result; 26 namespace OHOS::ArkCompiler::Toolchain { 27 struct BreakPointInfo { 28 int lineNumber; 29 int columnNumber; 30 std::string url; 31 }; 32 33 struct SymbolicBreakpointInfo { 34 std::string functionName; 35 }; 36 37 class DebuggerClient final { 38 public: DebuggerClient(int32_t sessionId)39 DebuggerClient(int32_t sessionId) : sessionId_(sessionId) {} 40 ~DebuggerClient() = default; 41 42 bool DispatcherCmd(const std::string &cmd); 43 int BreakCommand(); 44 int BacktrackCommand(); 45 int DeleteCommand(); 46 int DisableCommand(); 47 int DisplayCommand(); 48 int EnableCommand(); 49 int FinishCommand(); 50 int FrameCommand(); 51 int IgnoreCommand(); 52 int InfobreakpointsCommand(); 53 int InfosourceCommand(); 54 int JumpCommand(); 55 int NextCommand(); 56 int ListCommand(); 57 int PtypeCommand(); 58 int RunCommand(); 59 int SetvarCommand(); 60 int StepCommand(); 61 int UndisplayCommand(); 62 int WatchCommand(); 63 int ResumeCommand(); 64 int StepIntoCommand(); 65 int StepOutCommand(); 66 int StepOverCommand(); 67 int EnableLaunchAccelerateCommand(); 68 int SaveAllPossibleBreakpointsCommand(); 69 int AsyncStackDepthCommand(); 70 int SetSymbolicBreakpointsCommand(); 71 int RemoveSymbolicBreakpointsCommand(); 72 73 void AddBreakPointInfo(const std::string& url, const int& lineNumber, const int& columnNumber = 0); 74 void AddSymbolicBreakpointInfo(const std::string& functionName); 75 void RecvReply(std::unique_ptr<PtJson> json); 76 void PausedReply(const std::unique_ptr<PtJson> json); 77 void handleResponse(std::unique_ptr<PtJson> json); 78 79 private: 80 std::vector<BreakPointInfo> breakPointInfoList_ {}; 81 std::vector<SymbolicBreakpointInfo> symbolicBreakpointInfoList_ {}; 82 int32_t sessionId_; 83 }; 84 } // OHOS::ArkCompiler::Toolchain 85 #endif