debuggermanager.h 10.5 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

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;
con's avatar
con committed
50
51
QT_END_NAMESPACE

52
namespace Core {
53
class IOptionsPage;
54
}
55
56
57
namespace Utils {
class FancyMainWindow;
}
58

59
namespace TextEditor {
60
class ITextEditor;
61
62
}

63
64
65
66
namespace CPlusPlus {
    class Snapshot;
}

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

class DebuggerOutputWindow;
class DebuggerPlugin;

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

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

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

    QString dumperLibrary;
    QStringList dumperLibraryLocations;
hjk's avatar
hjk committed
131
    DebuggerStartMode startMode;
132
133
};

hjk's avatar
hjk committed
134
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
135
136

DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
137
138

// Flags for initialization
hjk's avatar
hjk committed
139
140
141
142
143
144
enum DebuggerEngineTypeFlags
{
    GdbEngineType     = 0x01,
    ScriptEngineType  = 0x02,
    CdbEngineType     = 0x04,
    AllEngineTypes = GdbEngineType
145
146
        | ScriptEngineType
        | CdbEngineType
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
162
163
public:
    DebuggerManager();
    ~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
173
    friend class Internal::CdbExceptionLoggerEventCallback;
    friend class Internal::GdbEngine;
    friend class Internal::ScriptEngine;
    friend class Internal::CdbDebugEngine;
174
    friend class Internal::CdbDebugEnginePrivate;
175
    friend class Internal::TrkGdbAdapter;
con's avatar
con committed
176

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

180
    Utils::FancyMainWindow *mainWindow() const;
181
    QLabel *statusLabel() const;
182
    Internal::IDebuggerEngine *currentEngine() const;
con's avatar
con committed
183

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

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

190
191
    bool debuggerActionsEnabled() const;

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

197
198
    const CPlusPlus::Snapshot &cppCodeModelSnapshot() 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();

con's avatar
con committed
205
206
207
208
209
    void setSimpleDockWidgetArrangement();

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

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
216
217
218
219
220
    void resetLocation();

    void interruptDebuggingRequest();

    void jumpToLineExec();
    void runToLineExec();
    void runToFunctionExec();
    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
228
229
230
231

    void stepExec();
    void stepOutExec();
    void nextExec();
    void continueExec();
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); }
Friedemann Kleint's avatar
Friedemann Kleint committed
261
262
   void ensureLogVisible();

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

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

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

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

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

295
    Internal::DebuggerManagerActions debuggerManagerActions() const;
296

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

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

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

306
    //
con's avatar
con committed
307
    // internal implementation
308
    //
309
310
311
312
313
314
315
    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
316
317
318
319
320
    Q_SLOT void loadSessionData();
    Q_SLOT void saveSessionData();
    Q_SLOT void dumpLog();

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

con's avatar
con committed
325
326
327
signals:
    void debuggingFinished();
    void inferiorPidChanged(qint64 pid);
hjk's avatar
hjk committed
328
    void stateChanged(int newstatus);
con's avatar
con committed
329
330
331
    void debugModeRequested();
    void previousModeRequested();
    void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
332
    void gotoLocationRequested(const QString &file, int line, bool setLocationMarker);
con's avatar
con committed
333
334
335
336
337
338
    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
339
    void applicationOutputAvailable(const QString &output);
340
341
    void emitShowOutput(int channel, const QString &output);
    void emitShowInput(int channel, const QString &input);
con's avatar
con committed
342
343

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

    void shutdown();

    void toggleBreakpoint(const QString &fileName, int lineNumber);
351
    void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
352
    Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
hjk's avatar
hjk committed
353
354
    void setToolTipExpression(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
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