debuggermanager.h 10.1 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
49
class QPoint;
class QVariant;
50
class QIcon;
con's avatar
con committed
51
52
QT_END_NAMESPACE

53
namespace Core {
54
class IOptionsPage;
55
}
56

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

62
63
64
65
namespace CPlusPlus {
    class Snapshot;
}

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

class DebuggerOutputWindow;
class DebuggerPlugin;

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

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

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

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

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

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

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

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

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

153
154
struct DebuggerManagerPrivate;

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

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

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

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

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

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

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

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

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

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

198
199
    QIcon locationMarkIcon() const;

200
201
    static DebuggerManager *instance();

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

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

    void setBusyCursor(bool on);

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

    void interruptDebuggingRequest();

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

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

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

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

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

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

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

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

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

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

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);
con's avatar
con committed
348

349
    DebuggerManagerPrivate *d;
con's avatar
con committed
350
351
352
353
354
};

} // namespace Debugger

#endif // DEBUGGER_DEBUGGERMANAGER_H