1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef DEBUGGER_BREAKHANDLER_H
#define DEBUGGER_BREAKHANDLER_H
#include "breakpoint.h"
#include <QAbstractTableModel>
//////////////////////////////////////////////////////////////////
//
// BreakHandler
//
//////////////////////////////////////////////////////////////////
namespace Debugger {
class DebuggerEngine;
namespace Internal {
class BreakpointMarker;
class BreakHandler : public QAbstractItemModel
{
Q_OBJECT
public:
BreakHandler();
~BreakHandler();
void loadSessionData();
void saveSessionData();
QAbstractItemModel *model() { return this; }
// The only way to add a new breakpoint.
void appendBreakpoint(const BreakpointParameters &data);
void handleAlienBreakpoint(const BreakpointResponse &response, DebuggerEngine *engine);
void insertSubBreakpoint(BreakpointModelId id, const BreakpointResponse &data);
void removeAlienBreakpoint(BreakpointModelId id);
BreakpointModelIds allBreakpointIds() const;
BreakpointModelIds engineBreakpointIds(DebuggerEngine *engine) const;
BreakpointModelIds unclaimedBreakpointIds() const;
int size() const { return m_storage.size(); }
QStringList engineBreakpointPaths(DebuggerEngine *engine) const;
// Find a breakpoint matching approximately the data in needle.
BreakpointModelId findSimilarBreakpoint(const BreakpointResponse &needle) const;
BreakpointModelId findBreakpointByResponseId(const BreakpointResponseId &resultId) const;
BreakpointModelId findWatchpoint(const BreakpointParameters &data) const;
BreakpointModelId findBreakpointByFunction(const QString &functionName) const;
BreakpointModelId findBreakpointByIndex(const QModelIndex &index) const;
BreakpointModelIds findBreakpointsByIndex(const QList<QModelIndex> &list) const;
void updateMarkers();
static QIcon breakpointIcon();
static QIcon disabledBreakpointIcon();
static QIcon pendingBreakpointIcon();
static QIcon emptyIcon();
static QIcon watchpointIcon();
static QIcon tracepointIcon();
BreakpointModelId findBreakpointByFileAndLine(const QString &fileName,
int lineNumber, bool useMarkerPosition = true);
BreakpointModelId findBreakpointByAddress(quint64 address) const;
void breakByFunction(const QString &functionName);
void removeBreakpoint(BreakpointModelId id);
QIcon icon(BreakpointModelId id) const;
void gotoLocation(BreakpointModelId id) const;
// Getter retrieves property value.
// Setter sets property value and triggers update if changed.
BreakpointPathUsage pathUsage(BreakpointModelId id) const;
void setPathUsage(BreakpointModelId, const BreakpointPathUsage &u);
QByteArray condition(BreakpointModelId id) const;
void setCondition(BreakpointModelId, const QByteArray &condition);
int ignoreCount(BreakpointModelId id) const;
void setIgnoreCount(BreakpointModelId, const int &count);
int threadSpec(BreakpointModelId id) const;
void setThreadSpec(BreakpointModelId, const int &spec);
QString fileName(BreakpointModelId id) const;
void setFileName(BreakpointModelId, const QString &fileName);
QString functionName(BreakpointModelId id) const;
void setFunctionName(BreakpointModelId, const QString &functionName);
QString expression(BreakpointModelId id) const;
void setExpression(BreakpointModelId, const QString &expression);
QString message(BreakpointModelId id) const;
void setMessage(BreakpointModelId, const QString &m);
BreakpointType type(BreakpointModelId id) const;
void setType(BreakpointModelId id, const BreakpointType &type);
quint64 address(BreakpointModelId id) const;
void setAddress(BreakpointModelId id, const quint64 &address);
int lineNumber(BreakpointModelId id) const;
void changeBreakpointData(BreakpointModelId id, const BreakpointParameters &data,
BreakpointParts parts);
const BreakpointParameters &breakpointData(BreakpointModelId id) const;
BreakpointState state(BreakpointModelId id) const;
bool isEnabled(BreakpointModelId id) const;
void setEnabled(BreakpointModelId id, bool on);
void updateFileNameFromMarker(BreakpointModelId id, const QString &fileName);
void updateLineNumberFromMarker(BreakpointModelId id, int lineNumber);
void changeLineNumberFromMarker(BreakpointModelId id, int lineNumber);
void setMarkerFileAndLine(BreakpointModelId id,
const QString &fileName, int lineNumber);
bool isOneShot(BreakpointModelId id) const;
bool isWatchpoint(BreakpointModelId id) const;
bool isTracepoint(BreakpointModelId id) const;
void setTracepoint(BreakpointModelId, bool on);
DebuggerEngine *engine(BreakpointModelId id) const;
void setEngine(BreakpointModelId id, DebuggerEngine *engine);
const BreakpointResponse &response(BreakpointModelId id) const;
void setResponse(BreakpointModelId id, const BreakpointResponse &data);
bool needsChange(BreakpointModelId id) const;
bool needsChildren(BreakpointModelId id) const;
// State transitions.
void notifyBreakpointChangeAfterInsertNeeded(BreakpointModelId id);
void notifyBreakpointInsertProceeding(BreakpointModelId id);
void notifyBreakpointInsertOk(BreakpointModelId id);
void notifyBreakpointInsertFailed(BreakpointModelId id);
void notifyBreakpointChangeOk(BreakpointModelId id);
void notifyBreakpointChangeProceeding(BreakpointModelId id);
void notifyBreakpointChangeFailed(BreakpointModelId id);
void notifyBreakpointPending(BreakpointModelId id);
void notifyBreakpointRemoveProceeding(BreakpointModelId id);
void notifyBreakpointRemoveOk(BreakpointModelId id);
void notifyBreakpointRemoveFailed(BreakpointModelId id);
void notifyBreakpointReleased(BreakpointModelId id);
void notifyBreakpointNeedsReinsertion(BreakpointModelId id);
void notifyBreakpointAdjusted(BreakpointModelId id,
const BreakpointParameters &data);
static QString displayFromThreadSpec(int spec);
static int threadSpecFromDisplay(const QString &str);
// Convenience.
void setWatchpointAtAddress(quint64 address, unsigned size);
void setWatchpointAtExpression(const QString &exp);
private:
// QAbstractItemModel implementation.
int columnCount(const QModelIndex &parent) const;
int rowCount(const QModelIndex &parent) const;
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
QModelIndex index(int row, int col, const QModelIndex &parent) const;
QModelIndex parent(const QModelIndex &parent) const;
QModelIndex createIndex(int row, int column, quint32 id) const;
QModelIndex createIndex(int row, int column, void *ptr) const;
int indexOf(BreakpointModelId id) const;
BreakpointModelId at(int index) const;
bool isEngineRunning(BreakpointModelId id) const;
void setState(BreakpointModelId id, BreakpointState state);
void loadBreakpoints();
void saveBreakpoints();
void cleanupBreakpoint(BreakpointModelId id);
Q_SLOT void changeLineNumberFromMarkerHelper(Debugger::Internal::BreakpointModelId id, int lineNumber);
struct BreakpointItem
{
BreakpointItem();
void destroyMarker();
bool needsChange() const;
bool isLocatedAt(const QString &fileName, int lineNumber,
bool useMarkerPosition) const;
void updateMarker(BreakpointModelId id);
void updateMarkerIcon();
QString toToolTip() const;
QString markerFileName() const;
int markerLineNumber() const;
QIcon icon() const;
BreakpointParameters data;
BreakpointState state; // Current state of breakpoint.
DebuggerEngine *engine; // Engine currently handling the breakpoint.
BreakpointResponse response;
BreakpointMarker *marker;
QList<BreakpointResponse> subItems;
};
typedef QHash<BreakpointModelId, BreakpointItem> BreakpointStorage;
typedef BreakpointStorage::ConstIterator ConstIterator;
typedef BreakpointStorage::Iterator Iterator;
BreakpointStorage m_storage;
void scheduleSynchronization();
void timerEvent(QTimerEvent *event);
int m_syncTimerId;
};
} // namespace Internal
} // namespace Debugger
#endif // DEBUGGER_BREAKHANDLER_H
|