File indexing completed on 2024-05-05 05:51:32
0001 /** 0002 * Description: Common interface for GDB and DAP clients 0003 * 0004 * SPDX-FileCopyrightText: 2022 Héctor Mesa Jiménez <wmj.py@gmx.com> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 #pragma once 0009 0010 #include <QObject> 0011 #include <QUrl> 0012 #include <ktexteditor/message.h> 0013 #include <optional> 0014 0015 #include "configview.h" 0016 #include "dap/entities.h" 0017 0018 class BackendInterface : public QObject 0019 { 0020 Q_OBJECT 0021 public: 0022 BackendInterface(QObject *parent); 0023 ~BackendInterface() override = default; 0024 0025 /** 0026 * true if debugger is running 0027 */ 0028 virtual bool debuggerRunning() const = 0; 0029 /** 0030 * true if debugger is running and busy executing commands 0031 */ 0032 virtual bool debuggerBusy() const = 0; 0033 /** 0034 * true if a breakpoint exists at url:line 0035 */ 0036 virtual bool hasBreakpoint(QUrl const &url, int line) const = 0; 0037 /** 0038 * true if debugger supports move program counter 0039 */ 0040 virtual bool supportsMovePC() const = 0; 0041 /** 0042 * true if debugger supports run to cursor 0043 */ 0044 virtual bool supportsRunToCursor() const = 0; 0045 /** 0046 * true if breakpoints can be set/unset 0047 */ 0048 virtual bool canSetBreakpoints() const = 0; 0049 /** 0050 * true if execution can continue 0051 */ 0052 virtual bool canContinue() const = 0; 0053 /** 0054 * true if basic movement actions can be used 0055 */ 0056 virtual bool canMove() const = 0; 0057 /** 0058 * toggle breakpoint at url:line 0059 */ 0060 virtual void toggleBreakpoint(QUrl const &url, int line) = 0; 0061 /** 0062 * move PC to url:line 0063 */ 0064 virtual void movePC(QUrl const &url, int line) = 0; 0065 /** 0066 * run to url:line 0067 */ 0068 virtual void runToCursor(QUrl const &url, int line) = 0; 0069 0070 virtual void issueCommand(QString const &cmd) = 0; 0071 0072 virtual QString targetName() const = 0; 0073 virtual void setFileSearchPaths(const QStringList &paths) = 0; 0074 0075 public Q_SLOTS: 0076 /** 0077 * interrupt debugger process 0078 */ 0079 virtual void slotInterrupt() = 0; 0080 /** 0081 * step into command 0082 */ 0083 virtual void slotStepInto() = 0; 0084 /** 0085 * step over command 0086 */ 0087 virtual void slotStepOver() = 0; 0088 /** 0089 * step out command 0090 */ 0091 virtual void slotStepOut() = 0; 0092 /** 0093 * continue command 0094 */ 0095 virtual void slotContinue() = 0; 0096 /** 0097 * kill debuggee command 0098 */ 0099 virtual void slotKill() = 0; 0100 /** 0101 * re-run program 0102 */ 0103 virtual void slotReRun() = 0; 0104 0105 virtual QString slotPrintVariable(const QString &variable) = 0; 0106 0107 /** 0108 * query information 0109 * 0110 * stack 0111 * frame 0112 * arguments 0113 * this 0114 * locals 0115 * thread 0116 */ 0117 virtual void slotQueryLocals(bool display) = 0; 0118 0119 virtual void changeStackFrame(int index) = 0; 0120 virtual void changeThread(int thread) = 0; 0121 virtual void changeScope(int scopeId) = 0; 0122 0123 Q_SIGNALS: 0124 void debugLocationChanged(const QUrl &file, int lineNum); 0125 void breakPointSet(const QUrl &file, int lineNum); 0126 void breakPointCleared(const QUrl &file, int lineNum); 0127 void clearBreakpointMarks(); 0128 void stackFrameInfo(int level, QString const &info); 0129 void stackFrameChanged(int level); 0130 void threadInfo(const dap::Thread &thread, bool active); 0131 0132 void variableInfo(int parentId, const dap::Variable &variable); 0133 void variableScopeOpened(); 0134 void variableScopeClosed(); 0135 void scopesInfo(const QList<dap::Scope> &scopes, std::optional<int> activeId); 0136 0137 void outputText(const QString &text); 0138 void outputError(const QString &text); 0139 void debuggeeOutput(const dap::Output &output); 0140 void readyForInput(bool ready); 0141 void programEnded(); 0142 void gdbEnded(); 0143 void sourceFileNotFound(const QString &fileName); 0144 void backendError(const QString &message, KTextEditor::Message::MessageType level); 0145 0146 void debuggerCapabilitiesChanged(); 0147 };