debuggermanager.h 9.93 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
}

con's avatar
con committed
62
63
64
65
66
67
68
namespace Debugger {
namespace Internal {

class DebuggerOutputWindow;
class DebuggerPlugin;

class BreakHandler;
69
class BreakpointData;
con's avatar
con committed
70
71
class ModulesHandler;
class RegisterHandler;
72
class SourceFilesWindow;
73
struct StackFrame;
con's avatar
con committed
74
class StackHandler;
75
class Symbol;
con's avatar
con committed
76
77
class ThreadsHandler;
class WatchData;
78
class WatchHandler;
79
80
81
82
83
84
class IDebuggerEngine;
class GdbEngine;
class ScriptEngine;
class CdbDebugEngine;
struct CdbDebugEnginePrivate;
struct DebuggerManagerActions;
85
86
87
class DebuggerPlugin;
class CdbDebugEventCallback;
class CdbDumperHelper;
88
class CdbDumperInitThread;
89
90
91
92
93
class CdbExceptionLoggerEventCallback;
class GdbEngine;
class CdbDebugEngine;
struct CdbDebugEnginePrivate;
} // namespace Internal
con's avatar
con committed
94

95
class DEBUGGER_EXPORT DebuggerStartParameters
96
{
97
public:
98
99
100
101
102
103
104
105
106
107
108
    DebuggerStartParameters();
    void clear();

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

    QString dumperLibrary;
    QStringList dumperLibraryLocations;
hjk's avatar
hjk committed
120
    DebuggerStartMode startMode;
121
122
};

hjk's avatar
hjk committed
123
typedef QSharedPointer<DebuggerStartParameters> DebuggerStartParametersPtr;
124
125

DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);
126
127

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

hjk's avatar
hjk committed
138
QDebug operator<<(QDebug d, DebuggerState state);
con's avatar
con committed
139
140

//
hjk's avatar
hjk committed
141
// DebuggerManager
con's avatar
con committed
142
143
//

144
145
struct DebuggerManagerPrivate;

146
class DEBUGGER_EXPORT DebuggerManager : public QObject
con's avatar
con committed
147
{
hjk's avatar
hjk committed
148
    Q_OBJECT
con's avatar
con committed
149

hjk's avatar
hjk committed
150
151
152
public:
    DebuggerManager();
    ~DebuggerManager();
153

154
155
156
157
    friend class Internal::IDebuggerEngine;
    friend class Internal::DebuggerPlugin;
    friend class Internal::CdbDebugEventCallback;
    friend class Internal::CdbDumperHelper;
158
    friend class Internal::CdbDumperInitThread;
159
160
161
162
163
    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
164

165
    DebuggerState state() const;
166
    QList<Core::IOptionsPage*> initializeEngines(unsigned enabledTypeFlags);
167

168
    Utils::FancyMainWindow *mainWindow() const;
169
    QLabel *statusLabel() const;
170
    Internal::IDebuggerEngine *currentEngine() const;
con's avatar
con committed
171

172
173
    DebuggerStartParametersPtr startParameters() const;
    qint64 inferiorPid() const;
hjk's avatar
hjk committed
174

175
176
    void showMessageBox(int icon, const QString &title, const QString &text);

177
178
    bool debuggerActionsEnabled() const;

179
180
181
182
183
    bool checkDebugConfiguration(int toolChain,
                                 QString *errorMessage,
                                 QString *settingsCategory = 0,
                                 QString *settingsPage = 0) const;

184
185
    static DebuggerManager *instance();

con's avatar
con committed
186
public slots:
hjk's avatar
hjk committed
187
    void startNewDebugger(const DebuggerStartParametersPtr &sp);
188
189
    void exitDebugger();

con's avatar
con committed
190
191
192
193
194
    void setSimpleDockWidgetArrangement();

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

195
    void gotoLocation(const Debugger::Internal::StackFrame &frame, bool setLocationMarker);
196
    void fileOpen(const QString &file);
con's avatar
con committed
197
198
199
200
201
202
203
204
205
    void resetLocation();

    void interruptDebuggingRequest();

    void jumpToLineExec();
    void runToLineExec();
    void runToFunctionExec();
    void toggleBreakpoint();
    void breakByFunction(const QString &functionName);
206
    void breakByFunctionMain();
con's avatar
con committed
207
208
209
210
211
212
213
214
    void setBreakpoint(const QString &fileName, int lineNumber);
    void activateFrame(int index);
    void selectThread(int index);

    void stepExec();
    void stepOutExec();
    void nextExec();
    void continueExec();
215
    void detachDebugger();
con's avatar
con committed
216
217

    void addToWatchWindow();
218
    void updateWatchData(const Debugger::Internal::WatchData &data);
219

con's avatar
con committed
220
    void sessionLoaded();
221
    void aboutToUnloadSession();
con's avatar
con committed
222
    void aboutToSaveSession();
223
224
    QVariant sessionValue(const QString &name);
    void setSessionValue(const QString &name, const QVariant &value);
con's avatar
con committed
225

226
    void assignValueInDebugger();
con's avatar
con committed
227
    void assignValueInDebugger(const QString &expr, const QString &value);
228
229

    void executeDebuggerCommand();
con's avatar
con committed
230
231
    void executeDebuggerCommand(const QString &command);

232
    void watchPoint();
233
    void setRegisterValue(int nr, const QString &value);
234

235
    void showStatusMessage(const QString &msg, int timeout = -1); // -1 forever
con's avatar
con committed
236

237
public slots: // FIXME
hjk's avatar
hjk committed
238
239
    void showDebuggerOutput(const QString &msg)
        { showDebuggerOutput(LogDebug, msg); }
Friedemann Kleint's avatar
Friedemann Kleint committed
240
241
   void ensureLogVisible();

hjk's avatar
hjk committed
242
//private slots:  // FIXME
243
244
    void showDebuggerOutput(int channel, const QString &msg);
    void showDebuggerInput(int channel, const QString &msg);
Oswald Buddenhagen's avatar
Oswald Buddenhagen committed
245
    void showApplicationOutput(const QString &data);
con's avatar
con committed
246

247
248
249
    void reloadSourceFiles();
    void sourceFilesDockToggled(bool on);

con's avatar
con committed
250
251
252
253
254
255
256
    void reloadModules();
    void modulesDockToggled(bool on);
    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();

    void reloadRegisters();
    void registerDockToggled(bool on);
257
    void clearStatusMessage();
258
    void attemptBreakpointSynchronization();
259
    void reloadFullStack();
260
    void operateByInstructionTriggered();
hjk's avatar
hjk committed
261
    void startFailed();
con's avatar
con committed
262
263

private:
264
265
266
267
268
269
270
    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;
271
    QWidget *threadsWindow() const;    
272
    Internal::DebuggerManagerActions debuggerManagerActions() const;
273

con's avatar
con committed
274
275
276
    void notifyInferiorStopped();
    void notifyInferiorRunning();
    void notifyInferiorExited();
277
    void notifyInferiorPidChanged(qint64);
con's avatar
con committed
278

279
    void cleanupViews();
con's avatar
con committed
280

hjk's avatar
hjk committed
281
282
    void setState(DebuggerState state);

283
    //
con's avatar
con committed
284
    // internal implementation
285
    //
286
287
288
289
290
291
292
    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
293
294
295
296
297
    Q_SLOT void loadSessionData();
    Q_SLOT void saveSessionData();
    Q_SLOT void dumpLog();

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

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

private:
321
    void init();
hjk's avatar
hjk committed
322
    void runTest(const QString &fileName);
hjk's avatar
hjk committed
323
    Q_SLOT void createNewDock(QWidget *widget);
con's avatar
con committed
324
325
326
327

    void shutdown();

    void toggleBreakpoint(const QString &fileName, int lineNumber);
328
    void toggleBreakpointEnabled(const QString &fileName, int lineNumber);
329
    Internal::BreakpointData *findBreakpoint(const QString &fileName, int lineNumber);
hjk's avatar
hjk committed
330
331
    void setToolTipExpression(const QPoint &mousePos,
        TextEditor::ITextEditor *editor, int cursorPos);
con's avatar
con committed
332

333
    DebuggerManagerPrivate *d;
con's avatar
con committed
334
335
336
337
338
};

} // namespace Debugger

#endif // DEBUGGER_DEBUGGERMANAGER_H