1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "jsdebugger.h" |
6 | #include "debugmanager.h" |
7 | |
8 | #include <QDebug> |
9 | #include <QRegularExpression> |
10 | |
11 | #define RET_EMPTY return {}; |
12 | class JSDebuggerPrivate |
13 | { |
14 | friend class JSDebugger; |
15 | |
16 | dap::array<dap::StackFrame> stackframes; |
17 | dap::array<dap::Thread> threads; |
18 | dap::array<dap::Variable> variables; |
19 | std::atomic_bool inferiorRunning{false}; |
20 | }; |
21 | |
22 | JSDebugger::JSDebugger(QObject *parent) |
23 | : Debugger(parent), d(new JSDebuggerPrivate()) |
24 | { |
25 | connect(this, &JSDebugger::asyncStopped, DebugManager::instance(), &DebugManager::asyncStopped); |
26 | } |
27 | |
28 | JSDebugger::~JSDebugger() |
29 | { |
30 | |
31 | } |
32 | |
33 | QString JSDebugger::program() |
34 | { |
35 | return "qsdbg"; |
36 | } |
37 | |
38 | QStringList JSDebugger::preArguments() |
39 | { |
40 | RET_EMPTY |
41 | } |
42 | |
43 | QString JSDebugger::quit() |
44 | { |
45 | RET_EMPTY |
46 | } |
47 | |
48 | QString JSDebugger::kill() |
49 | { |
50 | RET_EMPTY |
51 | } |
52 | |
53 | QString JSDebugger::breakInsert(const QString &path) |
54 | { |
55 | return ".break "+ path; |
56 | } |
57 | |
58 | QString JSDebugger::breakRemove(int bpid) |
59 | { |
60 | return ".delete "+ QString::number(bpid); |
61 | } |
62 | |
63 | QString JSDebugger::breakRemoveAll() |
64 | { |
65 | return ".delall"; |
66 | } |
67 | |
68 | QString JSDebugger::launchLocal() |
69 | { |
70 | return ""; |
71 | } |
72 | |
73 | QString JSDebugger::commandPause() |
74 | { |
75 | RET_EMPTY |
76 | } |
77 | |
78 | QString JSDebugger::commandContinue() |
79 | { |
80 | return ".continue"; |
81 | } |
82 | |
83 | QString JSDebugger::commandNext() |
84 | { |
85 | return ".next"; |
86 | } |
87 | |
88 | QString JSDebugger::commandStep() |
89 | { |
90 | return ".step"; |
91 | } |
92 | |
93 | QString JSDebugger::commandFinish() |
94 | { |
95 | RET_EMPTY |
96 | } |
97 | |
98 | QString JSDebugger::stackListFrames() |
99 | { |
100 | return ".backtrace"; |
101 | } |
102 | |
103 | QString JSDebugger::stackListVariables() |
104 | { |
105 | return ".info locals"; |
106 | } |
107 | |
108 | QString JSDebugger::threadInfo() |
109 | { |
110 | RET_EMPTY |
111 | } |
112 | |
113 | QString JSDebugger::threadSelect(const int threadId) |
114 | { |
115 | Q_UNUSED(threadId); |
116 | RET_EMPTY |
117 | } |
118 | |
119 | QString JSDebugger::listSourceFiles() |
120 | { |
121 | return ".list"; |
122 | } |
123 | |
124 | dap::array<dap::StackFrame> JSDebugger::allStackframes() |
125 | { |
126 | return d->stackframes; |
127 | } |
128 | |
129 | dap::array<dap::Thread> JSDebugger::allThreadList() |
130 | { |
131 | return d->threads; |
132 | } |
133 | |
134 | dap::array<dap::Variable> JSDebugger::allVariableList() |
135 | { |
136 | return d->variables; |
137 | } |
138 | |
139 | void JSDebugger::handleOutputRecord(const QString &text) |
140 | { |
141 | qInfo() << text; |
142 | } |
143 | |
144 | void JSDebugger::handleOutputStreamText(const QString &streamText) |
145 | { |
146 | qInfo() << streamText; |
147 | } |
148 | |
149 | void JSDebugger::parseBreakPoint(const QVariant &var) |
150 | { |
151 | Q_UNUSED(var) |
152 | } |
153 | |
154 | void JSDebugger::removeBreakPoint(const int bpid) |
155 | { |
156 | Q_UNUSED(bpid) |
157 | } |
158 | |
159 | void JSDebugger::clearBreakPoint() |
160 | { |
161 | } |
162 | |
163 | QList<int> JSDebugger::breakpointsForFile(const QString &filePath) |
164 | { |
165 | Q_UNUSED(filePath) |
166 | RET_EMPTY |
167 | } |
168 | |
169 | bool JSDebugger::isInferiorRunning() { |
170 | return d->inferiorRunning; |
171 | } |
172 |