1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef DEBUGMODEL_H |
6 | #define DEBUGMODEL_H |
7 | |
8 | #include "debug.h" |
9 | #include "debugsession.h" |
10 | |
11 | #include <QObject> |
12 | |
13 | namespace DEBUG_NAMESPACE { |
14 | class DebugModel : public QObject /*, public IDebugModel*/ |
15 | { |
16 | Q_OBJECT |
17 | |
18 | public: |
19 | DebugModel(dap::optional<dap::array<DebugSession *>> _sessions, QObject *parent = nullptr); |
20 | dap::array<DebugSession *> getSessions(bool includeInactive = false); |
21 | dap::optional<DebugSession *> getSession(dap::optional<dap::string> sessionId, bool includeInactive = false); |
22 | void addSession(DebugSession *session); |
23 | void clear(); |
24 | |
25 | void rawUpdate(IRawModelUpdate *data); |
26 | void clearThreads(dap::string id, bool removeThreads, dap::optional<dapNumber> reference); |
27 | void fetchCallStack(Thread &thread); |
28 | ReadonlyArray<IBreakpoint> getBreakpoints(dap::optional<QUrl> url, dap::optional<int> lineNumber, |
29 | dap::optional<int> column, dap::optional<bool> enabledOnly); |
30 | |
31 | QMap<QString, dap::array<IBreakpoint>> getAllBreakpoints(); |
32 | ReadonlyArray<IFunctionBreakpoint> getFunctionBreakpoints(); |
33 | ReadonlyArray<IDataBreakpoint> getDataBreakpoints(); |
34 | ReadonlyArray<IExceptionBreakpoint> getExceptionBreakpoints(); |
35 | ReadonlyArray<IInstructionBreakpoint> getInstructionBreakpoints(); |
36 | |
37 | bool areBreakpointsActivated(); |
38 | void setBreakpointsActivated(bool activated); |
39 | ReadonlyArray<IBreakpoint> addBreakpoints(QUrl &uri, dap::array<IBreakpointData> &rawData, bool fireEvent = true); |
40 | dap::array<IBreakpoint> removeBreakpoint(const QString &filePath, int lineNumber); |
41 | void updateBreakpoints(std::map<dap::string, IBreakpointUpdateData> &data); |
42 | void setBreakpointSessionData(dap::string &sessionId, const dap::Capabilities &capabilites, dap::optional<std::map<dap::string, dap::Breakpoint>> data); |
43 | dap::optional<dap::Breakpoint> getDebugProtocolBreakpoint(dap::string &breakpointId, dap::string &sessionId); |
44 | void enableOrDisableAllBreakpoints(bool enable); |
45 | IFunctionBreakpoint addFunctionBreakpoint(dap::string &functionName, dap::string &id); |
46 | void updateFunctionBreakpoint(dap::string &id, dap::optional<dap::string> name, dap::optional<dap::string> hitCondition, dap::optional<dap::string> condition); |
47 | void removeFunctionBreakpoints(dap::string &id); |
48 | void addDataBreakpoint(dap::string &label, dap::string &dataId, bool canPersist, dap::optional<dap::array<dap::DataBreakpointAccessType>> accessTypes, dap::DataBreakpointAccessType accessType); |
49 | void removeDataBreakpoints(dap::string &id); |
50 | #if 0 |
51 | void addInstructionBreakpoint(dap::string address, number offset, dap::optional<dap::string> condition, dap::optional<dap::string> hitCondition); |
52 | void removeInstructionBreakpoints(dap::optional<dap::string> address); |
53 | dap::array<Expression> getWatchExpressions(); |
54 | IExpression addWatchExpression(dap::optional<dap::string> name); |
55 | void renameWatchExpression(dap::string &id, dap::string &newName); |
56 | void removeWatchExpressions(dap::string &id); |
57 | void moveWatchExpression(dap::string id, number position); |
58 | #endif |
59 | void sourceIsNotAvailable(QUrl uri); |
60 | signals: |
61 | |
62 | public slots: |
63 | |
64 | private: |
65 | bool breakpointsActivated = true; |
66 | dap::array<Breakpoint> breakPoints; |
67 | dap::array<IFunctionBreakpoint> functionBreakpoints; |
68 | dap::array<IExceptionBreakpoint> exceptionBreakpoints; |
69 | dap::array<IDataBreakpoint> dataBreakpoints; |
70 | dap::array<IInstructionBreakpoint> instructionBreakpoints; |
71 | dap::array<DebugSession *> sessions; |
72 | }; |
73 | |
74 | } // end namespace. |
75 | |
76 | #endif // DEBUGMODEL_H |
77 | |