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

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

60
namespace TextEditor {
61
class ITextEditor;
62
class FontSettings;
63
64
}

65
66
67
68
namespace CPlusPlus {
    class Snapshot;
}

con's avatar
con committed
69
70
71
72
73
74
75
namespace Debugger {
namespace Internal {

class DebuggerOutputWindow;
class DebuggerPlugin;

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

105
class DEBUGGER_EXPORT DebuggerStartParameters
106
{
107
public:
108
109
110
111
112
113
114
115
116
117
118
    DebuggerStartParameters();
    void clear();

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

    QString dumperLibrary;
    QStringList dumperLibraryLocations;
hjk's avatar
hjk committed
133
    DebuggerStartMode startMode;
134
135
};

hjk's avatar
hjk committed
136
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
137
138

DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
139
140

// Flags for initialization
hjk's avatar
hjk committed
141
142
143
144
145
146
enum DebuggerEngineTypeFlags
{
    GdbEngineType     = 0x01,
    ScriptEngineType  = 0x02,
    CdbEngineType     = 0x04,
    AllEngineTypes = GdbEngineType
147
148
        | ScriptEngineType
        | CdbEngineType
149
150
};

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

//
hjk's avatar
hjk committed
154
// DebuggerManager
con's avatar
con committed
155
156
//

157
158
struct DebuggerManagerPrivate;

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

hjk's avatar
hjk committed
163
164
165
public:
    DebuggerManager();
    ~DebuggerManager();
166

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

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

183
    Utils::FancyMainWindow *mainWindow() const;
184
    QLabel *statusLabel() const;
185
    Internal::IDebuggerEngine *currentEngine() const;
con's avatar
con committed
186

187
188
    DebuggerStartParametersPtr startParameters() const;
    qint64 inferiorPid() const;
hjk's avatar
hjk committed
189

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

193
    bool debuggerActionsEnabled() const;
194
    unsigned debuggerCapabilities() const;
195

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

201
202
    const CPlusPlus::Snapshot &cppCodeModelSnapshot() const;

203
204
    QIcon locationMarkIcon() const;

205
206
    static DebuggerManager *instance();

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

con's avatar
con committed
211
212
213
214
215
    void setSimpleDockWidgetArrangement();

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

216
    void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
217
    void fileOpen(const QString &file);
con's avatar
con committed
218
219
220
221
222
223
224
225
226
    void resetLocation();

    void interruptDebuggingRequest();

    void jumpToLineExec();
    void runToLineExec();
    void runToFunctionExec();
    void toggleBreakpoint();
    void breakByFunction(const QString &functionName);
227
    void breakByFunctionMain();
con's avatar
con committed
228
229
230
    void setBreakpoint(const QString &fileName, int lineNumber);
    void activateFrame(int index);
    void selectThread(int index);
231
232
    void activateSnapshot(int index);
    void removeSnapshot(int index);
con's avatar
con committed
233
234
235
236
237

    void stepExec();
    void stepOutExec();
    void nextExec();
    void continueExec();
238
    void detachDebugger();
239
    void makeSnapshot();
con's avatar
con committed
240
241

    void addToWatchWindow();
242
    void updateWatchData(const Debugger::Internal::WatchData &data);
243

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

250
    void assignValueInDebugger();
con's avatar
con committed
251
    void assignValueInDebugger(const QString &expr, const QString &value);
252
253

    void executeDebuggerCommand();
con's avatar
con committed
254
255
    void executeDebuggerCommand(const QString &command);

256
    void watchPoint();
257
    void setRegisterValue(int nr, const QString &value);
258

259
    void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
260
    void clearCppCodeModelSnapshot();
con's avatar
con committed
261

262
263
    static const char *stateName(int s);

264
public slots: // FIXME
hjk's avatar
hjk committed
265
266
    void showDebuggerOutput(const QString &msg)
        { showDebuggerOutput(LogDebug, msg); }
Friedemann Kleint's avatar
Friedemann Kleint committed
267
268
   void ensureLogVisible();

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);
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
272
    void showApplicationOutput(const QString &data);
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
337
338
    void debugModeRequested();
    void previousModeRequested();
    void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
339
    void gotoLocationRequested(const QString &file, int line, bool setLocationMarker);
con's avatar
con committed
340
341
342
343
344
345
    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
346
    void applicationOutputAvailable(const QString &output);
347
348
    void emitShowOutput(int channel, const QString &output);
    void emitShowInput(int channel, const QString &input);
con's avatar
con committed
349
350

private:
351
    void init();
hjk's avatar
hjk committed
352
    void runTest(const QString &fileName);
hjk's avatar
hjk committed
353
    Q_SLOT void createNewDock(QWidget *widget);
con's avatar
con committed
354
355
356
357

    void shutdown();

    void toggleBreakpoint(const QString &fileName, int lineNumber);
358
    void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
359
    Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
hjk's avatar
hjk committed
360
361
    void setToolTipExpression(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
con's avatar
con committed
362

363
    DebuggerManagerPrivate *d;
con's avatar
con committed
364
365
366
367
368
};

} // namespace Debugger

#endif // DEBUGGER_DEBUGGERMANAGER_H