debuggerrunner.h 4.7 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 DEBUGGERRUNNER_H
#define DEBUGGERRUNNER_H

33
#include "debugger_global.h"
hjk's avatar
hjk committed
34 35
#include "debuggerconstants.h"

con's avatar
con committed
36
#include <projectexplorer/runconfiguration.h>
37

38 39
#include <QtCore/QScopedPointer>

40
namespace Utils {
41
class Environment;
42
}
con's avatar
con committed
43 44

namespace Debugger {
45
class DebuggerEngine;
46
class DebuggerRunControl;
47
class QmlEngine;
48
class DebuggerStartParameters;
49
struct DebuggerRunnerPrivate;
hjk's avatar
hjk committed
50

51
namespace Internal {
52 53
class GdbEngine;
class AbstractGdbAdapter;
54 55
}

hjk's avatar
hjk committed
56 57
//DEBUGGER_EXPORT QDebug operator<<(QDebug str, const DebuggerStartParameters &);

58
class DEBUGGER_EXPORT DebuggerRunControlFactory
59
    : public ProjectExplorer::IRunControlFactory
con's avatar
con committed
60 61 62 63
{
    Q_OBJECT

public:
64
    DebuggerRunControlFactory(QObject *parent, unsigned enabledEngines);
con's avatar
con committed
65

66
    // This is used by the "Non-Standard" scenarios, e.g. Attach to Core.
67
    // FIXME: What to do in case of a 0 runConfiguration?
68 69
    typedef ProjectExplorer::RunConfiguration RunConfiguration;
    typedef ProjectExplorer::RunControl RunControl;
70
    DebuggerRunControl *create(const DebuggerStartParameters &sp,
71
        RunConfiguration *runConfiguration = 0);
72

73 74 75 76
    // ProjectExplorer::IRunControlFactory
    // FIXME: Used by qmljsinspector.cpp:469
    RunControl *create(RunConfiguration *runConfiguration, const QString &mode);
    bool canRun(RunConfiguration *runConfiguration, const QString &mode) const;
con's avatar
con committed
77
private:
78 79 80
    QString displayName() const;
    QWidget *createConfigurationWidget(RunConfiguration *runConfiguration);

81
    unsigned m_enabledEngines;
con's avatar
con committed
82 83
};

84

85 86
// This is a job description containing all data "local" to the jobs, including
// the models of the individual debugger views.
87
class DEBUGGER_EXPORT DebuggerRunControl
hjk's avatar
hjk committed
88
    : public ProjectExplorer::RunControl
con's avatar
con committed
89 90 91 92
{
    Q_OBJECT

public:
93
    typedef ProjectExplorer::RunConfiguration RunConfiguration;
94
    explicit DebuggerRunControl(RunConfiguration *runConfiguration,
95
        unsigned enabledEngines, const DebuggerStartParameters &sp);
96
    ~DebuggerRunControl();
97

98
    // ProjectExplorer::RunControl
con's avatar
con committed
99
    virtual void start();
100 101
    virtual bool aboutToStop() const;
    virtual StopResult stop();
con's avatar
con committed
102
    virtual bool isRunning() const;
103
    QString displayName() const;
con's avatar
con committed
104

105
    void createEngine(const DebuggerStartParameters &startParameters);
106

107
    void setCustomEnvironment(Utils::Environment env);
108

109 110
    void startFailed();
    void debuggingFinished();
111
    RunConfiguration *runConfiguration() const;
112

Friedemann Kleint's avatar
Friedemann Kleint committed
113
    DebuggerState state() const;
114
    DebuggerEngine *engine();
115

116
    void showMessage(const QString &msg, int channel);
hjk's avatar
hjk committed
117

118 119
    void handleRemoteSetupDone();
    void handleRemoteSetupFailed(const QString &message);
120

121 122 123 124
    static bool checkDebugConfiguration(int toolChain,
                                 QString *errorMessage,
                                 QString *settingsCategory = 0,
                                 QString *settingsPage = 0);
125

126
signals:
127
    void engineRequestSetup();
128

129 130 131 132
public slots:
    void emitAddToOutputWindow(const QString &line, bool onStdErr);
    void emitAppendMessage(const QString &, bool isError);

con's avatar
con committed
133
private slots:
134
    void handleFinished();
con's avatar
con committed
135

136 137 138
protected:
    const DebuggerStartParameters &startParameters() const;

con's avatar
con committed
139
private:
140 141
    DebuggerEngineType engineForExecutable(unsigned enabledEngineTypes, const QString &executable);
    DebuggerEngineType engineForMode(unsigned enabledEngineTypes, DebuggerStartMode mode);
142 143 144
    void initGdbEngine(Internal::GdbEngine *engine);
    Internal::GdbEngine *gdbEngine() const;
    Internal::AbstractGdbAdapter *gdbAdapter() const;
145

146
    QScopedPointer<DebuggerRunnerPrivate> d;
con's avatar
con committed
147 148 149 150 151
};

} // namespace Debugger

#endif // DEBUGGERRUNNER_H