forked from qt-creator/qt-creator
Remove script manager and script debugger engine.
Doesn't really serve a purpose any more. Change-Id: I8c3bc11bf7b05a15eafd2a22456a40b270cefadf Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
@@ -15,8 +15,7 @@ win32-msvc*:QMAKE_CXXFLAGS += -wd4251 -wd4290 -wd4250
|
|||||||
INCLUDEPATH += dialogs \
|
INCLUDEPATH += dialogs \
|
||||||
actionmanager \
|
actionmanager \
|
||||||
editormanager \
|
editormanager \
|
||||||
progressmanager \
|
progressmanager
|
||||||
scriptmanager
|
|
||||||
SOURCES += mainwindow.cpp \
|
SOURCES += mainwindow.cpp \
|
||||||
editmode.cpp \
|
editmode.cpp \
|
||||||
tabpositionindicator.cpp \
|
tabpositionindicator.cpp \
|
||||||
@@ -55,7 +54,6 @@ SOURCES += mainwindow.cpp \
|
|||||||
progressmanager/progressview.cpp \
|
progressmanager/progressview.cpp \
|
||||||
progressmanager/progressbar.cpp \
|
progressmanager/progressbar.cpp \
|
||||||
progressmanager/futureprogress.cpp \
|
progressmanager/futureprogress.cpp \
|
||||||
scriptmanager/scriptmanager.cpp \
|
|
||||||
statusbarwidget.cpp \
|
statusbarwidget.cpp \
|
||||||
coreplugin.cpp \
|
coreplugin.cpp \
|
||||||
variablemanager.cpp \
|
variablemanager.cpp \
|
||||||
@@ -155,9 +153,6 @@ HEADERS += mainwindow.h \
|
|||||||
ifilewizardextension.h \
|
ifilewizardextension.h \
|
||||||
icorelistener.h \
|
icorelistener.h \
|
||||||
versiondialog.h \
|
versiondialog.h \
|
||||||
scriptmanager/metatypedeclarations.h \
|
|
||||||
scriptmanager/scriptmanager.h \
|
|
||||||
scriptmanager/scriptmanager_p.h \
|
|
||||||
core_global.h \
|
core_global.h \
|
||||||
statusbarwidget.h \
|
statusbarwidget.h \
|
||||||
coreplugin.h \
|
coreplugin.h \
|
||||||
|
@@ -20,7 +20,6 @@ QtcPlugin {
|
|||||||
"dialogs",
|
"dialogs",
|
||||||
"editormanager",
|
"editormanager",
|
||||||
"progressmanager",
|
"progressmanager",
|
||||||
"scriptmanager",
|
|
||||||
"actionmanager"
|
"actionmanager"
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -225,10 +224,6 @@ QtcPlugin {
|
|||||||
"progressmanager/progressmanager_p.h",
|
"progressmanager/progressmanager_p.h",
|
||||||
"progressmanager/progressview.cpp",
|
"progressmanager/progressview.cpp",
|
||||||
"progressmanager/progressview.h",
|
"progressmanager/progressview.h",
|
||||||
"scriptmanager/metatypedeclarations.h",
|
|
||||||
"scriptmanager/scriptmanager.cpp",
|
|
||||||
"scriptmanager/scriptmanager.h",
|
|
||||||
"scriptmanager/scriptmanager_p.h",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
|
@@ -432,11 +432,6 @@ ProgressManager *ICore::progressManager()
|
|||||||
return m_mainwindow->progressManager();
|
return m_mainwindow->progressManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptManager *ICore::scriptManager()
|
|
||||||
{
|
|
||||||
return m_mainwindow->scriptManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
VariableManager *ICore::variableManager()
|
VariableManager *ICore::variableManager()
|
||||||
{
|
{
|
||||||
return m_mainwindow->variableManager();
|
return m_mainwindow->variableManager();
|
||||||
|
@@ -98,7 +98,6 @@ public:
|
|||||||
static QT_DEPRECATED MessageManager *messageManager(); // Use MessageManager::... directly.
|
static QT_DEPRECATED MessageManager *messageManager(); // Use MessageManager::... directly.
|
||||||
static EditorManager *editorManager();
|
static EditorManager *editorManager();
|
||||||
static ProgressManager *progressManager();
|
static ProgressManager *progressManager();
|
||||||
static ScriptManager *scriptManager();
|
|
||||||
static QT_DEPRECATED VariableManager *variableManager(); // Use VariableManager::... directly.
|
static QT_DEPRECATED VariableManager *variableManager(); // Use VariableManager::... directly.
|
||||||
static VcsManager *vcsManager();
|
static VcsManager *vcsManager();
|
||||||
static QT_DEPRECATED ModeManager *modeManager(); // Use ModeManager::... directly.
|
static QT_DEPRECATED ModeManager *modeManager(); // Use ModeManager::... directly.
|
||||||
|
@@ -53,7 +53,6 @@
|
|||||||
#include "progressview.h"
|
#include "progressview.h"
|
||||||
#include "shortcutsettings.h"
|
#include "shortcutsettings.h"
|
||||||
#include "vcsmanager.h"
|
#include "vcsmanager.h"
|
||||||
#include "scriptmanager_p.h"
|
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
#include "variablemanager.h"
|
#include "variablemanager.h"
|
||||||
#include "versiondialog.h"
|
#include "versiondialog.h"
|
||||||
@@ -130,7 +129,6 @@ MainWindow::MainWindow() :
|
|||||||
m_editorManager(0),
|
m_editorManager(0),
|
||||||
m_externalToolManager(0),
|
m_externalToolManager(0),
|
||||||
m_progressManager(new ProgressManagerPrivate()),
|
m_progressManager(new ProgressManagerPrivate()),
|
||||||
m_scriptManager(new ScriptManagerPrivate(this)),
|
|
||||||
m_variableManager(new VariableManager),
|
m_variableManager(new VariableManager),
|
||||||
m_vcsManager(new VcsManager),
|
m_vcsManager(new VcsManager),
|
||||||
m_statusBarManager(0),
|
m_statusBarManager(0),
|
||||||
@@ -999,11 +997,6 @@ ProgressManager *MainWindow::progressManager() const
|
|||||||
return m_progressManager;
|
return m_progressManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptManager *MainWindow::scriptManager() const
|
|
||||||
{
|
|
||||||
return m_scriptManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
VariableManager *MainWindow::variableManager() const
|
VariableManager *MainWindow::variableManager() const
|
||||||
{
|
{
|
||||||
return m_variableManager;
|
return m_variableManager;
|
||||||
|
@@ -61,7 +61,6 @@ class ModeManager;
|
|||||||
class ProgressManager;
|
class ProgressManager;
|
||||||
class NavigationWidget;
|
class NavigationWidget;
|
||||||
class RightPaneWidget;
|
class RightPaneWidget;
|
||||||
class ScriptManager;
|
|
||||||
class SettingsDatabase;
|
class SettingsDatabase;
|
||||||
class VariableManager;
|
class VariableManager;
|
||||||
class VcsManager;
|
class VcsManager;
|
||||||
@@ -101,7 +100,6 @@ public:
|
|||||||
Core::MessageManager *messageManager() const;
|
Core::MessageManager *messageManager() const;
|
||||||
Core::EditorManager *editorManager() const;
|
Core::EditorManager *editorManager() const;
|
||||||
Core::ProgressManager *progressManager() const;
|
Core::ProgressManager *progressManager() const;
|
||||||
Core::ScriptManager *scriptManager() const;
|
|
||||||
Core::VariableManager *variableManager() const;
|
Core::VariableManager *variableManager() const;
|
||||||
Core::ModeManager *modeManager() const;
|
Core::ModeManager *modeManager() const;
|
||||||
Core::MimeDatabase *mimeDatabase() const;
|
Core::MimeDatabase *mimeDatabase() const;
|
||||||
@@ -183,7 +181,6 @@ private:
|
|||||||
ExternalToolManager *m_externalToolManager;
|
ExternalToolManager *m_externalToolManager;
|
||||||
MessageManager *m_messageManager;
|
MessageManager *m_messageManager;
|
||||||
ProgressManagerPrivate *m_progressManager;
|
ProgressManagerPrivate *m_progressManager;
|
||||||
ScriptManager *m_scriptManager;
|
|
||||||
VariableManager *m_variableManager;
|
VariableManager *m_variableManager;
|
||||||
VcsManager *m_vcsManager;
|
VcsManager *m_vcsManager;
|
||||||
StatusBarManager *m_statusBarManager;
|
StatusBarManager *m_statusBarManager;
|
||||||
|
@@ -1,61 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef METATYPEDECLARATIONS_H
|
|
||||||
#define METATYPEDECLARATIONS_H
|
|
||||||
|
|
||||||
#include <coreplugin/messagemanager.h>
|
|
||||||
#include <coreplugin/documentmanager.h>
|
|
||||||
#include <coreplugin/idocument.h>
|
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
#include <QList>
|
|
||||||
#include <QMetaType>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QMainWindow;
|
|
||||||
class QStatusBar;
|
|
||||||
class QSettings;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(Core::MessageManager*)
|
|
||||||
Q_DECLARE_METATYPE(Core::DocumentManager*)
|
|
||||||
Q_DECLARE_METATYPE(Core::IDocument*)
|
|
||||||
Q_DECLARE_METATYPE(QList<Core::IDocument*>)
|
|
||||||
Q_DECLARE_METATYPE(QList<Core::IEditor*>)
|
|
||||||
Q_DECLARE_METATYPE(Core::EditorManager*)
|
|
||||||
Q_DECLARE_METATYPE(Core::ICore*)
|
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(QMainWindow*)
|
|
||||||
Q_DECLARE_METATYPE(QStatusBar*)
|
|
||||||
Q_DECLARE_METATYPE(QSettings*)
|
|
||||||
|
|
||||||
#endif // METATYPEDECLARATIONS_H
|
|
@@ -1,280 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "scriptmanager_p.h"
|
|
||||||
#include "metatypedeclarations.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
#include <interface_wrap_helpers.h>
|
|
||||||
#include <wrap_helpers.h>
|
|
||||||
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QSettings>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QInputDialog>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QMainWindow>
|
|
||||||
#include <QStatusBar>
|
|
||||||
|
|
||||||
// Script function template to pop up a message box
|
|
||||||
// with a certain icon and buttons.
|
|
||||||
template <int MsgBoxIcon, int MsgBoxButtons>
|
|
||||||
static QScriptValue messageBox(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
if (context->argumentCount() < 3)
|
|
||||||
return QScriptValue(engine, -1);
|
|
||||||
|
|
||||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
|
||||||
const QString title = context->argument(1).toString();
|
|
||||||
const QString msg = context->argument(2).toString();
|
|
||||||
|
|
||||||
QMessageBox msgBox(static_cast<QMessageBox::Icon>(MsgBoxIcon), title, msg,
|
|
||||||
static_cast<QMessageBox::StandardButtons>(MsgBoxButtons), parent);
|
|
||||||
|
|
||||||
return QScriptValue(engine, msgBox.exec());
|
|
||||||
}
|
|
||||||
|
|
||||||
static QScriptValue inputDialogGetText(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
const int argumentCount = context->argumentCount();
|
|
||||||
if (argumentCount < 3)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
|
|
||||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
|
||||||
const QString title = context->argument(1).toString();
|
|
||||||
const QString label = context->argument(2).toString();
|
|
||||||
const QString defaultValue = argumentCount > 3 ? context->argument(3).toString() : QString();
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
const QString rc = QInputDialog::getText(parent, title, label, QLineEdit::Normal, defaultValue, &ok);
|
|
||||||
if (!ok)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
return QScriptValue(engine, rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QScriptValue inputDialogGetInteger(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
const int argumentCount = context->argumentCount();
|
|
||||||
if (argumentCount < 3)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
|
|
||||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
|
||||||
const QString title = context->argument(1).toString();
|
|
||||||
const QString label = context->argument(2).toString();
|
|
||||||
const int defaultValue = argumentCount > 3 ? context->argument(3).toInt32() : 0;
|
|
||||||
const int minValue = argumentCount > 4 ? context->argument(4).toInt32() : INT_MIN;
|
|
||||||
const int maxValue = argumentCount > 5 ? context->argument(5).toInt32() : INT_MAX;
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
const int rc = QInputDialog::getInt(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
|
|
||||||
if (!ok)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
return QScriptValue(engine, rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QScriptValue inputDialogGetDouble(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
const int argumentCount = context->argumentCount();
|
|
||||||
if (argumentCount < 3)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
|
|
||||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
|
||||||
const QString title = context->argument(1).toString();
|
|
||||||
const QString label = context->argument(2).toString();
|
|
||||||
const double defaultValue = argumentCount > 3 ? context->argument(3).toNumber() : 0;
|
|
||||||
// Use QInputDialog defaults
|
|
||||||
const double minValue = argumentCount > 4 ? context->argument(4).toNumber() : INT_MIN;
|
|
||||||
const double maxValue = argumentCount > 5 ? context->argument(5).toNumber() : INT_MAX;
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
const double rc = QInputDialog::getDouble(parent, title, label, defaultValue, minValue, maxValue, 1, &ok);
|
|
||||||
if (!ok)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
return QScriptValue(engine, rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
static QScriptValue inputDialogGetItem(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
const int argumentCount = context->argumentCount();
|
|
||||||
if (argumentCount < 4)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
|
|
||||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
|
||||||
const QString title = context->argument(1).toString();
|
|
||||||
const QString label = context->argument(2).toString();
|
|
||||||
const QStringList items = qscriptvalue_cast<QStringList>(context->argument(3));
|
|
||||||
const int defaultItem = argumentCount > 4 ? context->argument(4).toInt32() : 0;
|
|
||||||
const bool editable = argumentCount > 5 ? context->argument(5).toInt32() : 0;
|
|
||||||
|
|
||||||
bool ok;
|
|
||||||
const QString rc = QInputDialog::getItem (parent, title, label, items, defaultItem, editable, &ok);
|
|
||||||
if (!ok)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
|
|
||||||
return QScriptValue(engine, rc);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Script function template to pop up a file box
|
|
||||||
// with a certain icon and buttons.
|
|
||||||
template <int TAcceptMode, int TFileMode>
|
|
||||||
static QScriptValue fileBox(QScriptContext *context, QScriptEngine *engine)
|
|
||||||
{
|
|
||||||
const int argumentCount = context->argumentCount();
|
|
||||||
if (argumentCount < 2)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
|
|
||||||
QWidget *parent = qscriptvalue_cast<QWidget *>(context->argument(0));
|
|
||||||
const QString title = context->argument(1).toString();
|
|
||||||
const QString directory = argumentCount > 2 ? context->argument(2).toString() : QString();
|
|
||||||
const QString filter = argumentCount > 3 ? context->argument(3).toString() : QString();
|
|
||||||
QFileDialog fileDialog(parent, title, directory, filter);
|
|
||||||
fileDialog.setAcceptMode(static_cast<QFileDialog::AcceptMode>(TAcceptMode));
|
|
||||||
fileDialog.setFileMode (static_cast<QFileDialog::FileMode>(TFileMode));
|
|
||||||
if (fileDialog.exec() == QDialog::Rejected)
|
|
||||||
return QScriptValue(engine, QScriptValue::NullValue);
|
|
||||||
const QStringList rc = fileDialog.selectedFiles();
|
|
||||||
QTC_CHECK(!rc.empty());
|
|
||||||
return TFileMode == QFileDialog::ExistingFiles ?
|
|
||||||
engine->toScriptValue(rc) : engine->toScriptValue(rc.front());
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------ ScriptManagerPrivate
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
ScriptManagerPrivate::ScriptManagerPrivate(QObject *parent)
|
|
||||||
: ScriptManager(parent),
|
|
||||||
m_engine(0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Split a backtrace of the form:
|
|
||||||
// "<anonymous>(BuildManagerCommand(ls))@:0
|
|
||||||
// demoProjectExplorer()@:237
|
|
||||||
// <anonymous>()@:276
|
|
||||||
// <global>()@:0"
|
|
||||||
static void parseBackTrace(const QStringList &backTrace, ScriptManagerPrivate::Stack &stack)
|
|
||||||
{
|
|
||||||
const QChar at = QLatin1Char('@');
|
|
||||||
const QChar colon = QLatin1Char(':');
|
|
||||||
stack.clear();
|
|
||||||
foreach (const QString &line, backTrace) {
|
|
||||||
const int atPos = line.lastIndexOf(at);
|
|
||||||
if (atPos == -1)
|
|
||||||
continue;
|
|
||||||
const int colonPos = line.indexOf(colon, atPos + 1);
|
|
||||||
if (colonPos == -1)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
ScriptManagerPrivate::StackFrame frame;
|
|
||||||
frame.function = line.left(atPos);
|
|
||||||
frame.fileName = line.mid(atPos + 1, colonPos - atPos - 1);
|
|
||||||
frame.lineNumber = line.right(line.size() - colonPos - 1).toInt();
|
|
||||||
stack.push_back(frame);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScriptManagerPrivate::runScript(const QString &script, QString *errorMessage)
|
|
||||||
{
|
|
||||||
Stack stack;
|
|
||||||
return runScript(script, errorMessage, &stack);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScriptManagerPrivate::runScript(const QString &script, QString *errorMessage, Stack *stack)
|
|
||||||
{
|
|
||||||
ensureEngineInitialized();
|
|
||||||
stack->clear();
|
|
||||||
|
|
||||||
m_engine->pushContext();
|
|
||||||
m_engine->evaluate(script);
|
|
||||||
|
|
||||||
const bool failed = m_engine->hasUncaughtException ();
|
|
||||||
if (failed) {
|
|
||||||
const int errorLineNumber = m_engine->uncaughtExceptionLineNumber();
|
|
||||||
const QStringList backTrace = m_engine->uncaughtExceptionBacktrace();
|
|
||||||
parseBackTrace(backTrace, *stack);
|
|
||||||
const QString backtrace = backTrace.join(QString(QLatin1Char('\n')));
|
|
||||||
*errorMessage = ScriptManager::tr("Exception at line %1: %2\n%3").arg(errorLineNumber).arg(engineError(m_engine)).arg(backtrace);
|
|
||||||
}
|
|
||||||
m_engine->popContext();
|
|
||||||
return !failed;
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptManager::QScriptEnginePtr ScriptManagerPrivate::ensureEngineInitialized()
|
|
||||||
{
|
|
||||||
if (!m_engine.isNull())
|
|
||||||
return m_engine;
|
|
||||||
m_engine = QScriptEnginePtr(new QScriptEngine);
|
|
||||||
// register QObjects that occur as properties
|
|
||||||
SharedTools::registerQObject<QMainWindow>(m_engine.data());
|
|
||||||
SharedTools::registerQObject<QStatusBar>(m_engine.data());
|
|
||||||
SharedTools::registerQObject<QSettings>(m_engine.data());
|
|
||||||
|
|
||||||
qScriptRegisterSequenceMetaType<QList<Core::IEditor *> >(m_engine.data());
|
|
||||||
|
|
||||||
// CLASSIC: registerInterfaceWithDefaultPrototype<Core::MessageManager, MessageManagerPrototype>(m_engine);
|
|
||||||
|
|
||||||
// Message box conveniences
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("critical"),
|
|
||||||
m_engine->newFunction(messageBox<QMessageBox::Critical, QMessageBox::Ok>, 3));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("warning"),
|
|
||||||
m_engine->newFunction(messageBox<QMessageBox::Warning, QMessageBox::Ok>, 3));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("information"),
|
|
||||||
m_engine->newFunction(messageBox<QMessageBox::Information, QMessageBox::Ok>, 3));
|
|
||||||
// StandardButtons has overloaded operator '|' - grrr.
|
|
||||||
enum { MsgBoxYesNo = 0x00014000 };
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("yesNoQuestion"),
|
|
||||||
m_engine->newFunction(messageBox<QMessageBox::Question, MsgBoxYesNo>, 3));
|
|
||||||
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getText"), m_engine->newFunction(inputDialogGetText, 3));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getInteger"), m_engine->newFunction(inputDialogGetInteger, 3));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getDouble"), m_engine->newFunction(inputDialogGetDouble, 3));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getItem"), m_engine->newFunction(inputDialogGetItem, 3));
|
|
||||||
|
|
||||||
// file box
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getOpenFileNames"), m_engine->newFunction(fileBox<QFileDialog::AcceptOpen, QFileDialog::ExistingFiles> , 2));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getOpenFileName"), m_engine->newFunction(fileBox<QFileDialog::AcceptOpen, QFileDialog::ExistingFile> , 2));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getSaveFileName"), m_engine->newFunction(fileBox<QFileDialog::AcceptSave, QFileDialog::AnyFile> , 2));
|
|
||||||
m_engine->globalObject().setProperty(QLatin1String("getExistingDirectory"), m_engine->newFunction(fileBox<QFileDialog::AcceptSave, QFileDialog::DirectoryOnly> , 2));
|
|
||||||
return m_engine;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ScriptManagerPrivate::engineError(const QScriptEnginePtr &scriptEngine)
|
|
||||||
{
|
|
||||||
QScriptValue error = scriptEngine->evaluate(QLatin1String("Error"));
|
|
||||||
if (error.isValid())
|
|
||||||
return error.toString();
|
|
||||||
return ScriptManager::tr("Unknown error");
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
|
@@ -1,77 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef SCRIPTMANAGER_H
|
|
||||||
#define SCRIPTMANAGER_H
|
|
||||||
|
|
||||||
#include <coreplugin/core_global.h>
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QString>
|
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QScriptEngine;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
|
|
||||||
/* Script Manager.
|
|
||||||
* Provides a script engine that is initialized with
|
|
||||||
* Qt Creator's interfaces and allows for running scripts.
|
|
||||||
* @{todo} Should it actually manage script files, too? */
|
|
||||||
|
|
||||||
class CORE_EXPORT ScriptManager : public QObject
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
typedef QSharedPointer<QScriptEngine> QScriptEnginePtr;
|
|
||||||
|
|
||||||
// A stack frame as returned by a failed invocation (exception)
|
|
||||||
// fileName may be empty. lineNumber can be 0 for the top frame (goof-up?).
|
|
||||||
struct StackFrame {
|
|
||||||
QString function;
|
|
||||||
QString fileName;
|
|
||||||
int lineNumber;
|
|
||||||
};
|
|
||||||
typedef QList<StackFrame> Stack;
|
|
||||||
|
|
||||||
ScriptManager(QObject *parent = 0) : QObject(parent) {}
|
|
||||||
virtual ~ScriptManager() { }
|
|
||||||
|
|
||||||
// Run a script
|
|
||||||
virtual bool runScript(const QString &script, QString *errorMessage, Stack *errorStack) = 0;
|
|
||||||
virtual bool runScript(const QString &script, QString *errorMessage) = 0;
|
|
||||||
|
|
||||||
virtual QScriptEnginePtr scriptEngine() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Core
|
|
||||||
|
|
||||||
#endif // SCRIPTMANAGER_H
|
|
@@ -1,63 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef SCRIPTMANAGER_P_H
|
|
||||||
#define SCRIPTMANAGER_P_H
|
|
||||||
|
|
||||||
#include "scriptmanager.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QScriptEngine>
|
|
||||||
|
|
||||||
namespace Core {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class ScriptManagerPrivate : public Core::ScriptManager
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ScriptManagerPrivate(QObject *parent);
|
|
||||||
|
|
||||||
bool runScript(const QString &script, QString *errorMessage, Stack *stack);
|
|
||||||
bool runScript(const QString &script, QString *errorMessage);
|
|
||||||
virtual QScriptEnginePtr scriptEngine() { return ensureEngineInitialized(); }
|
|
||||||
|
|
||||||
static QString engineError(const QScriptEnginePtr &scriptEngine);
|
|
||||||
|
|
||||||
private:
|
|
||||||
QScriptEnginePtr ensureEngineInitialized();
|
|
||||||
|
|
||||||
QScriptEnginePtr m_engine;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Core
|
|
||||||
|
|
||||||
#endif // SCRIPTMANAGER_P_H
|
|
@@ -141,7 +141,6 @@ LIBS *= -lole32 \
|
|||||||
}
|
}
|
||||||
include(cdb/cdb.pri)
|
include(cdb/cdb.pri)
|
||||||
include(gdb/gdb.pri)
|
include(gdb/gdb.pri)
|
||||||
include(script/script.pri)
|
|
||||||
include(pdb/pdb.pri)
|
include(pdb/pdb.pri)
|
||||||
include(lldb/lldb.pri)
|
include(lldb/lldb.pri)
|
||||||
include(lldblib/lldbhost.pri)
|
include(lldblib/lldbhost.pri)
|
||||||
|
@@ -187,7 +187,6 @@ enum DebuggerEngineType
|
|||||||
{
|
{
|
||||||
NoEngineType = 0,
|
NoEngineType = 0,
|
||||||
GdbEngineType = 0x001,
|
GdbEngineType = 0x001,
|
||||||
ScriptEngineType = 0x002,
|
|
||||||
CdbEngineType = 0x004,
|
CdbEngineType = 0x004,
|
||||||
PdbEngineType = 0x008,
|
PdbEngineType = 0x008,
|
||||||
QmlEngineType = 0x020,
|
QmlEngineType = 0x020,
|
||||||
@@ -195,7 +194,6 @@ enum DebuggerEngineType
|
|||||||
LldbLibEngineType = 0x080,
|
LldbLibEngineType = 0x080,
|
||||||
LldbEngineType = 0x100,
|
LldbEngineType = 0x100,
|
||||||
AllEngineTypes = GdbEngineType
|
AllEngineTypes = GdbEngineType
|
||||||
| ScriptEngineType
|
|
||||||
| CdbEngineType
|
| CdbEngineType
|
||||||
| PdbEngineType
|
| PdbEngineType
|
||||||
| QmlEngineType
|
| QmlEngineType
|
||||||
|
@@ -72,7 +72,6 @@ namespace Internal {
|
|||||||
|
|
||||||
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *error);
|
DebuggerEngine *createCdbEngine(const DebuggerStartParameters &sp, QString *error);
|
||||||
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp);
|
DebuggerEngine *createGdbEngine(const DebuggerStartParameters &sp);
|
||||||
DebuggerEngine *createScriptEngine(const DebuggerStartParameters &sp);
|
|
||||||
DebuggerEngine *createPdbEngine(const DebuggerStartParameters &sp);
|
DebuggerEngine *createPdbEngine(const DebuggerStartParameters &sp);
|
||||||
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp);
|
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp);
|
||||||
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp, QString *error);
|
DebuggerEngine *createQmlCppEngine(const DebuggerStartParameters &sp, QString *error);
|
||||||
@@ -86,8 +85,6 @@ static const char *engineTypeName(DebuggerEngineType et)
|
|||||||
break;
|
break;
|
||||||
case Debugger::GdbEngineType:
|
case Debugger::GdbEngineType:
|
||||||
return "Gdb engine";
|
return "Gdb engine";
|
||||||
case Debugger::ScriptEngineType:
|
|
||||||
return "Script engine";
|
|
||||||
case Debugger::CdbEngineType:
|
case Debugger::CdbEngineType:
|
||||||
return "Cdb engine";
|
return "Cdb engine";
|
||||||
case Debugger::PdbEngineType:
|
case Debugger::PdbEngineType:
|
||||||
@@ -428,11 +425,6 @@ static bool fixupEngineTypes(DebuggerStartParameters &sp, RunConfiguration *rc,
|
|||||||
if (sp.masterEngineType != NoEngineType)
|
if (sp.masterEngineType != NoEngineType)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (sp.executable.endsWith(_(".js"))) {
|
|
||||||
sp.masterEngineType = ScriptEngineType;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sp.executable.endsWith(_(".py"))) {
|
if (sp.executable.endsWith(_(".py"))) {
|
||||||
sp.masterEngineType = PdbEngineType;
|
sp.masterEngineType = PdbEngineType;
|
||||||
return true;
|
return true;
|
||||||
@@ -518,8 +510,6 @@ DebuggerEngine *DebuggerRunControlFactory::createEngine(DebuggerEngineType et,
|
|||||||
switch (et) {
|
switch (et) {
|
||||||
case GdbEngineType:
|
case GdbEngineType:
|
||||||
return createGdbEngine(sp);
|
return createGdbEngine(sp);
|
||||||
case ScriptEngineType:
|
|
||||||
return createScriptEngine(sp);
|
|
||||||
case CdbEngineType:
|
case CdbEngineType:
|
||||||
return createCdbEngine(sp, errorMessage);
|
return createCdbEngine(sp, errorMessage);
|
||||||
case PdbEngineType:
|
case PdbEngineType:
|
||||||
|
@@ -1,9 +0,0 @@
|
|||||||
HEADERS += \
|
|
||||||
$$PWD/scriptengine.h \
|
|
||||||
|
|
||||||
SOURCES += \
|
|
||||||
$$PWD/scriptengine.cpp \
|
|
||||||
|
|
||||||
FORMS +=
|
|
||||||
|
|
||||||
RESOURCES +=
|
|
@@ -1,815 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "scriptengine.h"
|
|
||||||
|
|
||||||
#include "debuggerstartparameters.h"
|
|
||||||
#include "breakhandler.h"
|
|
||||||
#include "debuggerconstants.h"
|
|
||||||
#include "debuggercore.h"
|
|
||||||
#include "debuggerdialogs.h"
|
|
||||||
#include "debuggerstringutils.h"
|
|
||||||
#include "moduleshandler.h"
|
|
||||||
#include "registerhandler.h"
|
|
||||||
#include "sourceutils.h"
|
|
||||||
#include "stackhandler.h"
|
|
||||||
#include "watchhandler.h"
|
|
||||||
#include "watchutils.h"
|
|
||||||
#include "debuggertooltipmanager.h"
|
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
#include <texteditor/itexteditor.h>
|
|
||||||
#include <coreplugin/idocument.h>
|
|
||||||
#include <coreplugin/scriptmanager/scriptmanager.h>
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
|
|
||||||
#include <QDateTime>
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QDir>
|
|
||||||
#include <QFileInfo>
|
|
||||||
#include <QTimer>
|
|
||||||
|
|
||||||
#include <QApplication>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QToolTip>
|
|
||||||
|
|
||||||
#include <QScriptContext>
|
|
||||||
#include <QScriptClassPropertyIterator>
|
|
||||||
#include <QScriptContextInfo>
|
|
||||||
#include <QScriptEngine>
|
|
||||||
#include <QScriptEngineAgent>
|
|
||||||
#include <QScriptValue>
|
|
||||||
#include <QScriptValueIterator>
|
|
||||||
|
|
||||||
|
|
||||||
namespace Debugger {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
enum { debugScript = 0 };
|
|
||||||
|
|
||||||
#define SDEBUG(s) do { if (debugScript) qDebug() << s; } while (0)
|
|
||||||
#define XSDEBUG(s) qDebug() << s
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// ScriptEngine
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class ScriptAgent : public QScriptEngineAgent
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ScriptAgent(ScriptEngine *debugger, QScriptEngine *script);
|
|
||||||
~ScriptAgent() {}
|
|
||||||
|
|
||||||
void contextPop();
|
|
||||||
void contextPush();
|
|
||||||
void exceptionCatch(qint64 scriptId, const QScriptValue &exception);
|
|
||||||
void exceptionThrow(qint64 scriptId, const QScriptValue & exception,
|
|
||||||
bool hasHandler);
|
|
||||||
void functionEntry(qint64 scriptId);
|
|
||||||
void functionExit(qint64 scriptId, const QScriptValue &returnValue);
|
|
||||||
void positionChange(qint64 scriptId, int lineNumber, int columnNumber);
|
|
||||||
void scriptLoad(qint64 id, const QString &program, const QString &fileName,
|
|
||||||
int baseLineNumber);
|
|
||||||
void scriptUnload(qint64 id);
|
|
||||||
|
|
||||||
void showMessage(const QString &msg);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void maybeBreakNow(bool byFunction);
|
|
||||||
|
|
||||||
ScriptEngine *q;
|
|
||||||
int m_depth;
|
|
||||||
int m_contextDepth;
|
|
||||||
};
|
|
||||||
|
|
||||||
ScriptAgent::ScriptAgent(ScriptEngine *debugger, QScriptEngine *script)
|
|
||||||
: QScriptEngineAgent(script), q(debugger), m_depth(0), m_contextDepth(0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
void ScriptAgent::showMessage(const QString &msg)
|
|
||||||
{
|
|
||||||
SDEBUG(msg);
|
|
||||||
q->showMessage(msg, LogMisc);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::contextPop()
|
|
||||||
{
|
|
||||||
//showMessage(_("ContextPop: %1").arg(m_contextDepth));
|
|
||||||
--m_contextDepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::contextPush()
|
|
||||||
{
|
|
||||||
++m_contextDepth;
|
|
||||||
//showMessage(_("ContextPush: %1 ").arg(m_contextDepth));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::exceptionCatch(qint64 scriptId, const QScriptValue & exception)
|
|
||||||
{
|
|
||||||
Q_UNUSED(scriptId)
|
|
||||||
Q_UNUSED(exception)
|
|
||||||
showMessage(_("An exception was caught on %1: '%2'").
|
|
||||||
arg(scriptId).arg(exception.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::exceptionThrow(qint64 scriptId, const QScriptValue &exception,
|
|
||||||
bool hasHandler)
|
|
||||||
{
|
|
||||||
Q_UNUSED(scriptId)
|
|
||||||
Q_UNUSED(exception)
|
|
||||||
Q_UNUSED(hasHandler)
|
|
||||||
showMessage(_("An exception occurred on %1: '%2'").
|
|
||||||
arg(scriptId).arg(exception.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::functionEntry(qint64 scriptId)
|
|
||||||
{
|
|
||||||
Q_UNUSED(scriptId)
|
|
||||||
++m_depth;
|
|
||||||
//showMessage(_("Function entry occurred on %1, depth: %2").arg(scriptId));
|
|
||||||
q->checkForBreakCondition(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue)
|
|
||||||
{
|
|
||||||
Q_UNUSED(scriptId)
|
|
||||||
Q_UNUSED(returnValue)
|
|
||||||
--m_depth;
|
|
||||||
//showMessage(_("Function exit occurred on %1: '%2'").
|
|
||||||
// arg(scriptId).arg(returnValue.toString()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
|
|
||||||
{
|
|
||||||
Q_UNUSED(scriptId)
|
|
||||||
Q_UNUSED(lineNumber)
|
|
||||||
Q_UNUSED(columnNumber)
|
|
||||||
//showMessage(_("Position: %1").arg(lineNumber));
|
|
||||||
q->checkForBreakCondition(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::scriptLoad(qint64 scriptId, const QString &program,
|
|
||||||
const QString &fileName, int baseLineNumber)
|
|
||||||
{
|
|
||||||
Q_UNUSED(scriptId)
|
|
||||||
Q_UNUSED(program)
|
|
||||||
Q_UNUSED(fileName)
|
|
||||||
Q_UNUSED(baseLineNumber)
|
|
||||||
showMessage(_("Loaded: %1 id: %2").arg(fileName).arg(scriptId));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptAgent::scriptUnload(qint64 scriptId)
|
|
||||||
{
|
|
||||||
Q_UNUSED(scriptId)
|
|
||||||
showMessage(_("Unload script id %1 ").arg(scriptId));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// ScriptEngine
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
ScriptEngine::ScriptEngine(const DebuggerStartParameters &startParameters)
|
|
||||||
: DebuggerEngine(startParameters)
|
|
||||||
{
|
|
||||||
setObjectName(QLatin1String("ScriptEngine"));
|
|
||||||
}
|
|
||||||
|
|
||||||
ScriptEngine::~ScriptEngine()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
|
|
||||||
{
|
|
||||||
Q_UNUSED(command)
|
|
||||||
Q_UNUSED(languages)
|
|
||||||
XSDEBUG("FIXME: ScriptEngine::executeDebuggerCommand()");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::shutdownInferior()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
|
|
||||||
SDEBUG("ScriptEngine::shutdownInferior()");
|
|
||||||
m_scriptEngine->setAgent(0);
|
|
||||||
//m_scriptAgent.reset(0);
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = false;
|
|
||||||
if (m_scriptEngine->isEvaluating())
|
|
||||||
m_scriptEngine->abortEvaluation();
|
|
||||||
notifyInferiorShutdownOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::shutdownEngine()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
|
|
||||||
m_scriptEngine->setAgent(0);
|
|
||||||
notifyEngineShutdownOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::setupEngine()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == EngineSetupRequested, qDebug() << state());
|
|
||||||
showMessage(_("STARTING SCRIPT DEBUGGER"), LogMisc);
|
|
||||||
if (m_scriptEngine.isNull())
|
|
||||||
m_scriptEngine = Core::ICore::scriptManager()->scriptEngine();
|
|
||||||
QTC_CHECK(!m_scriptAgent);
|
|
||||||
m_scriptAgent.reset(new ScriptAgent(this, m_scriptEngine.data()));
|
|
||||||
m_scriptEngine->setAgent(m_scriptAgent.data());
|
|
||||||
//m_scriptEngine->setAgent(new ScriptAgent(this, m_scriptEngine.data()));
|
|
||||||
/* Keep the gui alive (have the engine call processEvents() while the script
|
|
||||||
* is run in the foreground). */
|
|
||||||
m_scriptEngine->setProcessEventsInterval(1 /*ms*/);
|
|
||||||
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = false;
|
|
||||||
m_scriptEngine->abortEvaluation();
|
|
||||||
|
|
||||||
notifyEngineSetupOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::setupInferior()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
|
||||||
m_scriptFileName = QFileInfo(startParameters().executable).absoluteFilePath();
|
|
||||||
showMessage(_("SCRIPT FILE: ") + m_scriptFileName);
|
|
||||||
QFile scriptFile(m_scriptFileName);
|
|
||||||
if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
|
||||||
showMessageBox(QMessageBox::Critical, tr("Error:"),
|
|
||||||
_("Cannot open script file %1:\n%2").
|
|
||||||
arg(m_scriptFileName, scriptFile.errorString()));
|
|
||||||
notifyInferiorSetupFailed();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
QTextStream stream(&scriptFile);
|
|
||||||
m_scriptContents = stream.readAll();
|
|
||||||
scriptFile.close();
|
|
||||||
attemptBreakpointSynchronization();
|
|
||||||
notifyInferiorSetupOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::continueInferior()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
SDEBUG("ScriptEngine::continueInferior()");
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *qtExtensionsC[] = {
|
|
||||||
"qt.core", "qt.gui", "qt.xml", "qt.svg", "qt.network",
|
|
||||||
"qt.sql", "qt.opengl", "qt.webkit", "qt.xmlpatterns", "qt.uitools"
|
|
||||||
};
|
|
||||||
|
|
||||||
void ScriptEngine::importExtensions()
|
|
||||||
{
|
|
||||||
SDEBUG("ScriptEngine::importExtensions()");
|
|
||||||
QStringList extensions;
|
|
||||||
const int extCount = sizeof(qtExtensionsC)/sizeof(const char *);
|
|
||||||
for (int e = 0; e < extCount; e++)
|
|
||||||
extensions.append(QLatin1String(qtExtensionsC[e]));
|
|
||||||
if (m_scriptEngine->importedExtensions().contains(extensions.front()))
|
|
||||||
return; // true;
|
|
||||||
QDir dir(QLatin1String("/home/apoenitz/dev/qtscriptgenerator"));
|
|
||||||
if (!dir.cd(QLatin1String("plugins"))) {
|
|
||||||
fprintf(stderr, "plugins folder does not exist -- did you build the bindings?\n");
|
|
||||||
return; // false;
|
|
||||||
}
|
|
||||||
QStringList paths = qApp->libraryPaths();
|
|
||||||
paths << dir.absolutePath();
|
|
||||||
qApp->setLibraryPaths(paths);
|
|
||||||
QStringList failExtensions;
|
|
||||||
foreach (const QString &ext, extensions) {
|
|
||||||
QScriptValue ret = m_scriptEngine->importExtension(ext);
|
|
||||||
if (ret.isError())
|
|
||||||
failExtensions.append(ext);
|
|
||||||
}
|
|
||||||
if (!failExtensions.isEmpty()) {
|
|
||||||
if (failExtensions.size() == extensions.size()) {
|
|
||||||
qWarning("Failed to import Qt bindings!\n"
|
|
||||||
"Plugins directory searched: %s/script\n"
|
|
||||||
"Make sure that the bindings have been built, "
|
|
||||||
"and that this executable and the plugins are "
|
|
||||||
"using compatible Qt libraries.", qPrintable(dir.absolutePath()));
|
|
||||||
} else {
|
|
||||||
qWarning("Failed to import some Qt bindings: %s\n"
|
|
||||||
"Plugins directory searched: %s/script\n"
|
|
||||||
"Make sure that the bindings have been built, "
|
|
||||||
"and that this executable and the plugins are "
|
|
||||||
"using compatible Qt libraries.",
|
|
||||||
qPrintable(failExtensions.join(QLatin1String(", "))),
|
|
||||||
qPrintable(dir.absolutePath()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return; // failExtensions.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::runEngine()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
|
||||||
notifyEngineRunAndInferiorRunOk();
|
|
||||||
showStatusMessage(tr("Running requested..."), 5000);
|
|
||||||
showMessage(QLatin1String("Running: ") + m_scriptFileName, LogMisc);
|
|
||||||
importExtensions();
|
|
||||||
const QScriptValue result =
|
|
||||||
m_scriptEngine->evaluate(m_scriptContents, m_scriptFileName);
|
|
||||||
QString msg;
|
|
||||||
if (m_scriptEngine->hasUncaughtException()) {
|
|
||||||
msg = _("An exception occurred during execution at line: %1\n%2\n")
|
|
||||||
.arg(m_scriptEngine->uncaughtExceptionLineNumber())
|
|
||||||
.arg(m_scriptEngine->uncaughtException().toString());
|
|
||||||
msg += m_scriptEngine->uncaughtExceptionBacktrace()
|
|
||||||
.join(QString(QLatin1Char('\n')));
|
|
||||||
} else {
|
|
||||||
msg = _("Evaluation returns '%1'").arg(result.toString());
|
|
||||||
}
|
|
||||||
showMessage(msg, LogMisc);
|
|
||||||
showMessage(_("This was the outermost function."));
|
|
||||||
notifyInferiorExited();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::interruptInferior()
|
|
||||||
{
|
|
||||||
m_stopOnNextLine = true;
|
|
||||||
XSDEBUG("ScriptEngine::interruptInferior()");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeStep()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
//SDEBUG("ScriptEngine::stepExec()");
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeStepI()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
//SDEBUG("ScriptEngine::stepIExec()");
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeStepOut()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
//SDEBUG("ScriptEngine::stepOutExec()");
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeNext()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
//SDEBUG("ScriptEngine::nextExec()");
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeNextI()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
//SDEBUG("ScriptEngine::nextIExec()");
|
|
||||||
m_stopped = false;
|
|
||||||
m_stopOnNextLine = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeRunToLine(const ContextData &data)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
Q_UNUSED(data)
|
|
||||||
SDEBUG("FIXME: ScriptEngine::runToLineExec()");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeRunToFunction(const QString &functionName)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
Q_UNUSED(functionName)
|
|
||||||
XSDEBUG("FIXME: ScriptEngine::runToFunctionExec()");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::executeJumpToLine(const ContextData &data)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
||||||
notifyInferiorRunRequested();
|
|
||||||
Q_UNUSED(data)
|
|
||||||
XSDEBUG("FIXME: ScriptEngine::jumpToLineExec()");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::activateFrame(int index)
|
|
||||||
{
|
|
||||||
Q_UNUSED(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::selectThread(ThreadId threadId)
|
|
||||||
{
|
|
||||||
Q_UNUSED(threadId)
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScriptEngine::acceptsBreakpoint(BreakpointModelId id) const
|
|
||||||
{
|
|
||||||
const QString fileName = breakHandler()->fileName(id);
|
|
||||||
return fileName.endsWith(QLatin1String(".js"));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::attemptBreakpointSynchronization()
|
|
||||||
{
|
|
||||||
QTC_ASSERT(false, /* FIXME */);
|
|
||||||
/*
|
|
||||||
BreakHandler *handler = breakHandler();
|
|
||||||
bool updateNeeded = false;
|
|
||||||
for (int index = 0; index != handler->size(); ++index) {
|
|
||||||
BreakpointData *data = handler->at(index);
|
|
||||||
if (data->pending) {
|
|
||||||
data->pending = false; // FIXME
|
|
||||||
updateNeeded = true;
|
|
||||||
}
|
|
||||||
if (data->bpNumber.isEmpty()) {
|
|
||||||
data->bpNumber = QByteArray::number(index + 1);
|
|
||||||
updateNeeded = true;
|
|
||||||
}
|
|
||||||
if (!data->fileName.isEmpty() && data->markerFileName().isEmpty()) {
|
|
||||||
data->setMarkerFileName(data->fileName);
|
|
||||||
data->setMarkerLineNumber(data->lineNumber);
|
|
||||||
updateNeeded = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (updateNeeded)
|
|
||||||
handler->updateMarkers();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::loadSymbols(const QString &moduleName)
|
|
||||||
{
|
|
||||||
Q_UNUSED(moduleName)
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::loadAllSymbols()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::reloadModules()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::requestModuleSymbols(const QString & /*moduleName*/)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Tooltip specific stuff
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
static WatchData m_toolTip;
|
|
||||||
static QPoint m_toolTipPos;
|
|
||||||
static QHash<QString, WatchData> m_toolTipCache;
|
|
||||||
|
|
||||||
bool ScriptEngine::setToolTipExpression(const QPoint &mousePos,
|
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
|
|
||||||
{
|
|
||||||
Q_UNUSED(mousePos)
|
|
||||||
Q_UNUSED(editor)
|
|
||||||
|
|
||||||
if (state() != InferiorStopOk) {
|
|
||||||
//SDEBUG("SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Check mime type and get expression (borrowing some C++ - functions)
|
|
||||||
const QString javaScriptMimeType =
|
|
||||||
QLatin1String("application/javascript");
|
|
||||||
if (!editor->document() || editor->document()->mimeType() != javaScriptMimeType)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int line;
|
|
||||||
int column;
|
|
||||||
QString exp = cppExpressionAt(editor, ctx.position, &line, &column);
|
|
||||||
|
|
||||||
/*
|
|
||||||
if (m_toolTipCache.contains(exp)) {
|
|
||||||
const WatchData & data = m_toolTipCache[exp];
|
|
||||||
q->watchHandler()->removeChildren(data.iname);
|
|
||||||
insertData(data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
QToolTip::hideText();
|
|
||||||
if (exp.isEmpty() || exp.startsWith(QLatin1Char('#'))) {
|
|
||||||
QToolTip::hideText();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasLetterOrNumber(exp)) {
|
|
||||||
QToolTip::showText(m_toolTipPos, tr("'%1' contains no identifier.").arg(exp));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exp.startsWith(QLatin1Char('"')) && exp.endsWith(QLatin1Char('"'))) {
|
|
||||||
QToolTip::showText(m_toolTipPos, tr("String literal %1.").arg(exp));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exp.startsWith(QLatin1String("++")) || exp.startsWith(QLatin1String("--")))
|
|
||||||
exp.remove(0, 2);
|
|
||||||
|
|
||||||
if (exp.endsWith(QLatin1String("++")) || exp.endsWith(QLatin1String("--")))
|
|
||||||
exp.remove(0, 2);
|
|
||||||
|
|
||||||
if (exp.startsWith(QLatin1Char('<')) || exp.startsWith(QLatin1Char('[')))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (hasSideEffects(exp)) {
|
|
||||||
QToolTip::showText(m_toolTipPos,
|
|
||||||
tr("Cowardly refusing to evaluate expression '%1' "
|
|
||||||
"with potential side effects.").arg(exp));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
//if (m_manager->status() != InferiorStopOk)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// FIXME: 'exp' can contain illegal characters
|
|
||||||
m_toolTip = WatchData();
|
|
||||||
m_toolTip.exp = exp;
|
|
||||||
m_toolTip.name = exp;
|
|
||||||
m_toolTip.iname = tooltipIName;
|
|
||||||
insertData(m_toolTip);
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// Watch specific stuff
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void ScriptEngine::assignValueInDebugger(const Internal::WatchData *,
|
|
||||||
const QString &expression, const QVariant &value)
|
|
||||||
{
|
|
||||||
SDEBUG("ASSIGNING: " << (expression + QLatin1Char('=') + value.toString()));
|
|
||||||
m_scriptEngine->evaluate(expression + QLatin1Char('=') + value.toString());
|
|
||||||
updateLocals();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ScriptEngine::checkForBreakCondition(bool byFunction)
|
|
||||||
{
|
|
||||||
// FIXME: Should that ever happen after setAgent(0) in shutdownInferior()?
|
|
||||||
// In practice, it does, so chicken out.
|
|
||||||
if (targetState() == DebuggerFinished)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
const QScriptContext *context = m_scriptEngine->currentContext();
|
|
||||||
const QScriptContextInfo info(context);
|
|
||||||
|
|
||||||
// Update breakpoints
|
|
||||||
const QString functionName = info.functionName();
|
|
||||||
const QString fileName = info.fileName();
|
|
||||||
const int lineNumber = byFunction
|
|
||||||
? info.functionStartLineNumber() : info.lineNumber();
|
|
||||||
SDEBUG(Q_FUNC_INFO << byFunction << functionName << lineNumber << fileName);
|
|
||||||
if (m_stopOnNextLine) {
|
|
||||||
// Interrupt inferior
|
|
||||||
m_stopOnNextLine = false;
|
|
||||||
} else {
|
|
||||||
if (byFunction && functionName.isEmpty())
|
|
||||||
return false;
|
|
||||||
BreakHandler *handler = breakHandler();
|
|
||||||
BreakpointModelId id = byFunction ?
|
|
||||||
handler->findBreakpointByFunction(functionName) :
|
|
||||||
handler->findBreakpointByFileAndLine(fileName, lineNumber, false);
|
|
||||||
|
|
||||||
// Skip disabled breakpoint.
|
|
||||||
if (!handler->isEnabled(id))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
BreakpointResponse br;
|
|
||||||
// We just run into a breakpoint.
|
|
||||||
//SDEBUG("RESOLVING BREAKPOINT AT " << fileName << lineNumber);
|
|
||||||
br.lineNumber = lineNumber;
|
|
||||||
br.fileName = fileName;
|
|
||||||
br.functionName = functionName;
|
|
||||||
handler->notifyBreakpointInsertOk(id);
|
|
||||||
handler->setResponse(id, br);
|
|
||||||
}
|
|
||||||
notifyInferiorSpontaneousStop();
|
|
||||||
SDEBUG("Stopped at " << lineNumber << fileName);
|
|
||||||
showStatusMessage(tr("Stopped at %1:%2.").arg(fileName).arg(lineNumber), 5000);
|
|
||||||
gotoLocation(Location(fileName, lineNumber));
|
|
||||||
updateLocals();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::updateLocals()
|
|
||||||
{
|
|
||||||
QScriptContext *context = m_scriptEngine->currentContext();
|
|
||||||
SDEBUG(Q_FUNC_INFO);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Build stack
|
|
||||||
//
|
|
||||||
QList<StackFrame> stackFrames;
|
|
||||||
int i = 0;
|
|
||||||
for (QScriptContext *c = context; c; c = c->parentContext(), ++i) {
|
|
||||||
const QScriptContextInfo info(c);
|
|
||||||
StackFrame frame;
|
|
||||||
frame.level = i;
|
|
||||||
frame.file = info.fileName();
|
|
||||||
frame.function = info.functionName();
|
|
||||||
frame.from = QString::number(info.functionStartLineNumber());
|
|
||||||
frame.to = QString::number(info.functionEndLineNumber());
|
|
||||||
frame.line = info.lineNumber();
|
|
||||||
if (frame.function.isEmpty())
|
|
||||||
frame.function = QLatin1String("<global scope>");
|
|
||||||
//frame.address = ...;
|
|
||||||
stackFrames.append(frame);
|
|
||||||
}
|
|
||||||
stackHandler()->setFrames(stackFrames);
|
|
||||||
|
|
||||||
//
|
|
||||||
// Build locals, deactivate agent meanwhile.
|
|
||||||
//
|
|
||||||
m_scriptEngine->setAgent(0);
|
|
||||||
|
|
||||||
WatchData data;
|
|
||||||
data.id = m_watchIdCounter++;
|
|
||||||
m_watchIdToScriptValue.insert(data.id, context->activationObject());
|
|
||||||
data.iname = "local";
|
|
||||||
data.name = _(data.iname);
|
|
||||||
|
|
||||||
updateSubItem(data);
|
|
||||||
// FIXME: Use an extra thread. This here is evil.
|
|
||||||
m_stopped = true;
|
|
||||||
showStatusMessage(tr("Stopped."), 5000);
|
|
||||||
while (m_stopped) {
|
|
||||||
//SDEBUG("LOOPING");
|
|
||||||
QApplication::processEvents();
|
|
||||||
}
|
|
||||||
// Clear any exceptions occurred during locals evaluation.
|
|
||||||
m_scriptEngine->clearExceptions();
|
|
||||||
m_scriptEngine->setAgent(m_scriptAgent.data());
|
|
||||||
notifyInferiorRunOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::updateWatchData(const WatchData &data, const WatchUpdateFlags &flags)
|
|
||||||
{
|
|
||||||
Q_UNUSED(flags);
|
|
||||||
updateSubItem(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline QString msgDebugInsert(const WatchData &d0, const QList<WatchData>& children)
|
|
||||||
{
|
|
||||||
QString rc;
|
|
||||||
QTextStream str(&rc);
|
|
||||||
str << "INSERTING " << d0.toString() << '\n';
|
|
||||||
foreach (const WatchData &c, children)
|
|
||||||
str << " " << c.toString() << '\n';
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptEngine::updateSubItem(const WatchData &data0)
|
|
||||||
{
|
|
||||||
WatchData data = data0;
|
|
||||||
QList<WatchData> children;
|
|
||||||
//SDEBUG("\nUPDATE SUBITEM: " << data.toString() << data.scriptValue.toString());
|
|
||||||
QTC_ASSERT(data.isValid(), return);
|
|
||||||
|
|
||||||
const QScriptValue &ob = m_watchIdToScriptValue.value(data.id);
|
|
||||||
if (data.isTypeNeeded() || data.isValueNeeded()) {
|
|
||||||
if (ob.isArray()) {
|
|
||||||
data.setType("Array", false);
|
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
|
||||||
} else if (ob.isBool()) {
|
|
||||||
data.setType("Bool", false);
|
|
||||||
data.setValue(ob.toBool() ? QLatin1String("true") : QLatin1String("false"));
|
|
||||||
data.setHasChildren(false);
|
|
||||||
} else if (ob.isDate()) {
|
|
||||||
data.setType("Date", false);
|
|
||||||
data.setValue(ob.toDateTime().toString());
|
|
||||||
data.setHasChildren(false);
|
|
||||||
} else if (ob.isError()) {
|
|
||||||
data.setType("Error", false);
|
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
|
||||||
} else if (ob.isFunction()) {
|
|
||||||
data.setType("Function", false);
|
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
|
||||||
} else if (ob.isNull()) {
|
|
||||||
const QString nullValue = QLatin1String("<null>");
|
|
||||||
data.setType("<null>", false);
|
|
||||||
data.setValue(nullValue);
|
|
||||||
} else if (ob.isNumber()) {
|
|
||||||
data.setType("Number", false);
|
|
||||||
data.setValue(QString::number(ob.toNumber()));
|
|
||||||
data.setHasChildren(false);
|
|
||||||
} else if (ob.isObject()) {
|
|
||||||
data.setType("Object", false);
|
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
|
||||||
} else if (ob.isQMetaObject()) {
|
|
||||||
data.setType("QMetaObject", false);
|
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
|
||||||
} else if (ob.isQObject()) {
|
|
||||||
data.setType("QObject", false);
|
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
|
||||||
} else if (ob.isRegExp()) {
|
|
||||||
data.setType("RegExp", false);
|
|
||||||
data.setValue(ob.toRegExp().pattern());
|
|
||||||
} else if (ob.isString()) {
|
|
||||||
data.setType("String", false);
|
|
||||||
data.setValue(ob.toString());
|
|
||||||
} else if (ob.isVariant()) {
|
|
||||||
data.setType("Variant", false);
|
|
||||||
data.setValue(QString(QLatin1Char(' ')));
|
|
||||||
} else if (ob.isUndefined()) {
|
|
||||||
data.setType("<undefined>", false);
|
|
||||||
data.setValue(QLatin1String("<unknown>"));
|
|
||||||
data.setHasChildren(false);
|
|
||||||
} else {
|
|
||||||
const QString unknown = QLatin1String("<unknown>");
|
|
||||||
data.setType("<unknown>", false);
|
|
||||||
data.setValue(unknown);
|
|
||||||
data.setHasChildren(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.isChildrenNeeded()) {
|
|
||||||
QScriptValueIterator it(ob);
|
|
||||||
while (it.hasNext()) {
|
|
||||||
it.next();
|
|
||||||
WatchData data1;
|
|
||||||
data1.iname = data.iname + '.' + it.name().toLatin1();
|
|
||||||
data1.exp = it.name().toLatin1();
|
|
||||||
data1.name = it.name();
|
|
||||||
data.id = m_watchIdCounter++;
|
|
||||||
m_watchIdToScriptValue.insert(data.id, it.value());
|
|
||||||
if (watchHandler()->isExpandedIName(data1.iname))
|
|
||||||
data1.setChildrenNeeded();
|
|
||||||
else
|
|
||||||
data1.setChildrenUnneeded();
|
|
||||||
children.push_back(data1);
|
|
||||||
}
|
|
||||||
data.setHasChildren(!children.isEmpty());
|
|
||||||
data.setChildrenUnneeded();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.isHasChildrenNeeded()) {
|
|
||||||
QScriptValueIterator it(ob);
|
|
||||||
data.setHasChildren(it.hasNext());
|
|
||||||
}
|
|
||||||
|
|
||||||
SDEBUG(msgDebugInsert(data, children));
|
|
||||||
watchHandler()->insertIncompleteData(data);
|
|
||||||
if (!children.isEmpty())
|
|
||||||
watchHandler()->insertData(children);
|
|
||||||
}
|
|
||||||
|
|
||||||
DebuggerEngine *createScriptEngine(const DebuggerStartParameters &sp)
|
|
||||||
{
|
|
||||||
return new ScriptEngine(sp);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Debugger
|
|
@@ -1,129 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
||||||
** Contact: http://www.qt-project.org/legal
|
|
||||||
**
|
|
||||||
** This file is part of Qt Creator.
|
|
||||||
**
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and Digia. For licensing terms and
|
|
||||||
** conditions see http://qt.digia.com/licensing. For further information
|
|
||||||
** use the contact form at http://qt.digia.com/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Lesser General Public License Usage
|
|
||||||
** 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.
|
|
||||||
**
|
|
||||||
** In addition, as a special exception, Digia gives you certain additional
|
|
||||||
** rights. These rights are described in the Digia Qt LGPL Exception
|
|
||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifndef DEBUGGER_SCRIPTENGINE_H
|
|
||||||
#define DEBUGGER_SCRIPTENGINE_H
|
|
||||||
|
|
||||||
#include "debuggerengine.h"
|
|
||||||
|
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QScriptEngine;
|
|
||||||
class QScriptValue;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Debugger {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class ScriptAgent;
|
|
||||||
class WatchData;
|
|
||||||
|
|
||||||
/* 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. */
|
|
||||||
|
|
||||||
class ScriptEngine : public Debugger::DebuggerEngine
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit ScriptEngine(const DebuggerStartParameters &startParameters);
|
|
||||||
virtual ~ScriptEngine();
|
|
||||||
|
|
||||||
private:
|
|
||||||
// DebuggerEngine implementation
|
|
||||||
void executeStep();
|
|
||||||
void executeStepOut();
|
|
||||||
void executeNext();
|
|
||||||
void executeStepI();
|
|
||||||
void executeNextI();
|
|
||||||
|
|
||||||
bool setToolTipExpression(const QPoint &mousePos,
|
|
||||||
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &);
|
|
||||||
void setupEngine();
|
|
||||||
void setupInferior();
|
|
||||||
void runEngine();
|
|
||||||
void shutdownInferior();
|
|
||||||
void shutdownEngine();
|
|
||||||
|
|
||||||
void continueInferior();
|
|
||||||
void interruptInferior();
|
|
||||||
|
|
||||||
void executeRunToLine(const ContextData &data);
|
|
||||||
void executeRunToFunction(const QString &functionName);
|
|
||||||
void executeJumpToLine(const ContextData &data);
|
|
||||||
|
|
||||||
void activateFrame(int index);
|
|
||||||
void selectThread(ThreadId threadId);
|
|
||||||
|
|
||||||
bool acceptsBreakpoint(BreakpointModelId id) const;
|
|
||||||
void attemptBreakpointSynchronization();
|
|
||||||
|
|
||||||
void assignValueInDebugger(const WatchData *w,
|
|
||||||
const QString &expr, const QVariant &value);
|
|
||||||
void executeDebuggerCommand(const QString &command, DebuggerLanguages languages);
|
|
||||||
|
|
||||||
void loadSymbols(const QString &moduleName);
|
|
||||||
void loadAllSymbols();
|
|
||||||
void requestModuleSymbols(const QString &moduleName);
|
|
||||||
void reloadModules();
|
|
||||||
void reloadRegisters() {}
|
|
||||||
void reloadSourceFiles() {}
|
|
||||||
void reloadFullStack() {}
|
|
||||||
|
|
||||||
bool checkForBreakCondition(bool byFunction);
|
|
||||||
void updateWatchData(const WatchData &data, const WatchUpdateFlags &flags);
|
|
||||||
void updateLocals();
|
|
||||||
void updateSubItem(const WatchData &data);
|
|
||||||
bool hasCapability(unsigned) const { return false; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class ScriptAgent;
|
|
||||||
|
|
||||||
void importExtensions();
|
|
||||||
|
|
||||||
QSharedPointer<QScriptEngine> m_scriptEngine;
|
|
||||||
QString m_scriptContents;
|
|
||||||
QString m_scriptFileName;
|
|
||||||
QScopedPointer<ScriptAgent> m_scriptAgent;
|
|
||||||
QHash<quint64,QScriptValue> m_watchIdToScriptValue;
|
|
||||||
quint64 m_watchIdCounter;
|
|
||||||
|
|
||||||
bool m_stopped;
|
|
||||||
bool m_stopOnNextLine;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Debugger
|
|
||||||
|
|
||||||
#endif // DEBUGGER_SCRIPTENGINE_H
|
|
Reference in New Issue
Block a user