| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef DEBUGGER_H |
| 6 | #define DEBUGGER_H |
| 7 | |
| 8 | #include "debug.h" |
| 9 | #include "event/event.h" |
| 10 | #include "interface/stackframemodel.h" |
| 11 | #include "interface/localtreemodel.h" |
| 12 | #include "interface/breakpointmodel.h" |
| 13 | #include "base/abstractdebugger.h" |
| 14 | |
| 15 | #include "services/project/projectservice.h" |
| 16 | #include "common/supportfile/dapconfig.h" |
| 17 | #include "common/widget/outputpane.h" |
| 18 | |
| 19 | #include <QSharedPointer> |
| 20 | #include <QTreeView> |
| 21 | #include <QPointer> |
| 22 | |
| 23 | /** |
| 24 | * @brief The Debugger class wrap |
| 25 | */ |
| 26 | namespace DEBUG { |
| 27 | class DebugSession; |
| 28 | } |
| 29 | |
| 30 | namespace dap { |
| 31 | class Session; |
| 32 | } |
| 33 | |
| 34 | class DebuggerPrivate; |
| 35 | class DAPDebugger; |
| 36 | class OutputPane; |
| 37 | class StackFrameView; |
| 38 | class RunTimeCfgProvider; |
| 39 | class QComboBox; |
| 40 | class DAPDebugger : public AbstractDebugger |
| 41 | { |
| 42 | Q_OBJECT |
| 43 | public: |
| 44 | explicit DAPDebugger(QObject *parent = nullptr); |
| 45 | ~DAPDebugger() override; |
| 46 | |
| 47 | QWidget *getOutputPane() const override; |
| 48 | QWidget *getStackPane() const override; |
| 49 | QWidget *getLocalsPane() const override; |
| 50 | QWidget *getBreakpointPane() const override; |
| 51 | |
| 52 | void startDebug() override; |
| 53 | void detachDebug() override; |
| 54 | |
| 55 | void interruptDebug() override; |
| 56 | void continueDebug() override; |
| 57 | void abortDebug() override; |
| 58 | void restartDebug() override; |
| 59 | |
| 60 | void stepOver() override; |
| 61 | void stepIn() override; |
| 62 | void stepOut() override; |
| 63 | |
| 64 | RunState getRunState() const override; |
| 65 | bool runCoredump(const QString &target, const QString &core, const QString &kit) override; |
| 66 | |
| 67 | public slots: |
| 68 | void registerDapHandlers(); |
| 69 | void handleEvents(const dpf::Event &event); |
| 70 | void printOutput(const QString &content, OutputPane::OutputFormat format = OutputPane::OutputFormat::NormalMessage); |
| 71 | void synPrintOutput(const QString &content, OutputPane::OutputFormat format = OutputPane::OutputFormat::NormalMessage); |
| 72 | /** |
| 73 | * interface triggered. |
| 74 | */ |
| 75 | void slotFrameSelected(const QModelIndex &index); |
| 76 | void slotBreakpointSelected(const QModelIndex &index); |
| 77 | bool showStoppedBySignalMessageBox(QString meaning, QString name); |
| 78 | void currentThreadChanged(const QString &text); |
| 79 | |
| 80 | void slotReceivedDAPPort(const QString &uuid, int port, const QString &kitName, const QMap<QString, QVariant> ¶m); |
| 81 | void slotOutputMsg(const QString &title, const QString &msg); |
| 82 | |
| 83 | private: |
| 84 | void launchBackend(); |
| 85 | void killBackend(); |
| 86 | void initializeView(); |
| 87 | void handleFrames(const StackFrames &stackFrames); |
| 88 | void updateThreadList(int curr, const dap::array<dap::Thread> &threads); |
| 89 | void switchCurrentThread(int curThreadID); |
| 90 | |
| 91 | void addBreakpoint(const QString &filepath, int lineNumber); |
| 92 | void removeBreakpoint(const QString &filepath, int lineNumber); |
| 93 | bool getLocals(dap::integer frameId, IVariables *out); |
| 94 | void exitDebug(); |
| 95 | void updateRunState(DAPDebugger::RunState state); |
| 96 | QString requestBuild(); |
| 97 | void start(); |
| 98 | void prepareDebug(); |
| 99 | bool requestDebugPort(const QMap<QString, QVariant> ¶m, const QString &kitName, bool customDap); |
| 100 | void stopWaitingDebugPort(); |
| 101 | void stopDAP(); |
| 102 | void launchSession(int port, const QMap<QString, QVariant> ¶m, const QString &kitName); |
| 103 | void disassemble(const QString &address); |
| 104 | void handleAssemble(const QString &content); |
| 105 | dpfservice::ProjectInfo getActiveProjectInfo() const; |
| 106 | |
| 107 | DebuggerPrivate *const d; |
| 108 | }; |
| 109 | |
| 110 | #endif // DEBUGGER_H |
| 111 | |