1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "ninjadebug.h" |
6 | |
7 | #include "services/option/optionmanager.h" |
8 | |
9 | #include <QDBusMessage> |
10 | #include <QDBusConnection> |
11 | #include <QUuid> |
12 | |
13 | class NinjaDebugPrivate |
14 | { |
15 | friend class NinjaDebug; |
16 | }; |
17 | |
18 | NinjaDebug::NinjaDebug(QObject *parent) |
19 | : QObject(parent) |
20 | , d(new NinjaDebugPrivate()) |
21 | { |
22 | |
23 | } |
24 | |
25 | NinjaDebug::~NinjaDebug() |
26 | { |
27 | if (d) |
28 | delete d; |
29 | } |
30 | |
31 | bool NinjaDebug::requestDAPPort(const QString &uuid, const QString &kit, |
32 | const QString &targetPath, const QStringList &arguments, |
33 | QString &retMsg) |
34 | { |
35 | QDBusMessage msg = QDBusMessage::createSignal("/path" , |
36 | "com.deepin.unioncode.interface" , |
37 | "getDebugPort" ); |
38 | |
39 | msg << uuid |
40 | << kit |
41 | << targetPath |
42 | << arguments; |
43 | bool ret = QDBusConnection::sessionBus().send(msg); |
44 | if (!ret) { |
45 | retMsg = tr("Request cxx dap port failed, please retry." ); |
46 | return false; |
47 | } |
48 | |
49 | return true; |
50 | } |
51 | |
52 | bool NinjaDebug::isLaunchNotAttach() |
53 | { |
54 | return false; |
55 | } |
56 | |
57 | dap::LaunchRequest NinjaDebug::launchDAP(const QString &targetPath, const QStringList &argments) |
58 | { |
59 | dap::LaunchRequest request; |
60 | request.name = "(gdb) Launch" ; |
61 | request.type = "cppdbg" ; |
62 | request.request = "launch" ; |
63 | request.program = targetPath.toStdString(); |
64 | request.stopAtEntry = false; |
65 | dap::array<dap::string> arrayArg; |
66 | foreach (QString arg, argments) { |
67 | arrayArg.push_back(arg.toStdString()); |
68 | } |
69 | request.args = arrayArg; |
70 | request.externalConsole = false; |
71 | request.MIMode = "gdb" ; |
72 | request.__sessionId = QUuid::createUuid().toString().toStdString(); |
73 | |
74 | return request; |
75 | } |
76 | |
77 | |