debuggermanager.h 10.1 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
42
43
#include <QtCore/QStringList>
#include <QtCore/QVariant>

QT_BEGIN_NAMESPACE
class QAction;
class QDockWidget;
44
class QLabel;
45
class QDebug;
46
47
48
class QAbstractItemModel;
class QPoint;
class QVariant;
con's avatar
con committed
49
50
QT_END_NAMESPACE

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

58
namespace TextEditor {
59
class ITextEditor;
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;
con's avatar
con committed
80
81
class ThreadsHandler;
class WatchData;
82
class WatchHandler;
83
84
85
86
87
88
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
class CdbDebugEngine;
struct CdbDebugEnginePrivate;
struct DebuggerManagerActions;
89
90
91
class DebuggerPlugin;
class CdbDebugEventCallback;
class CdbDumperHelper;
92
class CdbDumperInitThread;
93
94
95
96
97
class CdbExceptionLoggerEventCallback;
class GdbEngine;
class CdbDebugEngine;
struct CdbDebugEnginePrivate;
} // namespace Internal
con's avatar
con committed
98

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

    QString executable;
    QString coreFile;
    QStringList processArgs;
    QStringList environment;
    QString workingDir;
    QString buildDir;
    qint64 attachPID;
    bool useTerminal;
113
    QString crashParameter; // for AttachCrashedExternal
114
115
116
    // for remote debugging
    QString remoteChannel;
    QString remoteArchitecture;
117
    QString symbolFileName;
118
    QString serverStartScript;
119
    int toolChainType;
hjk's avatar
hjk committed
120
121
122

    QString dumperLibrary;
    QStringList dumperLibraryLocations;
hjk's avatar
hjk committed
123
    DebuggerStartMode startMode;
124
125
};

hjk's avatar
hjk committed
126
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
127
128

DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
129
130

// Flags for initialization
hjk's avatar
hjk committed
131
132
133
134
135
136
137
138
enum DebuggerEngineTypeFlags
{
    GdbEngineType     = 0x01,
    ScriptEngineType  = 0x02,
    CdbEngineType     = 0x04,
    AllEngineTypes = GdbEngineType
        | ScriptEngineType 
        | CdbEngineType 
139
140
};

hjk's avatar
hjk committed
141
QDebug operator<<(QDebug d, DebuggerState state);
con's avatar
con committed
142
143

//
hjk's avatar
hjk committed
144
// DebuggerManager
con's avatar
con committed
145
146
//

147
148
struct DebuggerManagerPrivate;

149
class DEBUGGER_EXPORT DebuggerManager : public QObject
con's avatar
con committed
150
{
hjk's avatar
hjk committed
151
    Q_OBJECT
con's avatar
con committed
152

hjk's avatar
hjk committed
153
154
155
public:
    DebuggerManager();
    ~DebuggerManager();
156

157
158
159
160
    friend class Internal::IDebuggerEngine;
    friend class Internal::DebuggerPlugin;
    friend class Internal::CdbDebugEventCallback;
    friend class Internal::CdbDumperHelper;
161
    friend class Internal::CdbDumperInitThread;
162
163
164
165
166
    friend class Internal::CdbExceptionLoggerEventCallback;
    friend class Internal::GdbEngine;
    friend class Internal::ScriptEngine;
    friend class Internal::CdbDebugEngine;
    friend struct Internal::CdbDebugEnginePrivate;
con's avatar
con committed
167

168
    DebuggerState state() const;
169
    QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
170

171
    Utils::FancyMainWindow *mainWindow() const;
172
    QLabel *statusLabel() const;
173
    Internal::IDebuggerEngine *currentEngine() const;
con's avatar
con committed
174

175
176
    DebuggerStartParametersPtr startParameters() const;
    qint64 inferiorPid() const;
hjk's avatar
hjk committed
177

178
179
    void showMessageBox(int icon, const QString &title, const QString &text);

180
181
    bool debuggerActionsEnabled() const;

182
183
184
185
186
    bool checkDebugConfiguration(int toolChain,
                                 QString *errorMessage,
                                 QString *settingsCategory = 0,
                                 QString *settingsPage = 0) const;

187
188
    const CPlusPlus::Snapshot &cppCodeModelSnapshot() const;

189
190
    static DebuggerManager *instance();

con's avatar
con committed
191
public slots:
hjk's avatar
hjk committed
192
    void startNewDebugger(const DebuggerStartParametersPtr &sp);
193
194
    void exitDebugger();

con's avatar
con committed
195
196
197
198
199
    void setSimpleDockWidgetArrangement();

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

200
    void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
201
    void fileOpen(const QString &file);
con's avatar
con committed
202
203
204
205
206
207
208
209
210
    void resetLocation();

    void interruptDebuggingRequest();

    void jumpToLineExec();
    void runToLineExec();
    void runToFunctionExec();
    void toggleBreakpoint();
    void breakByFunction(const QString &functionName);
211
    void breakByFunctionMain();
con's avatar
con committed
212
213
214
215
216
217
218
219
    void setBreakpoint(const QString &fileName, int lineNumber);
    void activateFrame(int index);
    void selectThread(int index);

    void stepExec();
    void stepOutExec();
    void nextExec();
    void continueExec();
220
    void detachDebugger();
con's avatar
con committed
221
222

    void addToWatchWindow();
223
    void updateWatchData(const Debugger::Internal::WatchData &data);
224

con's avatar
con committed
225
    void sessionLoaded();
226
    void aboutToUnloadSession();
con's avatar
con committed
227
    void aboutToSaveSession();
228
229
    QVariant sessionValue(const QString &name);
    void setSessionValue(const QString &name, const QVariant &value);
con's avatar
con committed
230

231
    void assignValueInDebugger();
con's avatar
con committed
232
    void assignValueInDebugger(const QString &expr, const QString &value);
233
234

    void executeDebuggerCommand();
con's avatar
con committed
235
236
    void executeDebuggerCommand(const QString &command);

237
    void watchPoint();
238
    void setRegisterValue(int nr, const QString &value);
239

240
    void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
241
    void clearCppCodeModelSnapshot();
con's avatar
con committed
242

243
public slots: // FIXME
hjk's avatar
hjk committed
244
245
    void showDebuggerOutput(const QString &msg)
        { showDebuggerOutput(LogDebug, msg); }
Friedemann Kleint's avatar
Friedemann Kleint committed
246
247
   void ensureLogVisible();

hjk's avatar
hjk committed
248
//private slots:  // FIXME
249
250
    void showDebuggerOutput(int channel, const QString &msg);
    void showDebuggerInput(int channel, const QString &msg);
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
251
    void showApplicationOutput(const QString &data);
con's avatar
con committed
252

253
254
255
    void reloadSourceFiles();
    void sourceFilesDockToggled(bool on);

con's avatar
con committed
256
257
258
259
260
261
262
    void reloadModules();
    void modulesDockToggled(bool on);
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();

    void reloadRegisters();
    void registerDockToggled(bool on);
263
    void clearStatusMessage();
264
    void attemptBreakpointSynchronization();
265
    void reloadFullStack();
266
    void operateByInstructionTriggered();
hjk's avatar
hjk committed
267
    void startFailed();
con's avatar
con committed
268
269

private:
270
271
272
273
274
275
276
    Internal::ModulesHandler *modulesHandler() const;
    Internal::BreakHandler *breakHandler() const;
    Internal::RegisterHandler *registerHandler() const;
    Internal::StackHandler *stackHandler() const;
    Internal::ThreadsHandler *threadsHandler() const;
    Internal::WatchHandler *watchHandler() const;
    Internal::SourceFilesWindow *sourceFileWindow() const;
277
278
    QWidget *threadsWindow() const;        

279
    Internal::DebuggerManagerActions debuggerManagerActions() const;
280

con's avatar
con committed
281
282
283
    void notifyInferiorStopped();
    void notifyInferiorRunning();
    void notifyInferiorExited();
284
    void notifyInferiorPidChanged(qint64);
con's avatar
con committed
285

286
    void cleanupViews();
con's avatar
con committed
287

hjk's avatar
hjk committed
288
289
    void setState(DebuggerState state);

290
    //
con's avatar
con committed
291
    // internal implementation
292
    //
293
294
295
296
297
298
299
    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
300
301
302
303
304
    Q_SLOT void loadSessionData();
    Q_SLOT void saveSessionData();
    Q_SLOT void dumpLog();

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

con's avatar
con committed
309
310
311
signals:
    void debuggingFinished();
    void inferiorPidChanged(qint64 pid);
hjk's avatar
hjk committed
312
    void stateChanged(int newstatus);
con's avatar
con committed
313
314
315
    void debugModeRequested();
    void previousModeRequested();
    void statusMessageRequested(const QString &msg, int timeout); // -1 for 'forever'
316
    void gotoLocationRequested(const QString &file, int line, bool setLocationMarker);
con's avatar
con committed
317
318
319
320
321
322
    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
323
    void applicationOutputAvailable(const QString &output);
324
325
    void emitShowOutput(int channel, const QString &output);
    void emitShowInput(int channel, const QString &input);
con's avatar
con committed
326
327

private:
328
    void init();
hjk's avatar
hjk committed
329
    void runTest(const QString &fileName);
hjk's avatar
hjk committed
330
    Q_SLOT void createNewDock(QWidget *widget);
con's avatar
con committed
331
332
333
334

    void shutdown();

    void toggleBreakpoint(const QString &fileName, int lineNumber);
335
    void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
336
    Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
hjk's avatar
hjk committed
337
338
    void setToolTipExpression(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
con's avatar
con committed
339

340
    DebuggerManagerPrivate *d;
con's avatar
con committed
341
342
343
344
345
};

} // namespace Debugger

#endif // DEBUGGER_DEBUGGERMANAGER_H