debuggermanager.h 8.92 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
** Commercial Usage
10
**
11
12
13
14
** 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.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
25
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30
31
32
#ifndef DEBUGGER_DEBUGGERMANAGER_H
#define DEBUGGER_DEBUGGERMANAGER_H

hjk's avatar
hjk committed
33
34
#include "debuggerconstants.h"

con's avatar
con committed
35
#include <QtCore/QObject>
36
#include <QtCore/QSharedPointer>
con's avatar
con committed
37
38
39
40
41
42
#include <QtCore/QStringList>
#include <QtCore/QVariant>

QT_BEGIN_NAMESPACE
class QAction;
class QDockWidget;
43
class QLabel;
44
class QDebug;
45
46
47
class QAbstractItemModel;
class QPoint;
class QVariant;
con's avatar
con committed
48
49
QT_END_NAMESPACE

50
namespace Core {
51
class IOptionsPage;
52
53
54
namespace Utils {
class FancyMainWindow;
}
55
} // namespace Core
56

57
namespace TextEditor {
58
class ITextEditor;
59
60
}

con's avatar
con committed
61
62
63
64
65
66
67
namespace Debugger {
namespace Internal {

class DebuggerOutputWindow;
class DebuggerPlugin;

class BreakHandler;
68
class BreakpointData;
con's avatar
con committed
69
70
class ModulesHandler;
class RegisterHandler;
71
class SourceFilesWindow;
72
struct StackFrame;
con's avatar
con committed
73
class StackHandler;
74
class Symbol;
con's avatar
con committed
75
76
class ThreadsHandler;
class WatchData;
77
class WatchHandler;
78
79
80
81
82
83
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
class CdbDebugEngine;
struct CdbDebugEnginePrivate;
struct DebuggerManagerActions;
con's avatar
con committed
84

85
class DebuggerStartParameters
86
{
87
public:
88
89
90
91
92
93
94
95
96
97
98
    DebuggerStartParameters();
    void clear();

    QString executable;
    QString coreFile;
    QStringList processArgs;
    QStringList environment;
    QString workingDir;
    QString buildDir;
    qint64 attachPID;
    bool useTerminal;
99
    QString crashParameter; // for AttachCrashedExternal
100
101
102
103
    // for remote debugging
    QString remoteChannel;
    QString remoteArchitecture;
    QString serverStartScript;
104
    int toolChainType;
hjk's avatar
hjk committed
105
106
107

    QString dumperLibrary;
    QStringList dumperLibraryLocations;
hjk's avatar
hjk committed
108
    DebuggerStartMode startMode;
109
110
};

hjk's avatar
hjk committed
111
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
112
113
114
QDebug operator<<(QDebug str, const DebuggerStartParameters &);

// Flags for initialization
hjk's avatar
hjk committed
115
116
117
118
119
120
121
122
123
124
enum DebuggerEngineTypeFlags
{
    GdbEngineType     = 0x01,
    ScriptEngineType  = 0x02,
    CdbEngineType     = 0x04,
    TcfEngineType     = 0x08,
    AllEngineTypes = GdbEngineType
        | ScriptEngineType 
        | CdbEngineType 
        | TcfEngineType
125
126
};

hjk's avatar
hjk committed
127
QDebug operator<<(QDebug d, DebuggerState state);
con's avatar
con committed
128
129

//
hjk's avatar
hjk committed
130
// DebuggerManager
con's avatar
con committed
131
132
//

133
134
struct DebuggerManagerPrivate;

hjk's avatar
hjk committed
135
class DebuggerManager : public QObject
con's avatar
con committed
136
{
hjk's avatar
hjk committed
137
    Q_OBJECT
con's avatar
con committed
138

hjk's avatar
hjk committed
139
140
141
public:
    DebuggerManager();
    ~DebuggerManager();
142

143
144
    friend class IDebuggerEngine;
    friend class DebuggerPlugin;
145
    friend class CdbDebugEventCallback;
146
    friend class CdbDumperHelper;
147
    friend class CdbExceptionLoggerEventCallback;
148
149
150
    friend class GdbEngine;
    friend class ScriptEngine;
    friend class TcfEngine;
Friedemann Kleint's avatar
Friedemann Kleint committed
151
    friend class CdbDebugEngine;
152
    friend struct CdbDebugEnginePrivate;
con's avatar
con committed
153

154
    QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
155

156
157
158
    Core::Utils::FancyMainWindow *mainWindow() const;
    QLabel *statusLabel() const;
    IDebuggerEngine *currentEngine() const;
con's avatar
con committed
159

160
161
    DebuggerStartParametersPtr startParameters() const;
    qint64 inferiorPid() const;
hjk's avatar
hjk committed
162

163
164
    void showMessageBox(int icon, const QString &title, const QString &text);

con's avatar
con committed
165
public slots:
hjk's avatar
hjk committed
166
    void startNewDebugger(const DebuggerStartParametersPtr &sp);
167
168
    void exitDebugger();

con's avatar
con committed
169
170
171
172
173
    void setSimpleDockWidgetArrangement();

    void setBusyCursor(bool on);
    void queryCurrentTextEditor(QString *fileName, int *lineNumber, QObject **ed);

174
    void gotoLocation(const StackFrame &frame, bool setLocationMarker);
175
    void fileOpen(const QString &file);
con's avatar
con committed
176
177
178
179
180
181
182
183
184
    void resetLocation();

    void interruptDebuggingRequest();

    void jumpToLineExec();
    void runToLineExec();
    void runToFunctionExec();
    void toggleBreakpoint();
    void breakByFunction(const QString &functionName);
185
    void breakByFunctionMain();
con's avatar
con committed
186
187
188
189
190
191
192
193
    void setBreakpoint(const QString &fileName, int lineNumber);
    void activateFrame(int index);
    void selectThread(int index);

    void stepExec();
    void stepOutExec();
    void nextExec();
    void continueExec();
194
    void detachDebugger();
con's avatar
con committed
195
196

    void addToWatchWindow();
197
    void updateWatchData(const WatchData &data);
198

con's avatar
con committed
199
    void sessionLoaded();
200
    void aboutToUnloadSession();
con's avatar
con committed
201
    void aboutToSaveSession();
202
203
    QVariant sessionValue(const QString &name);
    void setSessionValue(const QString &name, const QVariant &value);
con's avatar
con committed
204

205
    void assignValueInDebugger();
con's avatar
con committed
206
    void assignValueInDebugger(const QString &expr, const QString &value);
207
208

    void executeDebuggerCommand();
con's avatar
con committed
209
210
    void executeDebuggerCommand(const QString &command);

211
    void watchPoint();
212
    void setRegisterValue(int nr, const QString &value);
213

214
    void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
con's avatar
con committed
215
216

private slots:
hjk's avatar
hjk committed
217
218
    void showDebuggerOutput(const QString &msg)
        { showDebuggerOutput(LogDebug, msg); }
219
220
    void showDebuggerOutput(int channel, const QString &msg);
    void showDebuggerInput(int channel, const QString &msg);
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
221
    void showApplicationOutput(const QString &data);
con's avatar
con committed
222

223
224
225
    void reloadSourceFiles();
    void sourceFilesDockToggled(bool on);

con's avatar
con committed
226
227
228
229
230
231
232
    void reloadModules();
    void modulesDockToggled(bool on);
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();

    void reloadRegisters();
    void registerDockToggled(bool on);
233
    void clearStatusMessage();
234
    void attemptBreakpointSynchronization();
235
    void reloadFullStack();
236
    void stepByInstructionTriggered();
hjk's avatar
hjk committed
237
    void startFailed();
con's avatar
con committed
238
239

private:
240
241
242
243
244
245
246
247
248
    ModulesHandler *modulesHandler() const;
    BreakHandler *breakHandler() const;
    RegisterHandler *registerHandler() const;
    StackHandler *stackHandler() const;
    ThreadsHandler *threadsHandler() const;
    WatchHandler *watchHandler() const;
    SourceFilesWindow *sourceFileWindow() const;
    QWidget *threadsWindow() const;    
    DebuggerManagerActions debuggerManagerActions() const;
249

con's avatar
con committed
250
251
252
    void notifyInferiorStopped();
    void notifyInferiorRunning();
    void notifyInferiorExited();
253
    void notifyInferiorPidChanged(qint64);
con's avatar
con committed
254

255
    void cleanupViews();
con's avatar
con committed
256

hjk's avatar
hjk committed
257
258
259
    DebuggerState state() const;
    void setState(DebuggerState state);

260
    //
con's avatar
con committed
261
    // internal implementation
262
    //
263
264
265
266
267
268
269
    bool qtDumperLibraryEnabled() const;
    QString qtDumperLibraryName() const;
    QStringList qtDumperLibraryLocations() const;
    void showQtDumperLibraryWarning(const QString &details = QString());
    bool isReverseDebugging() const;
    QAbstractItemModel *threadsModel();

con's avatar
con committed
270
271
272
273
274
    Q_SLOT void loadSessionData();
    Q_SLOT void saveSessionData();
    Q_SLOT void dumpLog();

public:
275
    // stuff in this block should be made private by moving it to
con's avatar
con committed
276
    // one of the interfaces
277
278
    QList<Symbol> moduleSymbols(const QString &moduleName);

con's avatar
con committed
279
280
281
signals:
    void debuggingFinished();
    void inferiorPidChanged(qint64 pid);
hjk's avatar
hjk committed
282
    void stateChanged(int newstatus);
con's avatar
con committed
283
284
285
    void debugModeRequested();
    void previousModeRequested();
    void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
286
    void gotoLocationRequested(const StackFrame &frame, bool setLocationMarker);
con's avatar
con committed
287
288
289
290
291
292
    void resetLocationRequested();
    void currentTextEditorRequested(QString *fileName, int *lineNumber, QObject **ob);
    void sessionValueRequested(const QString &name, QVariant *value);
    void setSessionValueRequested(const QString &name, const QVariant &value);
    void configValueRequested(const QString &name, QVariant *value);
    void setConfigValueRequested(const QString &name, const QVariant &value);
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
293
    void applicationOutputAvailable(const QString &output);
con's avatar
con committed
294
295

private:
296
    void init();
hjk's avatar
hjk committed
297
    void runTest(const QString &fileName);
hjk's avatar
hjk committed
298
    Q_SLOT void createNewDock(QWidget *widget);
con's avatar
con committed
299
300
301
302

    void shutdown();

    void toggleBreakpoint(const QString &fileName, int lineNumber);
303
304
    void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
    BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
hjk's avatar
hjk committed
305
306
    void setToolTipExpression(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
con's avatar
con committed
307

308
    DebuggerManagerPrivate *d;
con's avatar
con committed
309
310
311
312
313
314
};

} // namespace Internal
} // namespace Debugger

#endif // DEBUGGER_DEBUGGERMANAGER_H