scriptengine.h 4.05 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 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
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

con's avatar
con committed
33 34 35
#ifndef DEBUGGER_SCRIPTENGINE_H
#define DEBUGGER_SCRIPTENGINE_H

36
#include "debuggerengine.h"
37

Friedemann Kleint's avatar
Friedemann Kleint committed
38 39
#include <QtCore/QSharedPointer>
#include <QtCore/QScopedPointer>
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
40
#include <QtCore/QHash>
con's avatar
con committed
41 42 43 44 45 46 47 48 49 50 51 52

QT_BEGIN_NAMESPACE
class QScriptEngine;
class QScriptValue;
QT_END_NAMESPACE

namespace Debugger {
namespace Internal {

class ScriptAgent;
class WatchData;

53 54 55 56 57 58
/* A debugger engine for a QScriptEngine implemented using a QScriptEngineAgent.
 * listening on script events. The engine has a special execution model:
 * The script is executed in the foreground, while the debugger runs in
 * processEvents() triggered by QScriptEngine::setProcessEventsInterval().
 * Stopping is emulated by manually calling processEvents() from the debugger engine. */

59
class ScriptEngine : public Debugger::DebuggerEngine
con's avatar
con committed
60 61 62 63
{
    Q_OBJECT

public:
64 65
    explicit ScriptEngine(const DebuggerStartParameters &startParameters);
    virtual ~ScriptEngine();
con's avatar
con committed
66 67

private:
68
    // DebuggerEngine implementation
hjk's avatar
hjk committed
69 70 71 72 73
    void executeStep();
    void executeStepOut();
    void executeNext();
    void executeStepI();
    void executeNextI();
con's avatar
con committed
74

75
    bool setToolTipExpression(const QPoint &mousePos,
76
        TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
hjk's avatar
hjk committed
77 78 79
    void setupEngine();
    void setupInferior();
    void runEngine();
hjk's avatar
hjk committed
80 81
    void shutdownInferior();
    void shutdownEngine();
con's avatar
con committed
82 83 84 85

    void continueInferior();
    void interruptInferior();

86
    void executeRunToLine(const ContextData &data);
hjk's avatar
hjk committed
87
    void executeRunToFunction(const QString &functionName);
88
    void executeJumpToLine(const ContextData &data);
con's avatar
con committed
89 90 91 92

    void activateFrame(int index);
    void selectThread(int index);

93
    bool acceptsBreakpoint(BreakpointModelId id) const;
con's avatar
con committed
94 95
    void attemptBreakpointSynchronization();

hjk's avatar
hjk committed
96 97
    void assignValueInDebugger(const WatchData *w,
        const QString &expr, const QVariant &value);
98
    void executeDebuggerCommand(const QString &command);
con's avatar
con committed
99 100 101

    void loadSymbols(const QString &moduleName);
    void loadAllSymbols();
hjk's avatar
hjk committed
102
    void requestModuleSymbols(const QString &moduleName);
con's avatar
con committed
103 104
    void reloadModules();
    void reloadRegisters() {}
105
    void reloadSourceFiles() {}
106
    void reloadFullStack() {}
con's avatar
con committed
107

Friedemann Kleint's avatar
Friedemann Kleint committed
108
    bool checkForBreakCondition(bool byFunction);
109
    void updateWatchData(const WatchData &data, const WatchUpdateFlags &flags);
110
    void updateLocals();
hjk's avatar
hjk committed
111
    void updateSubItem(const WatchData &data);
112
    bool hasCapability(unsigned) const { return false; }
con's avatar
con committed
113 114 115 116

private:
    friend class ScriptAgent;

hjk's avatar
hjk committed
117
    void importExtensions();
Friedemann Kleint's avatar
Friedemann Kleint committed
118 119

    QSharedPointer<QScriptEngine> m_scriptEngine;
con's avatar
con committed
120 121
    QString m_scriptContents;
    QString m_scriptFileName;
Friedemann Kleint's avatar
Friedemann Kleint committed
122
    QScopedPointer<ScriptAgent> m_scriptAgent;
Arvid Ephraim Picciani's avatar
Arvid Ephraim Picciani committed
123 124
    QHash<quint64,QScriptValue> m_watchIdToScriptValue;
    quint64 m_watchIdCounter;
con's avatar
con committed
125 126 127 128 129 130 131 132 133

    bool m_stopped;
    bool m_stopOnNextLine;
};

} // namespace Internal
} // namespace Debugger

#endif // DEBUGGER_SCRIPTENGINE_H