| 
									
										
										
										
											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
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-17 17:31:52 +02:00
										 |  |  | #include <utils/qtcassert.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | #include <QtCore/QObject>
 | 
					
						
							| 
									
										
										
										
											2009-10-01 11:22:44 +02:00
										 |  |  | #include <QtCore/QAbstractTableModel>
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace Debugger { | 
					
						
							| 
									
										
										
										
											2009-09-25 16:01:28 +02:00
										 |  |  | class DebuggerManager; | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 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
 | 
					
						
							| 
									
										
										
										
											2009-05-11 13:21:59 +02:00
										 |  |  |     bool useFullPath;       // should we use the full path when setting the bp?
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // 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
 | 
					
						
							| 
									
										
										
										
											2009-06-10 10:30:48 +02:00
										 |  |  |     bool    bpEnabled;      // enable/disable command sent
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // 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
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //////////////////////////////////////////////////////////////////
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-01 11:22:44 +02:00
										 |  |  | class BreakHandler : public QAbstractTableModel | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     explicit BreakHandler(DebuggerManager *manager, 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; } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-17 17:31:52 +02:00
										 |  |  |     BreakpointData *at(int index) const { QTC_ASSERT(index < size(), return 0); return m_bp.at(index); } | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     int size() const { return m_bp.size(); } | 
					
						
							| 
									
										
										
										
											2009-04-08 16:37:41 +02:00
										 |  |  |     bool hasPendingBreakpoints() const; | 
					
						
							| 
									
										
										
										
											2009-05-12 14:28:27 +02:00
										 |  |  |     void append(BreakpointData *data); | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     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-05-12 14:28:27 +02:00
										 |  |  |     QList<BreakpointData *> insertedBreakpoints() const; | 
					
						
							|  |  |  |     void takeInsertedBreakPoint(BreakpointData *); | 
					
						
							| 
									
										
										
										
											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); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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); | 
					
						
							|  |  |  |     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); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-08-14 13:04:05 +02:00
										 |  |  |     DebuggerManager *m_manager; // not owned
 | 
					
						
							| 
									
										
										
										
											2008-12-02 12:01:29 +01:00
										 |  |  |     QList<BreakpointData *> m_bp; | 
					
						
							| 
									
										
										
										
											2009-05-12 14:28:27 +02:00
										 |  |  |     QList<BreakpointData *> m_inserted; // lately inserted breakpoints
 | 
					
						
							| 
									
										
										
										
											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
 |