debuggermanager.h 10.4 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
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
hjk's avatar
hjk committed
86
class PythonEngine;
87
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
enum DebuggerEngineTypeFlags
{
    GdbEngineType     = 0x01,
    ScriptEngineType  = 0x02,
    CdbEngineType     = 0x04,
hjk's avatar
hjk committed
142
    PythonEngineType  = 0x08,
hjk's avatar
hjk committed
143
    AllEngineTypes = GdbEngineType
144
145
        | ScriptEngineType
        | CdbEngineType
hjk's avatar
hjk committed
146
        | PythonEngineType
147
148
};

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

//
hjk's avatar
hjk committed
152
// DebuggerManager
con's avatar
con committed
153
154
//

155
156
struct DebuggerManagerPrivate;

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

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

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

179
    DebuggerState state() const;
180
    QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
181

182
    QLabel *statusLabel() const;
183
    Internal::IDebuggerEngine *currentEngine() const;
con's avatar
con committed
184

185
186
    DebuggerStartParametersPtr startParameters() const;
    qint64 inferiorPid() const;
hjk's avatar
hjk committed
187

188
189
    QMessageBox *showMessageBox(int icon, const QString &title, const QString &text,
        int buttons = 0);
190

191
    bool debuggerActionsEnabled() const;
192
    unsigned debuggerCapabilities() const;
193

194
195
196
197
198
    bool checkDebugConfiguration(int toolChain,
                                 QString *errorMessage,
                                 QString *settingsCategory = 0,
                                 QString *settingsPage = 0) const;

199
200
    const CPlusPlus::Snapshot &cppCodeModelSnapshot() const;

201
202
    QIcon locationMarkIcon() const;

203
204
    static DebuggerManager *instance();

con's avatar
con committed
205
public slots:
hjk's avatar
hjk committed
206
    void startNewDebugger(const DebuggerStartParametersPtr &sp);
207
    void exitDebugger();
208
    void abortDebugger();
209

210
    void setSimpleDockWidgetArrangement(const QString &activeLanguage);
con's avatar
con committed
211
212
213

    void setBusyCursor(bool on);

214
    void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
215
    void fileOpen(const QString &file);
con's avatar
con committed
216
217
218
219
    void resetLocation();

    void interruptDebuggingRequest();

hjk's avatar
hjk committed
220
221
222
    void executeJumpToLine();
    void executeRunToLine();
    void executeRunToFunction();
con's avatar
con committed
223
    void breakByFunction(const QString &functionName);
224
    void breakByFunctionMain();
con's avatar
con committed
225
226
    void activateFrame(int index);
    void selectThread(int index);
227
228
    void activateSnapshot(int index);
    void removeSnapshot(int index);
con's avatar
con committed
229

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

    void addToWatchWindow();
239
    void updateWatchData(const Debugger::Internal::WatchData &data);
240

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

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

    void executeDebuggerCommand();
con's avatar
con committed
251
252
    void executeDebuggerCommand(const QString &command);

253
    void watchPoint();
254
    void setRegisterValue(int nr, const QString &value);
255

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

259
260
    static const char *stateName(int s);

261
public slots: // FIXME
hjk's avatar
hjk committed
262
263
    void showDebuggerOutput(const QString &msg)
        { showDebuggerOutput(LogDebug, msg); }
264
    void ensureLogVisible();
265
    void updateWatchersWindow();
266
    void updateWatchersHeader(int section, int oldSize, int newSize);
hjk's avatar
hjk committed
267
    void activateBreakpoint(int index);
Friedemann Kleint's avatar
Friedemann Kleint committed
268

hjk's avatar
hjk committed
269
//private slots:  // FIXME
270
271
    void showDebuggerOutput(int channel, const QString &msg);
    void showDebuggerInput(int channel, const QString &msg);
272
    void showApplicationOutput(const QString &data, bool onStdErr);
con's avatar
con committed
273

274
275
276
    void reloadSourceFiles();
    void sourceFilesDockToggled(bool on);

con's avatar
con committed
277
278
279
280
281
282
283
    void reloadModules();
    void modulesDockToggled(bool on);
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();

    void reloadRegisters();
    void registerDockToggled(bool on);
284
    void clearStatusMessage();
285
    void attemptBreakpointSynchronization();
286
    void reloadFullStack();
287
    void operateByInstructionTriggered();
hjk's avatar
hjk committed
288
    void startFailed();
con's avatar
con committed
289
290

private:
291
292
293
294
295
296
    Internal::ModulesHandler *modulesHandler() const;
    Internal::BreakHandler *breakHandler() const;
    Internal::RegisterHandler *registerHandler() const;
    Internal::StackHandler *stackHandler() const;
    Internal::ThreadsHandler *threadsHandler() const;
    Internal::WatchHandler *watchHandler() const;
297
    Internal::SnapshotHandler *snapshotHandler() const;
298
    Internal::SourceFilesWindow *sourceFileWindow() const;
299
    QWidget *threadsWindow() const;
300

301
    Internal::DebuggerManagerActions debuggerManagerActions() const;
302

con's avatar
con committed
303
304
305
    void notifyInferiorStopped();
    void notifyInferiorRunning();
    void notifyInferiorExited();
306
    void notifyInferiorPidChanged(qint64);
con's avatar
con committed
307

308
    void cleanupViews();
con's avatar
con committed
309

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

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

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

con's avatar
con committed
332
333
334
signals:
    void debuggingFinished();
    void inferiorPidChanged(qint64 pid);
hjk's avatar
hjk committed
335
    void stateChanged(int newstatus);
con's avatar
con committed
336
    void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
337
338
    void applicationOutputAvailable(const QString &output, bool onStdErr);
    void messageAvailable(const QString &output, bool isError);
339
340
    void emitShowOutput(int channel, const QString &output);
    void emitShowInput(int channel, const QString &input);
con's avatar
con committed
341
342

private:
343
    void init();
hjk's avatar
hjk committed
344
    void runTest(const QString &fileName);
hjk's avatar
hjk committed
345
    Q_SLOT void createNewDock(QWidget *widget);
con's avatar
con committed
346
347
348
349

    void shutdown();

    void toggleBreakpoint(const QString &fileName, int lineNumber);
350
    Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
hjk's avatar
hjk committed
351
352
    void setToolTipExpression(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
353
354
    void openTextEditor(const QString &titlePattern,
        const QString &contents);
con's avatar
con committed
355

356
    DebuggerManagerPrivate *d;
con's avatar
con committed
357
358
359
360
361
};

} // namespace Debugger

#endif // DEBUGGER_DEBUGGERMANAGER_H