2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#ifndef DEBUGGER_BREAKHANDLER_H
|
|
|
|
|
#define DEBUGGER_BREAKHANDLER_H
|
|
|
|
|
|
2010-05-07 15:16:31 +02:00
|
|
|
#include "breakpoint.h"
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QObject>
|
2009-10-01 11:22:44 +02:00
|
|
|
#include <QtCore/QAbstractTableModel>
|
2010-07-13 17:16:31 +02:00
|
|
|
|
2010-02-10 10:47:34 +01:00
|
|
|
#include <QtGui/QIcon>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakHandler
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
namespace Debugger {
|
2010-11-15 19:05:31 +01:00
|
|
|
|
|
|
|
|
class DebuggerEngine;
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-11-15 12:21:43 +01:00
|
|
|
class BreakpointMarker;
|
|
|
|
|
|
2009-10-01 11:22:44 +02:00
|
|
|
class BreakHandler : public QAbstractTableModel
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
2010-11-04 09:54:23 +01:00
|
|
|
BreakHandler();
|
2008-12-04 11:37:43 +01:00
|
|
|
~BreakHandler();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
void loadSessionData();
|
|
|
|
|
void saveSessionData();
|
|
|
|
|
|
|
|
|
|
QAbstractItemModel *model() { return this; }
|
|
|
|
|
|
2010-11-15 14:12:05 +01:00
|
|
|
// The only way to add a new breakpoint.
|
2010-11-16 10:50:11 +01:00
|
|
|
void appendBreakpoint(const BreakpointParameters &data);
|
2010-11-15 14:12:05 +01:00
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakpointIds allBreakpointIds() const;
|
|
|
|
|
BreakpointIds engineBreakpointIds(DebuggerEngine *engine) const;
|
|
|
|
|
BreakpointIds unclaimedBreakpointIds() const;
|
2010-11-15 13:12:13 +01:00
|
|
|
int size() const { return m_storage.size(); }
|
2010-11-10 16:33:11 +01:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
// Find a breakpoint matching approximately the data in needle.
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakpointId findSimilarBreakpoint(const BreakpointResponse &needle) const;
|
|
|
|
|
BreakpointId findBreakpointByNumber(int bpNumber) const;
|
|
|
|
|
BreakpointId findWatchpointByAddress(quint64 address) const;
|
|
|
|
|
BreakpointId findBreakpointByFunction(const QString &functionName) const;
|
|
|
|
|
BreakpointId findBreakpointByIndex(const QModelIndex &index) const;
|
2010-11-15 15:30:39 +01:00
|
|
|
BreakpointIds findBreakpointsByIndex(const QList<QModelIndex> &list) const;
|
2010-11-10 16:33:11 +01:00
|
|
|
void setWatchpointByAddress(quint64 address);
|
|
|
|
|
bool hasWatchpointAt(quint64 address) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
void updateMarkers();
|
|
|
|
|
|
2010-11-18 14:57:00 +01:00
|
|
|
static QIcon breakpointIcon();
|
|
|
|
|
static QIcon disabledBreakpointIcon();
|
|
|
|
|
static QIcon pendingBreakPointIcon();
|
|
|
|
|
static QIcon emptyIcon();
|
2010-02-10 10:47:34 +01:00
|
|
|
|
2010-09-21 14:26:45 +02:00
|
|
|
void toggleBreakpoint(const QString &fileName, int lineNumber, quint64 address = 0);
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakpointId findBreakpointByFileAndLine(const QString &fileName,
|
|
|
|
|
int lineNumber, bool useMarkerPosition = true);
|
|
|
|
|
BreakpointId findBreakpointByAddress(quint64 address) const;
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void breakByFunction(const QString &functionName);
|
2010-11-10 16:33:11 +01:00
|
|
|
void removeBreakpoint(BreakpointId id);
|
|
|
|
|
QIcon icon(BreakpointId id) const;
|
|
|
|
|
void gotoLocation(BreakpointId id) const;
|
|
|
|
|
|
|
|
|
|
// Getter retrieves property value.
|
|
|
|
|
// Setter sets property value and triggers update if changed.
|
|
|
|
|
#define PROPERTY(type, getter, setter) \
|
|
|
|
|
type getter(BreakpointId id) const; \
|
|
|
|
|
void setter(BreakpointId id, const type &value);
|
|
|
|
|
|
|
|
|
|
PROPERTY(bool, useFullPath, setUseFullPath)
|
|
|
|
|
PROPERTY(QByteArray, condition, setCondition)
|
|
|
|
|
PROPERTY(int, ignoreCount, setIgnoreCount)
|
|
|
|
|
PROPERTY(QByteArray, threadSpec, setThreadSpec)
|
|
|
|
|
PROPERTY(QString, fileName, setFileName)
|
|
|
|
|
PROPERTY(QString, functionName, setFunctionName)
|
|
|
|
|
PROPERTY(BreakpointType, type, setType);
|
|
|
|
|
PROPERTY(quint64, address, setAddress);
|
|
|
|
|
PROPERTY(int, lineNumber, setLineNumber);
|
|
|
|
|
#undef PROPERTY
|
2010-11-16 11:06:09 +01:00
|
|
|
void setBreakpointData(BreakpointId id, const BreakpointParameters &data);
|
|
|
|
|
const BreakpointParameters &breakpointData(BreakpointId id) const;
|
2010-11-15 14:12:05 +01:00
|
|
|
BreakpointState state(BreakpointId id) const;
|
2010-11-10 16:33:11 +01:00
|
|
|
bool isEnabled(BreakpointId id) const;
|
2010-11-15 15:05:39 +01:00
|
|
|
void setEnabled(BreakpointId id, bool on);
|
2010-11-10 16:33:11 +01:00
|
|
|
void updateLineNumberFromMarker(BreakpointId id, int lineNumber);
|
2010-11-15 19:05:31 +01:00
|
|
|
void setMarkerFileAndLine(BreakpointId id,
|
|
|
|
|
const QString &fileName, int lineNumber);
|
2010-11-10 16:33:11 +01:00
|
|
|
DebuggerEngine *engine(BreakpointId id) const;
|
|
|
|
|
void setEngine(BreakpointId id, DebuggerEngine *engine);
|
2010-11-15 16:22:51 +01:00
|
|
|
const BreakpointResponse &response(BreakpointId id) const;
|
2010-11-10 16:33:11 +01:00
|
|
|
void setResponse(BreakpointId id, const BreakpointResponse &data);
|
|
|
|
|
|
2010-11-16 13:52:21 +01:00
|
|
|
// State transitions.
|
|
|
|
|
void notifyBreakpointInsertProceeding(BreakpointId id);
|
2010-11-10 16:33:11 +01:00
|
|
|
void notifyBreakpointInsertOk(BreakpointId id);
|
|
|
|
|
void notifyBreakpointInsertFailed(BreakpointId id);
|
|
|
|
|
void notifyBreakpointChangeOk(BreakpointId id);
|
2010-11-18 16:16:23 +01:00
|
|
|
void notifyBreakpointChangeProceeding(BreakpointId id);
|
2010-11-10 16:33:11 +01:00
|
|
|
void notifyBreakpointChangeFailed(BreakpointId id);
|
2010-11-16 13:52:21 +01:00
|
|
|
void notifyBreakpointPending(BreakpointId id);
|
|
|
|
|
void notifyBreakpointRemoveProceeding(BreakpointId id);
|
2010-11-10 16:33:11 +01:00
|
|
|
void notifyBreakpointRemoveOk(BreakpointId id);
|
|
|
|
|
void notifyBreakpointRemoveFailed(BreakpointId id);
|
|
|
|
|
void notifyBreakpointReleased(BreakpointId id);
|
2010-11-16 18:20:52 +01:00
|
|
|
void notifyBreakpointAdjusted(BreakpointId id,
|
|
|
|
|
const BreakpointParameters &data);
|
2010-11-10 16:33:11 +01:00
|
|
|
|
2010-11-16 13:52:21 +01:00
|
|
|
private:
|
|
|
|
|
// QAbstractItemModel implementation.
|
2008-12-02 12:01:29 +01:00
|
|
|
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;
|
2009-04-28 15:08:52 +02:00
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-18 17:44:04 +01:00
|
|
|
void setState(BreakpointId id, BreakpointState state);
|
2008-12-02 12:01:29 +01:00
|
|
|
void loadBreakpoints();
|
|
|
|
|
void saveBreakpoints();
|
2010-11-10 16:33:11 +01:00
|
|
|
void updateMarker(BreakpointId id);
|
|
|
|
|
void cleanupBreakpoint(BreakpointId id);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-11-15 13:12:13 +01:00
|
|
|
struct BreakpointItem
|
|
|
|
|
{
|
2010-11-15 19:05:31 +01:00
|
|
|
BreakpointItem();
|
|
|
|
|
|
2010-11-15 14:27:06 +01:00
|
|
|
void destroyMarker();
|
2010-11-16 17:53:08 +01:00
|
|
|
bool isPending() const { return response.pending; }
|
2010-11-16 18:14:00 +01:00
|
|
|
bool needsChange() const;
|
2010-11-15 19:05:31 +01:00
|
|
|
bool isLocatedAt(const QString &fileName, int lineNumber,
|
|
|
|
|
bool useMarkerPosition) const;
|
2010-11-15 14:27:06 +01:00
|
|
|
QString toToolTip() const;
|
2010-11-18 13:38:58 +01:00
|
|
|
QString markerFileName() const;
|
|
|
|
|
int markerLineNumber() const;
|
2010-11-18 14:57:00 +01:00
|
|
|
QIcon icon() const;
|
2010-11-15 14:12:05 +01:00
|
|
|
|
2010-11-16 11:48:17 +01:00
|
|
|
BreakpointParameters data;
|
2010-11-15 14:12:05 +01:00
|
|
|
BreakpointState state; // Current state of breakpoint.
|
|
|
|
|
DebuggerEngine *engine; // Engine currently handling the breakpoint.
|
|
|
|
|
BreakpointResponse response;
|
2010-11-15 13:12:13 +01:00
|
|
|
BreakpointMarker *marker;
|
|
|
|
|
};
|
|
|
|
|
typedef QHash<BreakpointId, BreakpointItem> BreakpointStorage;
|
|
|
|
|
typedef BreakpointStorage::ConstIterator ConstIterator;
|
|
|
|
|
typedef BreakpointStorage::Iterator Iterator;
|
|
|
|
|
BreakpointStorage m_storage;
|
2010-11-10 16:33:11 +01:00
|
|
|
|
|
|
|
|
void scheduleSynchronization();
|
|
|
|
|
void timerEvent(QTimerEvent *event);
|
|
|
|
|
int m_syncTimerId;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
#endif // DEBUGGER_BREAKHANDLER_H
|