2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
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
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.nokia.com.
|
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;
|
|
|
|
|
|
2011-05-11 16:24:04 +02:00
|
|
|
class BreakHandler : public QAbstractItemModel
|
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();
|
2010-11-25 16:32:07 +01:00
|
|
|
void removeSessionData();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
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);
|
2011-06-15 14:02:26 +02:00
|
|
|
void appendSubBreakpoint(BreakpointId id, const BreakpointResponse &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;
|
2011-03-01 19:16:24 +01:00
|
|
|
BreakpointId findWatchpoint(const BreakpointParameters &data) const;
|
2010-11-10 16:33:11 +01:00
|
|
|
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;
|
2008-12-02 12:01:29 +01:00
|
|
|
void updateMarkers();
|
|
|
|
|
|
2010-11-18 14:57:00 +01:00
|
|
|
static QIcon breakpointIcon();
|
|
|
|
|
static QIcon disabledBreakpointIcon();
|
2010-11-26 12:30:05 +01:00
|
|
|
static QIcon pendingBreakpointIcon();
|
2010-11-18 14:57:00 +01:00
|
|
|
static QIcon emptyIcon();
|
2010-11-26 12:30:05 +01:00
|
|
|
static QIcon watchpointIcon();
|
2010-12-16 13:02:59 +01:00
|
|
|
static QIcon tracepointIcon();
|
2010-02-10 10:47:34 +01:00
|
|
|
|
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.
|
2011-02-17 13:00:11 +01:00
|
|
|
BreakpointPathUsage pathUsage(BreakpointId id) const;
|
|
|
|
|
void setPathUsage(BreakpointId, const BreakpointPathUsage &u);
|
2010-11-18 17:53:42 +01:00
|
|
|
QByteArray condition(BreakpointId id) const;
|
|
|
|
|
void setCondition(BreakpointId, const QByteArray &condition);
|
|
|
|
|
int ignoreCount(BreakpointId id) const;
|
|
|
|
|
void setIgnoreCount(BreakpointId, const int &count);
|
2010-11-30 13:39:01 +01:00
|
|
|
int threadSpec(BreakpointId id) const;
|
|
|
|
|
void setThreadSpec(BreakpointId, const int&spec);
|
2010-11-18 17:53:42 +01:00
|
|
|
QString fileName(BreakpointId id) const;
|
|
|
|
|
void setFileName(BreakpointId, const QString &fileName);
|
|
|
|
|
QString functionName(BreakpointId id) const;
|
|
|
|
|
void setFunctionName(BreakpointId, const QString &functionName);
|
2011-05-10 15:57:33 +02:00
|
|
|
QString expression(BreakpointId id) const;
|
|
|
|
|
void setExpression(BreakpointId, const QString &expression);
|
2010-11-18 17:53:42 +01:00
|
|
|
BreakpointType type(BreakpointId id) const;
|
|
|
|
|
void setType(BreakpointId id, const BreakpointType &type);
|
|
|
|
|
quint64 address(BreakpointId id) const;
|
|
|
|
|
void setAddress(BreakpointId id, const quint64 &address);
|
|
|
|
|
int lineNumber(BreakpointId id) const;
|
2011-03-29 12:55:36 +02:00
|
|
|
void changeBreakpointData(BreakpointId id, const BreakpointParameters &data,
|
|
|
|
|
BreakpointParts parts);
|
2010-11-16 11:06:09 +01:00
|
|
|
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);
|
2011-05-09 08:35:58 +02:00
|
|
|
bool isWatchpoint(BreakpointId id) const;
|
2010-12-16 17:58:43 +01:00
|
|
|
bool isTracepoint(BreakpointId id) const;
|
|
|
|
|
void setTracepoint(BreakpointId, bool on);
|
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;
|
2011-05-11 15:24:50 +02:00
|
|
|
void setResponse(BreakpointId id, const BreakpointResponse &data);
|
2010-11-30 12:47:53 +01:00
|
|
|
bool needsChange(BreakpointId id) const;
|
2010-11-10 16:33:11 +01:00
|
|
|
|
2010-11-16 13:52:21 +01:00
|
|
|
// State transitions.
|
2010-11-30 12:47:53 +01:00
|
|
|
void notifyBreakpointChangeAfterInsertNeeded(BreakpointId id);
|
2010-11-16 13:52:21 +01:00
|
|
|
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-30 12:47:53 +01:00
|
|
|
void notifyBreakpointNeedsReinsertion(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-12-14 13:00:02 +01:00
|
|
|
static QString displayFromThreadSpec(int spec);
|
|
|
|
|
static int threadSpecFromDisplay(const QString &str);
|
|
|
|
|
|
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;
|
2011-05-11 16:24:04 +02:00
|
|
|
QModelIndex index(int row, int col, const QModelIndex &parent) const;
|
|
|
|
|
QModelIndex parent(const QModelIndex &parent) const;
|
2011-06-15 14:02:26 +02:00
|
|
|
QModelIndex createIndex(int row, int column, quint32 id) const;
|
|
|
|
|
QModelIndex createIndex(int row, int column, void *ptr) const;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-06-15 14:02:26 +02:00
|
|
|
int indexOf(BreakpointId id) const;
|
|
|
|
|
BreakpointId at(int index) const;
|
2011-05-11 12:18:32 +02:00
|
|
|
bool isEngineRunning(BreakpointId id) const;
|
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 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;
|
2011-06-15 14:02:26 +02:00
|
|
|
QList<BreakpointResponse> subItems;
|
2010-11-15 13:12:13 +01:00
|
|
|
};
|
|
|
|
|
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
|