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/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 class DebuggerClient final {
33 public:
DebuggerClient(int32_t sessionId)34     DebuggerClient(int32_t sessionId) : sessionId_(sessionId) {}
35     ~DebuggerClient() = default;
36 
37     bool DispatcherCmd(const std::string &cmd);
38     int BreakCommand();
39     int BacktrackCommand();
40     int DeleteCommand();
41     int DisableCommand();
42     int DisplayCommand();
43     int EnableCommand();
44     int FinishCommand();
45     int FrameCommand();
46     int IgnoreCommand();
47     int InfobreakpointsCommand();
48     int InfosourceCommand();
49     int JumpCommand();
50     int NextCommand();
51     int ListCommand();
52     int PtypeCommand();
53     int RunCommand();
54     int SetvarCommand();
55     int StepCommand();
56     int UndisplayCommand();
57     int WatchCommand();
58     int ResumeCommand();
59     int StepIntoCommand();
60     int StepOutCommand();
61     int StepOverCommand();
62 
63     void AddBreakPointInfo(const std::string& url, const int& lineNumber, const int& columnNumber = 0);
64     void RecvReply(std::unique_ptr<PtJson> json);
65     void PausedReply(const std::unique_ptr<PtJson> json);
66     void handleResponse(std::unique_ptr<PtJson> json);
67 
68 private:
69     std::vector<BreakPointInfo> breakPointInfoList_ {};
70     int32_t sessionId_;
71 };
72 } // OHOS::ArkCompiler::Toolchain
73 #endif