debuggermanager.h 10.2 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2010 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

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

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

QT_BEGIN_NAMESPACE
42
class QAbstractItemModel;
con's avatar
con committed
43
class QAction;
44
class QDebug;
con's avatar
con committed
45
class QDockWidget;
46
class QLabel;
47
class QMessageBox;
48
class QPoint;
49
class QIcon;
con's avatar
con committed
50
51
QT_END_NAMESPACE

52
namespace Core {
53
class IOptionsPage;
54
}
55

56
namespace TextEditor {
57
class ITextEditor;
58
class FontSettings;
59
60
}

61
62
63
64
namespace CPlusPlus {
    class Snapshot;
}

con's avatar
con committed
65
66
67
68
69
70
71
namespace Debugger {
namespace Internal {

class DebuggerOutputWindow;
class DebuggerPlugin;

class BreakHandler;
72
class BreakpointData;
con's avatar
con committed
73
74
class ModulesHandler;
class RegisterHandler;
75
class SourceFilesWindow;
76
struct StackFrame;
con's avatar
con committed
77
class StackHandler;
78
class Symbol;
79
class SnapshotHandler;
con's avatar
con committed
80
81
class ThreadsHandler;
class WatchData;
82
class WatchHandler;
83
84
85
86
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
class CdbDebugEngine;
87
class CdbDebugEnginePrivate;
88
struct DebuggerManagerActions;
89
90
class CdbDebugEventCallback;
class CdbDumperHelper;
91
class CdbDumperInitThread;
92
93
94
class CdbExceptionLoggerEventCallback;
class GdbEngine;
class CdbDebugEngine;
95
class CdbDebugEnginePrivate;
96
class TrkGdbAdapter;
97
class BreakpointMarker;
98
} // namespace Internal
con's avatar
con committed
99

100
class DEBUGGER_EXPORT DebuggerStartParameters
101
{
102
public:
103
104
105
106
107
108
109
110
111
112
113
    DebuggerStartParameters();
    void clear();

    QString executable;
    QString coreFile;
    QStringList processArgs;
    QStringList environment;
    QString workingDir;
    QString buildDir;
    qint64 attachPID;
    bool useTerminal;
114
    QString crashParameter; // for AttachCrashedExternal
115
116
117
    // for remote debugging
    QString remoteChannel;
    QString remoteArchitecture;
118
    QString symbolFileName;
119
    QString serverStartScript;
120
    QString sysRoot;
ck's avatar
ck committed
121
    QString debuggerCommand;
122
    int toolChainType;
ck's avatar
ck committed
123
    QString remoteDumperLib;
hjk's avatar
hjk committed
124
    QString qtInstallPath;
hjk's avatar
hjk committed
125
126
127

    QString dumperLibrary;
    QStringList dumperLibraryLocations;
hjk's avatar
hjk committed
128
    DebuggerStartMode startMode;
129
130
};

hjk's avatar
hjk committed
131
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
132
133

DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
134
135

// Flags for initialization
hjk's avatar
hjk committed
136
137
138
139
140
141
enum DebuggerEngineTypeFlags
{
    GdbEngineType     = 0x01,
    ScriptEngineType  = 0x02,
    CdbEngineType     = 0x04,
    AllEngineTypes = GdbEngineType
142
143
        | ScriptEngineType
        | CdbEngineType
144
145
};

hjk's avatar
hjk committed
146
QDebug operator<<(QDebug d, DebuggerState state);
con's avatar
con committed
147
148

//
hjk's avatar
hjk committed
149
// DebuggerManager
con's avatar
con committed
150
151
//

152
153
struct DebuggerManagerPrivate;

154
class DEBUGGER_EXPORT DebuggerManager : public QObject
con's avatar
con committed
155
{
hjk's avatar
hjk committed
156
    Q_OBJECT
con's avatar
con committed
157

hjk's avatar
hjk committed
158
public:
159
    explicit DebuggerManager(Internal::DebuggerPlugin *plugin);
hjk's avatar
hjk committed
160
    ~DebuggerManager();
161

162
163
164
165
    friend class Internal::IDebuggerEngine;
    friend class Internal::DebuggerPlugin;
    friend class Internal::CdbDebugEventCallback;
    friend class Internal::CdbDumperHelper;
166
    friend class Internal::CdbDumperInitThread;
167
168
169
170
    friend class Internal::CdbExceptionLoggerEventCallback;
    friend class Internal::GdbEngine;
    friend class Internal::ScriptEngine;
    friend class Internal::CdbDebugEngine;
171
    friend class Internal::CdbDebugEnginePrivate;
172
    friend class Internal::TrkGdbAdapter;
173
    friend class Internal::BreakpointMarker;
con's avatar
con committed
174

175
    DebuggerState state() const;
176
    QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
177

178
    QLabel *statusLabel() const;
179
    Internal::IDebuggerEngine *currentEngine() const;
con's avatar
con committed
180

181
182
    DebuggerStartParametersPtr startParameters() const;
    qint64 inferiorPid() const;
hjk's avatar
hjk committed
183

184
185
    QMessageBox *showMessageBox(int icon, const QString &title, const QString &text,
        int buttons = 0);
186

187
    bool debuggerActionsEnabled() const;
188
    unsigned debuggerCapabilities() const;
189

190
191
192
193
194
    bool checkDebugConfiguration(int toolChain,
                                 QString *errorMessage,
                                 QString *settingsCategory = 0,
                                 QString *settingsPage = 0) const;

195
196
    const CPlusPlus::Snapshot &cppCodeModelSnapshot() const;

197
198
    QIcon locationMarkIcon() const;

199
200
    static DebuggerManager *instance();

con's avatar
con committed
201
public slots:
hjk's avatar
hjk committed
202
    void startNewDebugger(const DebuggerStartParametersPtr &sp);
203
204
    void exitDebugger();

205
    void setSimpleDockWidgetArrangement(const QString &activeLanguage);
con's avatar
con committed
206
207
208

    void setBusyCursor(bool on);

209
    void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
210
    void fileOpen(const QString &file);
con's avatar
con committed
211
212
213
214
    void resetLocation();

    void interruptDebuggingRequest();

hjk's avatar
hjk committed
215
216
217
    void executeJumpToLine();
    void executeRunToLine();
    void executeRunToFunction();
con's avatar
con committed
218
219
    void toggleBreakpoint();
    void breakByFunction(const QString &functionName);
220
    void breakByFunctionMain();
con's avatar
con committed
221
222
223
    void setBreakpoint(const QString &fileName, int lineNumber);
    void activateFrame(int index);
    void selectThread(int index);
224
225
    void activateSnapshot(int index);
    void removeSnapshot(int index);
con's avatar
con committed
226

hjk's avatar
hjk committed
227
228
229
230
231
    void executeStep();
    void executeStepOut();
    void executeStepNext();
    void executeContinue();
    void executeReturn();
232
    void detachDebugger();
233
    void makeSnapshot();
con's avatar
con committed
234
235

    void addToWatchWindow();
236
    void updateWatchData(const Debugger::Internal::WatchData &data);
237

con's avatar
con committed
238
    void sessionLoaded();
239
    void aboutToUnloadSession();
con's avatar
con committed
240
    void aboutToSaveSession();
241
242
    QVariant sessionValue(const QString &name);
    void setSessionValue(const QString &name, const QVariant &value);
con's avatar
con committed
243

244
    void assignValueInDebugger();
con's avatar
con committed
245
    void assignValueInDebugger(const QString &expr, const QString &value);
246
247

    void executeDebuggerCommand();
con's avatar
con committed
248
249
    void executeDebuggerCommand(const QString &command);

250
    void watchPoint();
251
    void setRegisterValue(int nr, const QString &value);
252

253
    void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
254
    void clearCppCodeModelSnapshot();
con's avatar
con committed
255

256
257
    static const char *stateName(int s);

258
public slots: // FIXME
hjk's avatar
hjk committed
259
260
    void showDebuggerOutput(const QString &msg)
        { showDebuggerOutput(LogDebug, msg); }
261
    void ensureLogVisible();
262
    void updateWatchersWindow();
Friedemann Kleint's avatar
Friedemann Kleint committed
263

hjk's avatar
hjk committed
264
//private slots:  // FIXME
265
266
    void showDebuggerOutput(int channel, const QString &msg);
    void showDebuggerInput(int channel, const QString &msg);
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
267
    void showApplicationOutput(const QString &data);
con's avatar
con committed
268

269
270
271
    void reloadSourceFiles();
    void sourceFilesDockToggled(bool on);

con's avatar
con committed
272
273
274
275
276
277
278
    void reloadModules();
    void modulesDockToggled(bool on);
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();

    void reloadRegisters();
    void registerDockToggled(bool on);
279
    void clearStatusMessage();
280
    void attemptBreakpointSynchronization();
281
    void reloadFullStack();
282
    void operateByInstructionTriggered();
hjk's avatar
hjk committed
283
    void startFailed();
con's avatar
con committed
284
285

private:
286
287
288
289
290
291
    Internal::ModulesHandler *modulesHandler() const;
    Internal::BreakHandler *breakHandler() const;
    Internal::RegisterHandler *registerHandler() const;
    Internal::StackHandler *stackHandler() const;
    Internal::ThreadsHandler *threadsHandler() const;
    Internal::WatchHandler *watchHandler() const;
292
    Internal::SnapshotHandler *snapshotHandler() const;
293
    Internal::SourceFilesWindow *sourceFileWindow() const;
294
    QWidget *threadsWindow() const;
295

296
    Internal::DebuggerManagerActions debuggerManagerActions() const;
297

con's avatar
con committed
298
299
300
    void notifyInferiorStopped();
    void notifyInferiorRunning();
    void notifyInferiorExited();
301
    void notifyInferiorPidChanged(qint64);
con's avatar
con committed
302

303
    void cleanupViews();
con's avatar
con committed
304

Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
305
    void setState(DebuggerState state, bool forced = false);
hjk's avatar
hjk committed
306

307
    //
con's avatar
con committed
308
    // internal implementation
309
    //
310
311
312
313
314
315
316
    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
317
318
319
    Q_SLOT void loadSessionData();
    Q_SLOT void saveSessionData();
    Q_SLOT void dumpLog();
320
    Q_SLOT void fontSettingsChanged(const TextEditor::FontSettings &settings);
con's avatar
con committed
321
322

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

con's avatar
con committed
327
328
329
signals:
    void debuggingFinished();
    void inferiorPidChanged(qint64 pid);
hjk's avatar
hjk committed
330
    void stateChanged(int newstatus);
con's avatar
con committed
331
    void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
332
    void applicationOutputAvailable(const QString &output);
333
334
    void emitShowOutput(int channel, const QString &output);
    void emitShowInput(int channel, const QString &input);
con's avatar
con committed
335
336

private:
337
    void init();
hjk's avatar
hjk committed
338
    void runTest(const QString &fileName);
hjk's avatar
hjk committed
339
    Q_SLOT void createNewDock(QWidget *widget);
con's avatar
con committed
340
341
342
343

    void shutdown();

    void toggleBreakpoint(const QString &fileName, int lineNumber);
344
    void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
345
    Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
hjk's avatar
hjk committed
346
347
    void setToolTipExpression(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
348
349
    void openTextEditor(const QString &titlePattern,
        const QString &contents);
con's avatar
con committed
350

351
    DebuggerManagerPrivate *d;
con's avatar
con committed
352
353
354
355
356
};

} // namespace Debugger

#endif // DEBUGGER_DEBUGGERMANAGER_H