File indexing completed on 2024-05-12 04:37:34
0001 /* 0002 SPDX-FileCopyrightText: 2002 Matthias Hoelzer-Kluepfel <hoelzer@kde.org> 0003 SPDX-FileCopyrightText: 2002 John Firebaugh <jfirebaugh@kde.org> 0004 SPDX-FileCopyrightText: 2007 Hamish Rodda <rodda@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KDEVPLATFORM_BREAKPOINT_H 0010 #define KDEVPLATFORM_BREAKPOINT_H 0011 0012 #include <QSet> 0013 #include <QUrl> 0014 0015 #include <debugger/debuggerexport.h> 0016 0017 class QVariant; 0018 class KConfigGroup; 0019 namespace KTextEditor { 0020 class MovingCursor; 0021 } 0022 namespace KDevelop 0023 { 0024 class BreakpointModel; 0025 0026 class KDEVPLATFORMDEBUGGER_EXPORT Breakpoint 0027 { 0028 public: 0029 enum BreakpointKind { 0030 CodeBreakpoint = 0, 0031 WriteBreakpoint, 0032 ReadBreakpoint, 0033 AccessBreakpoint, 0034 LastBreakpointKind 0035 }; 0036 enum BreakpointState { 0037 NotStartedState, 0038 DirtyState, 0039 PendingState, 0040 CleanState 0041 }; 0042 ///Custom roles for retrieving data from breakpoint model. 0043 enum BreakpointRole{ 0044 LocationRole = Qt::UserRole + 1 ///< Retrieves breakpoint's full path unlike Qt::DisplayRole. Note: it's only applicable to LocationColumn. 0045 }; 0046 0047 Breakpoint(BreakpointModel *model, BreakpointKind kind); 0048 Breakpoint(BreakpointModel *model, const KConfigGroup& config); 0049 0050 bool setData(int index, const QVariant& value); 0051 0052 ///Note: to retrieve the full path use LocationRole, Qt::DisplayRole return only a file's name 0053 QVariant data(int column, int role) const; 0054 0055 void save(KConfigGroup& config); 0056 0057 // Moved to BreakpointModel; temporarily left here to ease API transition 0058 enum Column { 0059 EnableColumn, 0060 StateColumn, 0061 TypeColumn, 0062 LocationColumn, 0063 ConditionColumn, 0064 HitCountColumn, 0065 IgnoreHitsColumn 0066 }; 0067 0068 void setUrl(const QUrl &url); 0069 QUrl url() const; 0070 0071 void setLine(int line); 0072 int line() const; 0073 0074 void setLocation(const QUrl& url, int line); 0075 QString location(); 0076 0077 BreakpointKind kind() const; 0078 0079 void setAddress(const QString& address); 0080 QString address() const; 0081 0082 int hitCount() const; 0083 0084 /** 0085 * Check if the breakpoint is deleted. 0086 * @note This method exists to ease the API transition in IBreakpointController; 0087 * it should be removed eventually, since check for already freed memory does not work. 0088 */ 0089 bool deleted() const; 0090 0091 bool enabled() const; 0092 0093 void setMovingCursor(KTextEditor::MovingCursor *cursor); 0094 KTextEditor::MovingCursor *movingCursor() const; 0095 0096 void setIgnoreHits(int c); 0097 int ignoreHits() const; 0098 0099 void setCondition(const QString &c); 0100 QString condition() const; 0101 0102 void setExpression(const QString &c); 0103 QString expression() const; 0104 0105 BreakpointState state() const; 0106 QString errorText() const; 0107 0108 protected: 0109 friend class BreakpointModel; 0110 friend class IBreakpointController; 0111 0112 /** 0113 * Return the model this breakpoint is attached to 0114 * 0115 * @note This might be null, e.g. after the breakpoint has been marked as deleted 0116 */ 0117 BreakpointModel *breakpointModel(); 0118 0119 BreakpointModel *m_model; 0120 bool m_enabled; 0121 bool m_deleted; 0122 BreakpointState m_state; 0123 BreakpointKind m_kind; 0124 /* For watchpoints, the address it is set at. */ 0125 QString m_address; 0126 QUrl m_url; 0127 int m_line; 0128 QString m_condition; 0129 KTextEditor::MovingCursor *m_movingCursor; 0130 int m_hitCount; 0131 int m_ignoreHits; 0132 QString m_expression; 0133 QString m_errorText; 0134 0135 void reportChange(Column c); 0136 }; 0137 0138 } 0139 #endif