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