2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** Contact: Qt Software Information (qt-info@nokia.com)
|
|
|
|
|
**
|
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
|
|
|
|
|
** contact the sales department at qt-sales@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
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QObject>
|
|
|
|
|
#include <QtCore/QAbstractItemModel>
|
|
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class BreakpointMarker;
|
|
|
|
|
class BreakHandler;
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakpointData
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class BreakpointData
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit BreakpointData(BreakHandler *handler);
|
|
|
|
|
~BreakpointData();
|
|
|
|
|
|
|
|
|
|
void removeMarker();
|
|
|
|
|
void updateMarker();
|
|
|
|
|
QString toToolTip() const;
|
|
|
|
|
BreakHandler *handler() { return m_handler; }
|
|
|
|
|
|
|
|
|
|
bool isLocatedAt(const QString &fileName, int lineNumber) const;
|
|
|
|
|
bool conditionsMatch() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Intentionally unimplemented.
|
|
|
|
|
// Making it copiable is tricky because of the markers.
|
|
|
|
|
void operator=(const BreakpointData &);
|
|
|
|
|
BreakpointData(const BreakpointData &);
|
|
|
|
|
|
|
|
|
|
// Our owner
|
|
|
|
|
BreakHandler *m_handler; // not owned.
|
|
|
|
|
|
|
|
|
|
public:
|
2009-04-28 15:08:52 +02:00
|
|
|
bool enabled; // should we talk to the debugger engine?
|
2008-12-02 12:01:29 +01:00
|
|
|
bool pending; // does the debugger engine know about us already?
|
|
|
|
|
|
|
|
|
|
// this "user requested information". will get stored in the session
|
|
|
|
|
QString fileName; // short name of source file
|
|
|
|
|
QString condition; // condition associated with breakpoint
|
|
|
|
|
QString ignoreCount; // ignore count associated with breakpoint
|
|
|
|
|
QString lineNumber; // line in source file
|
|
|
|
|
QString funcName; // name of containing function
|
|
|
|
|
|
|
|
|
|
// this is what gdb produced in response
|
|
|
|
|
QString bpNumber; // breakpoint number assigned by the debugger engine
|
|
|
|
|
QString bpCondition; // condition acknowledged by the debugger engine
|
|
|
|
|
QString bpIgnoreCount; // ignore count acknowledged by the debugger engine
|
|
|
|
|
QString bpFileName; // file name acknowledged by the debugger engine
|
|
|
|
|
QString bpLineNumber; // line number acknowledged by the debugger engine
|
|
|
|
|
QString bpFuncName; // function name acknowledged by the debugger engine
|
|
|
|
|
QString bpAddress; // address acknowledged by the debugger engine
|
|
|
|
|
bool bpMultiple; // happens in constructors/gdb
|
|
|
|
|
|
|
|
|
|
// taken from either user input or gdb responses
|
|
|
|
|
QString markerFileName; // used to locate the marker
|
|
|
|
|
int markerLineNumber;
|
|
|
|
|
|
|
|
|
|
// our red blob in the editor
|
|
|
|
|
BreakpointMarker *marker;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// BreakHandler
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
class BreakHandler : public QAbstractItemModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit BreakHandler(QObject *parent = 0);
|
2008-12-04 11:37:43 +01:00
|
|
|
~BreakHandler();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
void removeAllBreakpoints();
|
|
|
|
|
void setAllPending();
|
|
|
|
|
void loadSessionData();
|
|
|
|
|
void saveSessionData();
|
|
|
|
|
|
|
|
|
|
QAbstractItemModel *model() { return this; }
|
|
|
|
|
|
|
|
|
|
BreakpointData *at(int index) const { return index < size() ? m_bp.at(index) : 0; }
|
|
|
|
|
int size() const { return m_bp.size(); }
|
2009-04-08 16:37:41 +02:00
|
|
|
bool hasPendingBreakpoints() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
void append(BreakpointData *data) { m_bp.append(data); }
|
|
|
|
|
void removeAt(int index); // also deletes the marker
|
|
|
|
|
void clear(); // also deletes all the marker
|
|
|
|
|
int indexOf(BreakpointData *data) { return m_bp.indexOf(data); }
|
2009-04-28 15:08:52 +02:00
|
|
|
int findBreakpoint(const QString &fileName, int lineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
int findBreakpoint(const BreakpointData &data); // returns index
|
|
|
|
|
int findBreakpoint(int bpNumber); // returns index
|
|
|
|
|
void updateMarkers();
|
|
|
|
|
|
2009-04-28 15:08:52 +02:00
|
|
|
QList<BreakpointData *> takeRemovedBreakpoints(); // owned
|
|
|
|
|
QList<BreakpointData *> takeEnabledBreakpoints(); // not owned
|
|
|
|
|
QList<BreakpointData *> takeDisabledBreakpoints(); // not owned
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
void setBreakpoint(const QString &fileName, int lineNumber);
|
2009-04-28 15:08:52 +02:00
|
|
|
void toggleBreakpointEnabled(BreakpointData *data);
|
|
|
|
|
void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
void breakByFunction(const QString &functionName);
|
2009-03-10 17:30:11 +01:00
|
|
|
void activateBreakpoint(int index);
|
2008-12-02 12:01:29 +01:00
|
|
|
void removeBreakpoint(int index);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void gotoLocation(const QString &fileName, int lineNumber, bool setMarker);
|
|
|
|
|
|
|
|
|
|
void sessionValueRequested(const QString &name, QVariant *value);
|
|
|
|
|
void setSessionValueRequested(const QString &name, const QVariant &value);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
friend class BreakpointMarker;
|
|
|
|
|
|
|
|
|
|
// QAbstractItemModel
|
|
|
|
|
int columnCount(const QModelIndex &parent) const;
|
|
|
|
|
int rowCount(const QModelIndex &parent) const;
|
|
|
|
|
QVariant data(const QModelIndex &index, int role) const;
|
|
|
|
|
bool setData(const QModelIndex &index, const QVariant &, int role);
|
|
|
|
|
QModelIndex parent(const QModelIndex &) const { return QModelIndex(); }
|
|
|
|
|
QModelIndex index(int row, int column, const QModelIndex &) const
|
|
|
|
|
{ return createIndex(row, column); }
|
|
|
|
|
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
|
|
|
|
|
|
|
|
void markerUpdated(BreakpointMarker *, int lineNumber);
|
|
|
|
|
void loadBreakpoints();
|
|
|
|
|
void saveBreakpoints();
|
|
|
|
|
void resetBreakpoints();
|
|
|
|
|
void removeBreakpointHelper(int index);
|
|
|
|
|
|
|
|
|
|
QList<BreakpointData *> m_bp;
|
2009-04-28 15:08:52 +02:00
|
|
|
QList<BreakpointData *> m_removed; // lately removed breakpoints
|
|
|
|
|
QList<BreakpointData *> m_enabled; // lately enabled breakpoints
|
|
|
|
|
QList<BreakpointData *> m_disabled; // lately disabled breakpoints
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
|
|
|
|
|
|
|
|
|
#endif // DEBUGGER_BREAKHANDLER_H
|