2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** Commercial Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** If you are unsure which license is appropriate for your use, please
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-18 12:34:59 +01:00
|
|
|
#define QT_NO_CAST_FROM_ASCII
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "scriptengine.h"
|
|
|
|
|
|
2008-12-09 16:18:28 +01:00
|
|
|
#include "breakhandler.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "debuggerconstants.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2010-07-07 14:36:17 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "moduleshandler.h"
|
|
|
|
|
#include "registerhandler.h"
|
|
|
|
|
#include "stackhandler.h"
|
|
|
|
|
#include "watchhandler.h"
|
2009-04-29 17:52:19 +02:00
|
|
|
#include "watchutils.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2008-12-09 16:18:28 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-14 14:29:37 +02:00
|
|
|
#include <texteditor/itexteditor.h>
|
|
|
|
|
#include <coreplugin/ifile.h>
|
2010-01-15 17:30:26 +01:00
|
|
|
#include <coreplugin/scriptmanager/scriptmanager.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2009-05-14 14:29:37 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtCore/QDateTime>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
|
2009-03-02 15:14:12 +01:00
|
|
|
#include <QtGui/QApplication>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QToolTip>
|
|
|
|
|
|
|
|
|
|
#include <QtScript/QScriptContext>
|
|
|
|
|
#include <QtScript/QScriptClassPropertyIterator>
|
|
|
|
|
#include <QtScript/QScriptContextInfo>
|
|
|
|
|
#include <QtScript/QScriptEngine>
|
|
|
|
|
#include <QtScript/QScriptEngineAgent>
|
|
|
|
|
#include <QtScript/QScriptValue>
|
|
|
|
|
#include <QtScript/QScriptValueIterator>
|
|
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
// #define DEBUG_SCRIPT 1
|
2009-04-07 11:24:00 +02:00
|
|
|
#if DEBUG_SCRIPT
|
|
|
|
|
# define SDEBUG(s) qDebug() << s
|
|
|
|
|
#else
|
|
|
|
|
# define SDEBUG(s)
|
|
|
|
|
#endif
|
2009-04-07 13:38:19 +02:00
|
|
|
# define XSDEBUG(s) qDebug() << s
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-23 10:45:32 +02:00
|
|
|
|
|
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ScriptEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2009-09-23 10:45:32 +02:00
|
|
|
class ScriptAgent : public QScriptEngineAgent
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void maybeBreakNow(bool byFunction);
|
|
|
|
|
|
2010-01-29 21:33:57 +01:00
|
|
|
ScriptEngine *q;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ScriptAgent::ScriptAgent(ScriptEngine *debugger, QScriptEngine *script)
|
|
|
|
|
: QScriptEngineAgent(script), q(debugger)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::contextPop()
|
|
|
|
|
{
|
2009-04-07 11:24:00 +02:00
|
|
|
SDEBUG("ScriptAgent::contextPop: ");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::contextPush()
|
|
|
|
|
{
|
2009-04-07 11:24:00 +02:00
|
|
|
SDEBUG("ScriptAgent::contextPush: ");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::exceptionCatch(qint64 scriptId, const QScriptValue & exception)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(scriptId)
|
|
|
|
|
Q_UNUSED(exception)
|
2010-01-15 17:30:26 +01:00
|
|
|
const QString msg = QString::fromLatin1("An exception was caught on %1: '%2'").
|
|
|
|
|
arg(scriptId).arg(exception.toString());
|
|
|
|
|
SDEBUG(msg);
|
2010-06-14 18:19:02 +02:00
|
|
|
q->showMessage(msg, LogMisc);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::exceptionThrow(qint64 scriptId, const QScriptValue &exception,
|
|
|
|
|
bool hasHandler)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(scriptId)
|
|
|
|
|
Q_UNUSED(exception)
|
|
|
|
|
Q_UNUSED(hasHandler)
|
2010-01-15 17:30:26 +01:00
|
|
|
const QString msg = QString::fromLatin1("An exception occurred on %1: '%2'").
|
|
|
|
|
arg(scriptId).arg(exception.toString());
|
|
|
|
|
SDEBUG(msg);
|
2010-06-14 18:19:02 +02:00
|
|
|
q->showMessage(msg, LogMisc);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::functionEntry(qint64 scriptId)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(scriptId)
|
2010-06-14 18:19:02 +02:00
|
|
|
q->showMessage(QString::fromLatin1("Function entry occurred on %1").arg(scriptId), LogMisc);
|
2010-01-15 17:30:26 +01:00
|
|
|
q->checkForBreakCondition(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::functionExit(qint64 scriptId, const QScriptValue &returnValue)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(scriptId)
|
|
|
|
|
Q_UNUSED(returnValue)
|
2010-01-15 17:30:26 +01:00
|
|
|
const QString msg = QString::fromLatin1("Function exit occurred on %1: '%2'").arg(scriptId).arg(returnValue.toString());
|
|
|
|
|
SDEBUG(msg);
|
2010-06-14 18:19:02 +02:00
|
|
|
q->showMessage(msg, LogMisc);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::positionChange(qint64 scriptId, int lineNumber, int columnNumber)
|
|
|
|
|
{
|
2009-04-07 11:24:00 +02:00
|
|
|
SDEBUG("ScriptAgent::position: " << lineNumber);
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(scriptId)
|
|
|
|
|
Q_UNUSED(lineNumber)
|
|
|
|
|
Q_UNUSED(columnNumber)
|
2010-01-15 17:30:26 +01:00
|
|
|
q->checkForBreakCondition(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::scriptLoad(qint64 scriptId, const QString &program,
|
|
|
|
|
const QString &fileName, int baseLineNumber)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(scriptId)
|
|
|
|
|
Q_UNUSED(program)
|
|
|
|
|
Q_UNUSED(fileName)
|
|
|
|
|
Q_UNUSED(baseLineNumber)
|
2010-06-14 18:19:02 +02:00
|
|
|
q->showMessage(QString::fromLatin1("Loaded: %1 id: %2")
|
2010-06-14 17:23:25 +02:00
|
|
|
.arg(fileName).arg(scriptId), LogMisc);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptAgent::scriptUnload(qint64 scriptId)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(scriptId)
|
2009-04-07 11:24:00 +02:00
|
|
|
SDEBUG("ScriptAgent::scriptUnload: " << scriptId);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// ScriptEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
ScriptEngine::ScriptEngine(const DebuggerStartParameters &startParameters)
|
|
|
|
|
: DebuggerEngine(startParameters)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ScriptEngine::~ScriptEngine()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::executeDebuggerCommand(const QString &command)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(command)
|
2009-04-07 13:38:19 +02:00
|
|
|
XSDEBUG("FIXME: ScriptEngine::executeDebuggerCommand()");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::shutdown()
|
|
|
|
|
{
|
2010-01-29 21:33:57 +01:00
|
|
|
exitDebugger();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::exitDebugger()
|
|
|
|
|
{
|
2010-01-15 17:30:26 +01:00
|
|
|
if (state() == DebuggerNotReady)
|
|
|
|
|
return;
|
2009-04-07 11:24:00 +02:00
|
|
|
SDEBUG("ScriptEngine::exitDebugger()");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = false;
|
2010-01-15 17:30:26 +01:00
|
|
|
if (m_scriptEngine->isEvaluating())
|
|
|
|
|
m_scriptEngine->abortEvaluation();
|
|
|
|
|
setState(InferiorShuttingDown);
|
|
|
|
|
setState(InferiorShutDown);
|
|
|
|
|
|
|
|
|
|
setState(EngineShuttingDown);
|
|
|
|
|
m_scriptEngine->setAgent(0);
|
|
|
|
|
setState(DebuggerNotReady);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-08 13:34:51 +02:00
|
|
|
void ScriptEngine::startEngine()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-07-08 13:28:22 +02:00
|
|
|
QTC_ASSERT(state() == EngineStarting, qDebug() << state());
|
2010-07-07 14:36:17 +02:00
|
|
|
showMessage(_("STARTING SCRIPT DEBUGGER"), LogMisc);
|
2010-01-15 17:30:26 +01:00
|
|
|
if (m_scriptEngine.isNull())
|
|
|
|
|
m_scriptEngine = Core::ICore::instance()->scriptManager()->scriptEngine();
|
2009-09-02 10:07:38 +02:00
|
|
|
if (!m_scriptAgent)
|
2010-01-15 17:30:26 +01:00
|
|
|
m_scriptAgent.reset(new ScriptAgent(this, m_scriptEngine.data()));
|
|
|
|
|
m_scriptEngine->setAgent(m_scriptAgent.data());
|
|
|
|
|
/* Keep the gui alive (have the engine call processEvents() while the script
|
|
|
|
|
* is run in the foreground). */
|
2009-09-02 10:07:38 +02:00
|
|
|
m_scriptEngine->setProcessEventsInterval(1 /*ms*/);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = false;
|
|
|
|
|
m_scriptEngine->abortEvaluation();
|
2009-05-26 16:27:24 +02:00
|
|
|
|
2010-07-08 11:44:00 +02:00
|
|
|
setState(EngineStarted);
|
2010-01-15 17:30:26 +01:00
|
|
|
setState(InferiorStarting);
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
m_scriptFileName = QFileInfo(startParameters().executable).absoluteFilePath();
|
2010-07-07 14:36:17 +02:00
|
|
|
showMessage(_("SCRIPT FILE: ") + m_scriptFileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
QFile scriptFile(m_scriptFileName);
|
2010-01-15 17:30:26 +01:00
|
|
|
if (!scriptFile.open(QIODevice::ReadOnly|QIODevice::Text)) {
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(QString::fromLatin1("Cannot open %1: %2").
|
2010-06-14 17:23:25 +02:00
|
|
|
arg(m_scriptFileName, scriptFile.errorString()), LogError);
|
2010-06-16 11:08:54 +02:00
|
|
|
startFailed();
|
2009-09-10 13:09:42 +02:00
|
|
|
return;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
QTextStream stream(&scriptFile);
|
|
|
|
|
m_scriptContents = stream.readAll();
|
|
|
|
|
scriptFile.close();
|
|
|
|
|
attemptBreakpointSynchronization();
|
2009-09-25 08:35:31 +02:00
|
|
|
setState(InferiorRunningRequested);
|
|
|
|
|
showStatusMessage(tr("Running requested..."), 5000);
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(QLatin1String("Running: ") + m_scriptFileName, LogMisc);
|
2009-04-07 11:24:00 +02:00
|
|
|
QTimer::singleShot(0, this, SLOT(runInferior()));
|
2010-06-16 11:08:54 +02:00
|
|
|
startSuccessful();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::continueInferior()
|
|
|
|
|
{
|
2009-04-07 11:24:00 +02:00
|
|
|
SDEBUG("ScriptEngine::continueInferior()");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = false;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
static const char *qtExtensionsC[] = {
|
|
|
|
|
"qt.core", "qt.gui", "qt.xml", "qt.svg", "qt.network",
|
|
|
|
|
"qt.sql", "qt.opengl", "qt.webkit", "qt.xmlpatterns", "qt.uitools"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool ScriptEngine::importExtensions()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-15 17:30:26 +01:00
|
|
|
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;
|
2010-01-18 12:34:59 +01:00
|
|
|
QDir dir(QLatin1String("/home/apoenitz/dev/qtscriptgenerator"));
|
|
|
|
|
if (!dir.cd(QLatin1String("plugins"))) {
|
2009-04-07 16:39:17 +02:00
|
|
|
fprintf(stderr, "plugins folder does not exist -- did you build the bindings?\n");
|
2010-01-15 17:30:26 +01:00
|
|
|
return false;
|
2009-04-07 16:39:17 +02:00
|
|
|
}
|
|
|
|
|
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.",
|
2010-01-18 12:34:59 +01:00
|
|
|
qPrintable(failExtensions.join(QLatin1String(", "))), qPrintable(dir.absolutePath()));
|
2009-04-07 16:39:17 +02:00
|
|
|
}
|
|
|
|
|
}
|
2010-01-15 17:30:26 +01:00
|
|
|
return failExtensions.isEmpty();
|
|
|
|
|
}
|
2009-04-07 16:39:17 +02:00
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
void ScriptEngine::runInferior()
|
|
|
|
|
{
|
|
|
|
|
SDEBUG("ScriptEngine::runInferior()");
|
|
|
|
|
importExtensions();
|
|
|
|
|
setState(InferiorRunning);
|
|
|
|
|
const QScriptValue result = m_scriptEngine->evaluate(m_scriptContents, m_scriptFileName);
|
|
|
|
|
setState(InferiorStopping);
|
|
|
|
|
setState(InferiorStopped);
|
2010-06-14 17:23:25 +02:00
|
|
|
QString msg;
|
2010-01-15 17:30:26 +01:00
|
|
|
if (m_scriptEngine->hasUncaughtException()) {
|
2010-06-14 17:23:25 +02:00
|
|
|
msg = QString::fromLatin1("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')));
|
2010-01-15 17:30:26 +01:00
|
|
|
} else {
|
2010-06-14 17:23:25 +02:00
|
|
|
msg = QString::fromLatin1("Evaluation returns '%1'")
|
|
|
|
|
.arg(result.toString());
|
2010-01-15 17:30:26 +01:00
|
|
|
}
|
2010-06-14 18:19:02 +02:00
|
|
|
showMessage(msg, LogMisc);
|
2010-01-15 17:30:26 +01:00
|
|
|
exitDebugger();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::interruptInferior()
|
|
|
|
|
{
|
|
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = true;
|
2009-04-07 13:38:19 +02:00
|
|
|
XSDEBUG("ScriptEngine::interruptInferior()");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeStep()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-04-07 13:38:19 +02:00
|
|
|
//SDEBUG("ScriptEngine::stepExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeStepI()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-04-07 13:38:19 +02:00
|
|
|
//SDEBUG("ScriptEngine::stepIExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeStepOut()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-04-07 13:38:19 +02:00
|
|
|
//SDEBUG("ScriptEngine::stepOutExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeNext()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-04-07 13:38:19 +02:00
|
|
|
//SDEBUG("ScriptEngine::nextExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeNextI()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-04-07 13:38:19 +02:00
|
|
|
//SDEBUG("ScriptEngine::nextIExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopped = false;
|
|
|
|
|
m_stopOnNextLine = true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeRunToLine(const QString &fileName, int lineNumber)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(fileName)
|
|
|
|
|
Q_UNUSED(lineNumber)
|
2009-04-07 11:24:00 +02:00
|
|
|
SDEBUG("FIXME: ScriptEngine::runToLineExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeRunToFunction(const QString &functionName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(functionName)
|
2009-04-07 13:38:19 +02:00
|
|
|
XSDEBUG("FIXME: ScriptEngine::runToFunctionExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-10 16:17:40 +01:00
|
|
|
void ScriptEngine::executeJumpToLine(const QString &fileName, int lineNumber)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(fileName)
|
|
|
|
|
Q_UNUSED(lineNumber)
|
2009-04-07 13:38:19 +02:00
|
|
|
XSDEBUG("FIXME: ScriptEngine::jumpToLineExec()");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::activateFrame(int index)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(index)
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::selectThread(int index)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(index)
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::attemptBreakpointSynchronization()
|
|
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
BreakHandler *handler = breakHandler();
|
2008-12-02 12:01:29 +01:00
|
|
|
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()) {
|
2010-01-05 16:51:55 +01:00
|
|
|
data->bpNumber = QByteArray::number(index + 1);
|
2008-12-02 12:01:29 +01:00
|
|
|
updateNeeded = true;
|
|
|
|
|
}
|
2010-03-26 10:29:19 +01:00
|
|
|
if (!data->fileName.isEmpty() && data->markerFileName().isEmpty()) {
|
|
|
|
|
data->setMarkerFileName(data->fileName);
|
|
|
|
|
data->setMarkerLineNumber(data->lineNumber.toInt());
|
2008-12-02 12:01:29 +01:00
|
|
|
updateNeeded = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (updateNeeded)
|
|
|
|
|
handler->updateMarkers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::loadSymbols(const QString &moduleName)
|
|
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(moduleName)
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::loadAllSymbols()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::reloadModules()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-03 19:12:52 +02:00
|
|
|
void ScriptEngine::requestModuleSymbols(const QString & /*moduleName*/)
|
2009-04-15 12:01:58 +02:00
|
|
|
{
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Tooltip specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
static WatchData m_toolTip;
|
|
|
|
|
static QPoint m_toolTipPos;
|
|
|
|
|
static QHash<QString, WatchData> m_toolTipCache;
|
|
|
|
|
|
2009-09-25 08:35:31 +02:00
|
|
|
void ScriptEngine::setToolTipExpression(const QPoint &mousePos,
|
|
|
|
|
TextEditor::ITextEditor *editor, int cursorPos)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(mousePos)
|
|
|
|
|
Q_UNUSED(editor)
|
|
|
|
|
Q_UNUSED(cursorPos)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-25 08:35:31 +02:00
|
|
|
if (state() != InferiorStopped) {
|
2009-04-07 11:24:00 +02:00
|
|
|
//SDEBUG("SUPPRESSING DEBUGGER TOOLTIP, INFERIOR NOT STOPPED");
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2009-05-14 14:29:37 +02:00
|
|
|
// Check mime type and get expression (borrowing some C++ - functions)
|
2009-09-25 08:35:31 +02:00
|
|
|
const QString javaScriptMimeType =
|
2010-01-15 17:36:49 +01:00
|
|
|
QLatin1String("application/javascript");
|
2009-05-14 14:29:37 +02:00
|
|
|
if (!editor->file() || editor->file()->mimeType() != javaScriptMimeType)
|
|
|
|
|
return;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-05-14 14:29:37 +02:00
|
|
|
int line;
|
|
|
|
|
int column;
|
|
|
|
|
QString exp = cppExpressionAt(editor, cursorPos, &line, &column);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (m_toolTipCache.contains(exp)) {
|
|
|
|
|
const WatchData & data = m_toolTipCache[exp];
|
|
|
|
|
q->watchHandler()->removeChildren(data.iname);
|
|
|
|
|
insertData(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
QToolTip::hideText();
|
2010-01-18 12:34:59 +01:00
|
|
|
if (exp.isEmpty() || exp.startsWith(QLatin1Char('#'))) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QToolTip::hideText();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!hasLetterOrNumber(exp)) {
|
2009-04-17 21:11:52 +02:00
|
|
|
QToolTip::showText(m_toolTipPos, tr("'%1' contains no identifier").arg(exp));
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:34:59 +01:00
|
|
|
if (exp.startsWith(QLatin1Char('"')) && exp.endsWith(QLatin1Char('"'))) {
|
2009-04-17 21:11:52 +02:00
|
|
|
QToolTip::showText(m_toolTipPos, tr("String literal %1").arg(exp));
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:34:59 +01:00
|
|
|
if (exp.startsWith(QLatin1String("++")) || exp.startsWith(QLatin1String("--")))
|
|
|
|
|
exp.remove(0, 2);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-18 12:34:59 +01:00
|
|
|
if (exp.endsWith(QLatin1String("++")) || exp.endsWith(QLatin1String("--")))
|
|
|
|
|
exp.remove(0, 2);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-18 12:34:59 +01:00
|
|
|
if (exp.startsWith(QLatin1Char('<')) || exp.startsWith(QLatin1Char('[')))
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (hasSideEffects(exp)) {
|
|
|
|
|
QToolTip::showText(m_toolTipPos,
|
2009-04-08 12:11:30 +02:00
|
|
|
tr("Cowardly refusing to evaluate expression '%1' "
|
|
|
|
|
"with potential side effects").arg(exp));
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
2009-09-25 08:35:31 +02:00
|
|
|
//if (m_manager->status() != InferiorStopped)
|
2008-12-02 12:01:29 +01:00
|
|
|
// 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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Watch specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::assignValueInDebugger(const QString &expression,
|
|
|
|
|
const QString &value)
|
|
|
|
|
{
|
2010-04-23 12:12:22 +02:00
|
|
|
SDEBUG("ASSIGNING: " << (expression + QLatin1Char('=') + value));
|
2010-01-18 12:34:59 +01:00
|
|
|
m_scriptEngine->evaluate(expression + QLatin1Char('=') + value);
|
2009-04-07 13:38:19 +02:00
|
|
|
updateLocals();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
static BreakpointData *findBreakPointByFunction(BreakHandler *handler,
|
|
|
|
|
const QString &functionName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-01-15 17:30:26 +01:00
|
|
|
const int count = handler->size();
|
|
|
|
|
for (int b = 0; b < count; b++) {
|
|
|
|
|
BreakpointData *data = handler->at(b);
|
|
|
|
|
if (data->funcName == functionName)
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
static BreakpointData *findBreakPointByFileName(BreakHandler *handler,
|
|
|
|
|
int lineNumber,
|
|
|
|
|
const QString &fileName)
|
|
|
|
|
{
|
|
|
|
|
const int count = handler->size();
|
|
|
|
|
for (int b = 0; b < count; b++) {
|
|
|
|
|
BreakpointData *data = handler->at(b);
|
|
|
|
|
if (lineNumber == data->lineNumber.toInt() && fileName == data->fileName)
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
bool ScriptEngine::checkForBreakCondition(bool byFunction)
|
|
|
|
|
{
|
|
|
|
|
const QScriptContext *context = m_scriptEngine->currentContext();
|
|
|
|
|
const QScriptContextInfo info(context);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-01-15 17:30:26 +01:00
|
|
|
// Update breakpoints
|
|
|
|
|
const QString functionName = info.functionName();
|
|
|
|
|
const QString fileName = info.fileName();
|
2010-07-07 13:26:32 +02:00
|
|
|
const int lineNumber = byFunction
|
|
|
|
|
? info.functionStartLineNumber() : info.lineNumber();
|
|
|
|
|
SDEBUG("checkForBreakCondition" << byFunction << functionName
|
|
|
|
|
<< lineNumber << fileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (m_stopOnNextLine) {
|
2010-01-15 17:30:26 +01:00
|
|
|
// Interrupt inferior
|
2008-12-02 12:01:29 +01:00
|
|
|
m_stopOnNextLine = false;
|
|
|
|
|
} else {
|
2010-01-15 17:30:26 +01:00
|
|
|
if (byFunction && functionName.isEmpty())
|
|
|
|
|
return false;
|
|
|
|
|
BreakpointData *data = byFunction ?
|
2010-06-16 11:08:54 +02:00
|
|
|
findBreakPointByFunction(breakHandler(), functionName) :
|
|
|
|
|
findBreakPointByFileName(breakHandler(), lineNumber, fileName);
|
2010-01-15 17:30:26 +01:00
|
|
|
if (!data)
|
|
|
|
|
return false;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-07-07 13:26:32 +02:00
|
|
|
// Skip disabled breakpoint.
|
|
|
|
|
if (!data->enabled)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
// We just run into a breakpoint.
|
2009-04-07 11:24:00 +02:00
|
|
|
//SDEBUG("RESOLVING BREAKPOINT AT " << fileName << lineNumber);
|
2010-01-05 16:51:55 +01:00
|
|
|
data->bpLineNumber = QByteArray::number(lineNumber);
|
2008-12-02 12:01:29 +01:00
|
|
|
data->bpFileName = fileName;
|
|
|
|
|
data->bpFuncName = functionName;
|
2010-03-26 10:29:19 +01:00
|
|
|
data->setMarkerLineNumber(lineNumber);
|
|
|
|
|
data->setMarkerFileName(fileName);
|
2008-12-02 12:01:29 +01:00
|
|
|
data->pending = false;
|
|
|
|
|
data->updateMarker();
|
|
|
|
|
}
|
2010-01-15 17:30:26 +01:00
|
|
|
setState(InferiorStopping);
|
2009-09-25 08:35:31 +02:00
|
|
|
setState(InferiorStopped);
|
2010-01-15 17:30:26 +01:00
|
|
|
SDEBUG("Stopped at " << lineNumber << fileName);
|
|
|
|
|
showStatusMessage(tr("Stopped at %1:%2.").arg(fileName).arg(lineNumber), 5000);
|
2009-09-25 08:35:31 +02:00
|
|
|
|
2009-08-14 13:04:05 +02:00
|
|
|
StackFrame frame;
|
2010-01-29 21:33:57 +01:00
|
|
|
frame.file = fileName;
|
2009-08-14 13:04:05 +02:00
|
|
|
frame.line = lineNumber;
|
2010-06-16 11:08:54 +02:00
|
|
|
gotoLocation(frame, true);
|
2009-04-07 13:38:19 +02:00
|
|
|
updateLocals();
|
2010-01-15 17:30:26 +01:00
|
|
|
return true;
|
2009-04-07 13:38:19 +02:00
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-04-07 13:38:19 +02:00
|
|
|
void ScriptEngine::updateLocals()
|
|
|
|
|
{
|
|
|
|
|
QScriptContext *context = m_scriptEngine->currentContext();
|
2010-06-16 11:08:54 +02:00
|
|
|
watchHandler()->beginCycle();
|
2009-04-07 11:24:00 +02:00
|
|
|
//SDEBUG("UPDATE LOCALS");
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// Build stack
|
2010-01-29 21:33:57 +01:00
|
|
|
//
|
2008-12-02 12:01:29 +01:00
|
|
|
QList<StackFrame> stackFrames;
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (QScriptContext *c = context; c; c = c->parentContext(), ++i) {
|
2010-01-15 17:30:26 +01:00
|
|
|
const QScriptContextInfo info(c);
|
2008-12-02 12:01:29 +01:00
|
|
|
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())
|
2010-01-15 17:30:26 +01:00
|
|
|
frame.function = QLatin1String("<global scope>");
|
2008-12-02 12:01:29 +01:00
|
|
|
//frame.address = ...;
|
|
|
|
|
stackFrames.append(frame);
|
|
|
|
|
}
|
2010-06-16 11:08:54 +02:00
|
|
|
stackHandler()->setFrames(stackFrames);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
//
|
2010-01-18 12:34:59 +01:00
|
|
|
// Build locals, deactivate agent meanwhile.
|
2008-12-02 12:01:29 +01:00
|
|
|
//
|
2010-01-18 12:34:59 +01:00
|
|
|
m_scriptEngine->setAgent(0);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
WatchData data;
|
|
|
|
|
data.iname = "local";
|
2010-01-18 12:34:59 +01:00
|
|
|
data.name = QString::fromLatin1(data.iname);
|
2008-12-02 12:01:29 +01:00
|
|
|
data.scriptValue = context->activationObject();
|
2010-06-16 11:08:54 +02:00
|
|
|
watchHandler()->beginCycle();
|
2009-09-02 13:19:47 +02:00
|
|
|
updateSubItem(data);
|
2010-06-16 11:08:54 +02:00
|
|
|
watchHandler()->endCycle();
|
2008-12-02 12:01:29 +01:00
|
|
|
// FIXME: Use an extra thread. This here is evil
|
|
|
|
|
m_stopped = true;
|
2009-09-25 08:35:31 +02:00
|
|
|
showStatusMessage(tr("Stopped."), 5000);
|
2008-12-02 12:01:29 +01:00
|
|
|
while (m_stopped) {
|
2009-04-07 11:24:00 +02:00
|
|
|
//SDEBUG("LOOPING");
|
2008-12-02 12:01:29 +01:00
|
|
|
QApplication::processEvents();
|
|
|
|
|
}
|
2010-01-18 12:34:59 +01:00
|
|
|
setState(InferiorRunningRequested);
|
|
|
|
|
setState(InferiorRunning);
|
|
|
|
|
// Clear any exceptions occurred during locals evaluation.
|
|
|
|
|
m_scriptEngine->clearExceptions();
|
|
|
|
|
m_scriptEngine->setAgent(m_scriptAgent.data());
|
|
|
|
|
SDEBUG("Continuing");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-06-17 16:00:03 +02:00
|
|
|
void ScriptEngine::updateWatchData(const WatchData &data)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-06-17 16:00:03 +02:00
|
|
|
updateSubItem(data);
|
2010-01-18 12:34:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ScriptEngine::updateSubItem(const WatchData &data0)
|
|
|
|
|
{
|
|
|
|
|
WatchData data = data0;
|
2010-01-18 12:34:59 +01:00
|
|
|
QList<WatchData> children;
|
|
|
|
|
SDEBUG("\nUPDATE SUBITEM: " << data.toString() << data.scriptValue.toString());
|
2008-12-09 12:08:56 +01:00
|
|
|
QTC_ASSERT(data.isValid(), return);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (data.isTypeNeeded() || data.isValueNeeded()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
const QScriptValue &ob = data.scriptValue;
|
2008-12-02 12:01:29 +01:00
|
|
|
if (ob.isArray()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Array"), false);
|
|
|
|
|
data.setValue(QString(QLatin1Char(' ')));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isBool()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Bool"), false);
|
|
|
|
|
data.setValue(ob.toBool() ? QLatin1String("true") : QLatin1String("false"));
|
2009-06-22 11:35:08 +02:00
|
|
|
data.setHasChildren(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isDate()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Date"), false);
|
|
|
|
|
data.setValue(ob.toDateTime().toString());
|
2009-06-22 11:35:08 +02:00
|
|
|
data.setHasChildren(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isError()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Error"), false);
|
|
|
|
|
data.setValue(QString(QLatin1Char(' ')));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isFunction()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Function"), false);
|
|
|
|
|
data.setValue(QString(QLatin1Char(' ')));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isNull()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
const QString nullValue = QLatin1String("<null>");
|
|
|
|
|
data.setType(nullValue, false);
|
|
|
|
|
data.setValue(nullValue);
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isNumber()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Number"), false);
|
|
|
|
|
data.setValue(QString::number(ob.toNumber()));
|
2009-06-22 11:35:08 +02:00
|
|
|
data.setHasChildren(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isObject()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Object"), false);
|
|
|
|
|
data.setValue(QString(QLatin1Char(' ')));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isQMetaObject()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("QMetaObject"), false);
|
|
|
|
|
data.setValue(QString(QLatin1Char(' ')));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isQObject()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("QObject"), false);
|
|
|
|
|
data.setValue(QString(QLatin1Char(' ')));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isRegExp()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("RegExp"), false);
|
|
|
|
|
data.setValue(ob.toRegExp().pattern());
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isString()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("String"), false);
|
|
|
|
|
data.setValue(ob.toString());
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isVariant()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("Variant"), false);
|
|
|
|
|
data.setValue(QString(QLatin1Char(' ')));
|
2008-12-02 12:01:29 +01:00
|
|
|
} else if (ob.isUndefined()) {
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setType(QLatin1String("<undefined>"), false);
|
|
|
|
|
data.setValue(QLatin1String("<unknown>"));
|
2009-09-02 13:19:47 +02:00
|
|
|
data.setHasChildren(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
} else {
|
2010-01-18 12:34:59 +01:00
|
|
|
const QString unknown = QLatin1String("<unknown>");
|
|
|
|
|
data.setType(unknown, false);
|
|
|
|
|
data.setValue(unknown);
|
2009-09-02 13:19:47 +02:00
|
|
|
data.setHasChildren(false);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (data.isChildrenNeeded()) {
|
|
|
|
|
QScriptValueIterator it(data.scriptValue);
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
it.next();
|
|
|
|
|
WatchData data1;
|
2010-01-18 12:34:59 +01:00
|
|
|
data1.iname = data.iname + '.' + it.name().toLatin1();
|
2010-01-05 16:51:55 +01:00
|
|
|
data1.exp = it.name().toLatin1();
|
2008-12-02 12:01:29 +01:00
|
|
|
data1.name = it.name();
|
|
|
|
|
data1.scriptValue = it.value();
|
2010-06-16 11:08:54 +02:00
|
|
|
if (watchHandler()->isExpandedIName(data1.iname)) {
|
2008-12-02 12:01:29 +01:00
|
|
|
data1.setChildrenNeeded();
|
2010-01-18 12:34:59 +01:00
|
|
|
} else {
|
2008-12-02 12:01:29 +01:00
|
|
|
data1.setChildrenUnneeded();
|
2010-01-18 12:34:59 +01:00
|
|
|
}
|
|
|
|
|
children.push_back(data1);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setHasChildren(!children.isEmpty());
|
2008-12-02 12:01:29 +01:00
|
|
|
data.setChildrenUnneeded();
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-22 11:35:08 +02:00
|
|
|
if (data.isHasChildrenNeeded()) {
|
2008-12-02 12:01:29 +01:00
|
|
|
QScriptValueIterator it(data.scriptValue);
|
2010-01-18 12:34:59 +01:00
|
|
|
data.setHasChildren(it.hasNext());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-18 12:34:59 +01:00
|
|
|
SDEBUG(msgDebugInsert(data, children));
|
2010-06-16 11:08:54 +02:00
|
|
|
watchHandler()->insertData(data);
|
2010-01-18 12:34:59 +01:00
|
|
|
if (!children.isEmpty())
|
2010-06-16 11:08:54 +02:00
|
|
|
watchHandler()->insertBulkData(children);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
DebuggerEngine *createScriptEngine(const DebuggerStartParameters &sp)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-06-16 11:08:54 +02:00
|
|
|
return new ScriptEngine(sp);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-09-23 10:45:32 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|