2010-06-09 16:13:47 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmlengine.h"
|
2010-08-13 14:18:10 +02:00
|
|
|
#include "qmladapter.h"
|
2010-06-09 16:13:47 +02:00
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerconstants.h"
|
2010-07-01 11:48:43 +02:00
|
|
|
#include "debuggerplugin.h"
|
2010-06-09 16:13:47 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2010-07-23 15:26:58 +02:00
|
|
|
#include "debuggeruiswitcher.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
#include "breakhandler.h"
|
|
|
|
|
#include "moduleshandler.h"
|
|
|
|
|
#include "registerhandler.h"
|
|
|
|
|
#include "stackhandler.h"
|
|
|
|
|
#include "watchhandler.h"
|
|
|
|
|
#include "watchutils.h"
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2010-07-01 11:48:43 +02:00
|
|
|
#include <projectexplorer/environment.h>
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QDateTime>
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QDir>
|
|
|
|
|
#include <QtCore/QFileInfo>
|
|
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QApplication>
|
|
|
|
|
#include <QtGui/QMainWindow>
|
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
#include <QtGui/QToolTip>
|
2010-07-23 18:40:12 +02:00
|
|
|
#include <QtGui/QTextDocument>
|
2010-06-09 16:13:47 +02:00
|
|
|
|
|
|
|
|
#include <QtNetwork/QTcpSocket>
|
2010-07-01 11:48:43 +02:00
|
|
|
#include <QtNetwork/QHostAddress>
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
#define DEBUG_QML 1
|
|
|
|
|
#if DEBUG_QML
|
|
|
|
|
# define SDEBUG(s) qDebug() << s
|
|
|
|
|
#else
|
|
|
|
|
# define SDEBUG(s)
|
|
|
|
|
#endif
|
|
|
|
|
# define XSDEBUG(s) qDebug() << s
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
enum {
|
|
|
|
|
MaxConnectionAttempts = 50,
|
2010-08-16 14:19:55 +02:00
|
|
|
ConnectionAttemptDefaultInterval = 200
|
2010-08-13 14:18:10 +02:00
|
|
|
};
|
2010-07-23 18:40:12 +02:00
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-07-22 13:00:26 +02:00
|
|
|
QDataStream& operator>>(QDataStream& s, WatchData &data)
|
|
|
|
|
{
|
|
|
|
|
data = WatchData();
|
|
|
|
|
QString value;
|
|
|
|
|
QString type;
|
|
|
|
|
bool hasChildren;
|
2010-07-22 14:58:37 +02:00
|
|
|
s >> data.exp >> data.name >> value >> type >> hasChildren >> data.objectId;
|
2010-07-22 13:00:26 +02:00
|
|
|
data.setType(type, false);
|
|
|
|
|
data.setValue(value);
|
|
|
|
|
data.setHasChildren(hasChildren);
|
2010-07-22 14:58:37 +02:00
|
|
|
data.setAllUnneeded();
|
2010-07-22 13:00:26 +02:00
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// QmlEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2010-06-16 11:08:54 +02:00
|
|
|
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters)
|
2010-08-13 14:18:10 +02:00
|
|
|
: DebuggerEngine(startParameters)
|
|
|
|
|
, m_ping(0)
|
|
|
|
|
, m_adapter(new QmlAdapter(this))
|
|
|
|
|
, m_addedAdapterToObjectPool(false)
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2010-08-24 15:35:46 +02:00
|
|
|
setObjectName(QLatin1String("QmlEngine"));
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlEngine::~QmlEngine()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
void QmlEngine::setupInferior()
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == InferiorSetupRequested, qDebug() << state());
|
2010-08-13 14:18:10 +02:00
|
|
|
|
|
|
|
|
connect(&m_applicationLauncher, SIGNAL(processExited(int)), SLOT(disconnected()));
|
|
|
|
|
m_applicationLauncher.setEnvironment(startParameters().environment);
|
|
|
|
|
m_applicationLauncher.setWorkingDirectory(startParameters().workingDirectory);
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
notifyInferiorSetupOk();
|
|
|
|
|
}
|
2010-07-05 11:28:38 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void QmlEngine::connectionEstablished()
|
|
|
|
|
{
|
|
|
|
|
attemptBreakpointSynchronization();
|
|
|
|
|
|
|
|
|
|
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
pluginManager->addObject(m_adapter);
|
|
|
|
|
m_addedAdapterToObjectPool = true;
|
|
|
|
|
|
|
|
|
|
plugin()->showMessage(tr("QML Debugger connected."), StatusBar);
|
|
|
|
|
|
|
|
|
|
notifyEngineRunAndInferiorRunOk();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::connectionStartupFailed()
|
|
|
|
|
{
|
|
|
|
|
QMessageBox::critical(0,
|
|
|
|
|
tr("Failed to connect to debugger"),
|
|
|
|
|
tr("Could not connect to debugger server.") );
|
|
|
|
|
notifyEngineRunFailed();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::connectionError()
|
|
|
|
|
{
|
|
|
|
|
// do nothing for now - only exit the debugger when inferior exits.
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
void QmlEngine::runEngine()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == EngineRunRequested, qDebug() << state());
|
2010-08-13 14:18:10 +02:00
|
|
|
|
|
|
|
|
// ### TODO for non-qmlproject apps, start in a different way
|
|
|
|
|
m_applicationLauncher.start(ProjectExplorer::ApplicationLauncher::Gui,
|
|
|
|
|
startParameters().executable,
|
|
|
|
|
startParameters().processArgs);
|
|
|
|
|
|
|
|
|
|
m_adapter->beginConnection();
|
|
|
|
|
plugin()->showMessage(tr("QML Debugger connecting..."), StatusBar);
|
2010-08-18 12:26:13 +02:00
|
|
|
|
|
|
|
|
// FIXME: refactor the UI
|
|
|
|
|
Debugger::DebuggerUISwitcher::instance()->setActiveLanguage("QML");
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
void QmlEngine::shutdownInferior()
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2010-07-09 17:07:59 +02:00
|
|
|
QTC_ASSERT(state() == InferiorShutdownRequested, qDebug() << state());
|
2010-08-13 14:18:10 +02:00
|
|
|
if (!m_applicationLauncher.isRunning()) {
|
|
|
|
|
showMessage(tr("Trying to stop while process is no longer running."), LogError);
|
|
|
|
|
} else {
|
|
|
|
|
disconnect(&m_applicationLauncher, SIGNAL(processExited(int)), this, SLOT(disconnected()));
|
|
|
|
|
m_applicationLauncher.stop();
|
|
|
|
|
}
|
2010-07-09 17:07:59 +02:00
|
|
|
notifyInferiorShutdownOk();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::shutdownEngine()
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(state() == EngineShutdownRequested, qDebug() << state());
|
2010-08-13 14:18:10 +02:00
|
|
|
|
|
|
|
|
if (m_addedAdapterToObjectPool) {
|
|
|
|
|
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
pluginManager->removeObject(m_adapter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (m_applicationLauncher.isRunning()) {
|
|
|
|
|
// should only happen if engine is ill
|
|
|
|
|
disconnect(&m_applicationLauncher, SIGNAL(processExited(int)), this, SLOT(disconnected()));
|
|
|
|
|
m_applicationLauncher.stop();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:42:44 +02:00
|
|
|
notifyEngineShutdownOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-08 18:10:50 +02:00
|
|
|
void QmlEngine::setupEngine()
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
m_adapter->setMaxConnectionAttempts(MaxConnectionAttempts);
|
|
|
|
|
m_adapter->setConnectionAttemptInterval(ConnectionAttemptDefaultInterval);
|
|
|
|
|
connect(m_adapter, SIGNAL(connectionError()), SLOT(connectionError()));
|
|
|
|
|
connect(m_adapter, SIGNAL(connected()), SLOT(connectionEstablished()));
|
|
|
|
|
connect(m_adapter, SIGNAL(connectionStartupFailed()), SLOT(connectionStartupFailed()));
|
|
|
|
|
|
2010-07-09 08:48:33 +02:00
|
|
|
notifyEngineSetupOk();
|
2010-07-01 11:48:43 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
void QmlEngine::continueInferior()
|
|
|
|
|
{
|
2010-07-13 08:41:27 +02:00
|
|
|
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("CONTINUE");
|
|
|
|
|
sendMessage(reply);
|
2010-07-22 15:31:11 +02:00
|
|
|
resetLocation();
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::interruptInferior()
|
|
|
|
|
{
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("INTERRUPT");
|
|
|
|
|
sendMessage(reply);
|
2010-08-04 17:13:17 +02:00
|
|
|
notifyInferiorStopOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStep()
|
|
|
|
|
{
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("STEPINTO");
|
|
|
|
|
sendMessage(reply);
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStepI()
|
|
|
|
|
{
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("STEPINTO");
|
|
|
|
|
sendMessage(reply);
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStepOut()
|
|
|
|
|
{
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("STEPOUT");
|
|
|
|
|
sendMessage(reply);
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeNext()
|
|
|
|
|
{
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("STEPOVER");
|
|
|
|
|
sendMessage(reply);
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeNextI()
|
|
|
|
|
{
|
2010-06-25 14:08:53 +02:00
|
|
|
SDEBUG("QmlEngine::executeNextI()");
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeRunToLine(const QString &fileName, int lineNumber)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(fileName)
|
|
|
|
|
Q_UNUSED(lineNumber)
|
|
|
|
|
SDEBUG("FIXME: QmlEngine::executeRunToLine()");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeRunToFunction(const QString &functionName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(functionName)
|
|
|
|
|
XSDEBUG("FIXME: QmlEngine::executeRunToFunction()");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeJumpToLine(const QString &fileName, int lineNumber)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(fileName)
|
|
|
|
|
Q_UNUSED(lineNumber)
|
|
|
|
|
XSDEBUG("FIXME: QmlEngine::executeJumpToLine()");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::activateFrame(int index)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(index)
|
2010-07-22 15:22:46 +02:00
|
|
|
|
|
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("ACTIVATE_FRAME");
|
|
|
|
|
rs << index;
|
|
|
|
|
sendMessage(reply);
|
|
|
|
|
|
2010-06-25 14:08:53 +02:00
|
|
|
gotoLocation(stackHandler()->frames().value(index), true);
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::selectThread(int index)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::attemptBreakpointSynchronization()
|
|
|
|
|
{
|
2010-06-25 14:08:53 +02:00
|
|
|
BreakHandler *handler = breakHandler();
|
|
|
|
|
//bool updateNeeded = false;
|
|
|
|
|
QSet< QPair<QString, qint32> > breakList;
|
|
|
|
|
for (int index = 0; index != handler->size(); ++index) {
|
|
|
|
|
BreakpointData *data = handler->at(index);
|
|
|
|
|
breakList << qMakePair(data->fileName, data->lineNumber.toInt());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("BREAKPOINTS");
|
|
|
|
|
rs << breakList;
|
|
|
|
|
//qDebug() << Q_FUNC_INFO << breakList;
|
|
|
|
|
sendMessage(reply);
|
|
|
|
|
}
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::loadSymbols(const QString &moduleName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(moduleName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::loadAllSymbols()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::reloadModules()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::requestModuleSymbols(const QString &moduleName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(moduleName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Tooltip specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
static WatchData m_toolTip;
|
|
|
|
|
static QPoint m_toolTipPos;
|
|
|
|
|
static QHash<QString, WatchData> m_toolTipCache;
|
|
|
|
|
|
|
|
|
|
void QmlEngine::setToolTipExpression(const QPoint &mousePos, TextEditor::ITextEditor *editor, int cursorPos)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(mousePos)
|
|
|
|
|
Q_UNUSED(editor)
|
|
|
|
|
Q_UNUSED(cursorPos)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Watch specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void QmlEngine::assignValueInDebugger(const QString &expression,
|
|
|
|
|
const QString &value)
|
|
|
|
|
{
|
2010-07-22 19:06:26 +02:00
|
|
|
QRegExp inObject("@([0-9a-fA-F]+)->(.+)");
|
|
|
|
|
if (inObject.exactMatch(expression)) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
quint64 objectId = inObject.cap(1).toULongLong(&ok, 16);
|
|
|
|
|
QString property = inObject.cap(2);
|
|
|
|
|
if (ok && objectId > 0 && !property.isEmpty()) {
|
|
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("SET_PROPERTY");
|
|
|
|
|
rs << expression.toUtf8() << objectId << property << value;
|
|
|
|
|
sendMessage(reply);
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-25 14:08:53 +02:00
|
|
|
void QmlEngine::updateWatchData(const WatchData &data)
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2010-07-22 15:32:39 +02:00
|
|
|
// qDebug() << "UPDATE WATCH DATA" << data.toString();
|
2010-06-16 11:08:54 +02:00
|
|
|
//watchHandler()->rebuildModel();
|
2010-06-09 16:13:47 +02:00
|
|
|
showStatusMessage(tr("Stopped."), 5000);
|
2010-06-25 14:08:53 +02:00
|
|
|
|
2010-07-22 14:58:37 +02:00
|
|
|
if (!data.name.isEmpty() && data.isValueNeeded()) {
|
2010-06-25 14:08:53 +02:00
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("EXEC");
|
|
|
|
|
rs << data.iname << data.name;
|
|
|
|
|
sendMessage(reply);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-11 10:46:45 +02:00
|
|
|
if (!data.name.isEmpty() && data.isChildrenNeeded()
|
|
|
|
|
&& watchHandler()->isExpandedIName(data.iname))
|
2010-07-22 14:58:37 +02:00
|
|
|
expandObject(data.iname, data.objectId);
|
|
|
|
|
|
2010-06-25 14:08:53 +02:00
|
|
|
{
|
|
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("WATCH_EXPRESSIONS");
|
|
|
|
|
rs << watchHandler()->watchedExpressions();
|
|
|
|
|
sendMessage(reply);
|
|
|
|
|
}
|
2010-07-22 17:15:18 +02:00
|
|
|
|
|
|
|
|
if (!data.isSomethingNeeded())
|
|
|
|
|
watchHandler()->insertData(data);
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-22 14:58:37 +02:00
|
|
|
void QmlEngine::expandObject(const QByteArray& iname, quint64 objectId)
|
|
|
|
|
{
|
|
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("EXPAND");
|
|
|
|
|
rs << iname << objectId;
|
|
|
|
|
sendMessage(reply);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 11:30:07 +02:00
|
|
|
void QmlEngine::sendPing()
|
|
|
|
|
{
|
|
|
|
|
m_ping++;
|
|
|
|
|
QByteArray reply;
|
|
|
|
|
QDataStream rs(&reply, QIODevice::WriteOnly);
|
|
|
|
|
rs << QByteArray("PING");
|
|
|
|
|
rs << m_ping;
|
|
|
|
|
sendMessage(reply);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 11:44:29 +02:00
|
|
|
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp)
|
|
|
|
|
{
|
|
|
|
|
return new QmlEngine(sp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned QmlEngine::debuggerCapabilities() const
|
|
|
|
|
{
|
|
|
|
|
return AddWatcherCapability;
|
|
|
|
|
/*ReverseSteppingCapability | SnapshotCapability
|
|
|
|
|
| AutoDerefPointersCapability | DisassemblerCapability
|
|
|
|
|
| RegisterCapability | ShowMemoryCapability
|
|
|
|
|
| JumpToLineCapability | ReloadModuleCapability
|
|
|
|
|
| ReloadModuleSymbolsCapability | BreakOnThrowAndCatchCapability
|
|
|
|
|
| ReturnFromFunctionCapability
|
|
|
|
|
| CreateFullBacktraceCapability
|
|
|
|
|
| WatchpointCapability
|
|
|
|
|
| AddWatcherCapability;*/
|
2010-06-25 14:08:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::messageReceived(const QByteArray &message)
|
|
|
|
|
{
|
|
|
|
|
QByteArray rwData = message;
|
|
|
|
|
QDataStream stream(&rwData, QIODevice::ReadOnly);
|
|
|
|
|
|
|
|
|
|
QByteArray command;
|
|
|
|
|
stream >> command;
|
|
|
|
|
|
2010-07-07 16:40:24 +02:00
|
|
|
showMessage(_("RECEIVED RESPONSE: ") + quoteUnprintableLatin1(message));
|
2010-07-02 17:03:25 +02:00
|
|
|
if (command == "STOPPED") {
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorSpontaneousStop();
|
2010-07-02 17:03:25 +02:00
|
|
|
|
2010-06-25 14:08:53 +02:00
|
|
|
QList<QPair<QString, QPair<QString, qint32> > > backtrace;
|
2010-07-22 13:00:26 +02:00
|
|
|
QList<WatchData> watches;
|
|
|
|
|
QList<WatchData> locals;
|
2010-07-16 11:44:29 +02:00
|
|
|
stream >> backtrace >> watches >> locals;
|
2010-06-25 14:08:53 +02:00
|
|
|
|
2010-07-02 17:03:25 +02:00
|
|
|
StackFrames stackFrames;
|
2010-06-25 14:08:53 +02:00
|
|
|
typedef QPair<QString, QPair<QString, qint32> > Iterator;
|
|
|
|
|
foreach (const Iterator &it, backtrace) {
|
|
|
|
|
StackFrame frame;
|
|
|
|
|
frame.file = it.second.first;
|
|
|
|
|
frame.line = it.second.second;
|
|
|
|
|
frame.function = it.first;
|
2010-07-02 17:03:25 +02:00
|
|
|
stackFrames.append(frame);
|
2010-06-25 14:08:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gotoLocation(stackFrames.value(0), true);
|
|
|
|
|
stackHandler()->setFrames(stackFrames);
|
|
|
|
|
|
|
|
|
|
watchHandler()->beginCycle();
|
2010-07-23 11:30:07 +02:00
|
|
|
bool needPing = false;
|
2010-06-25 14:08:53 +02:00
|
|
|
|
2010-07-22 13:00:26 +02:00
|
|
|
foreach (WatchData data, watches) {
|
2010-06-25 14:08:53 +02:00
|
|
|
data.iname = watchHandler()->watcherName(data.exp);
|
2010-07-22 13:00:26 +02:00
|
|
|
watchHandler()->insertData(data);
|
2010-07-22 14:58:37 +02:00
|
|
|
|
2010-07-23 11:30:07 +02:00
|
|
|
if (watchHandler()->expandedINames().contains(data.iname)) {
|
|
|
|
|
needPing = true;
|
2010-07-22 14:58:37 +02:00
|
|
|
expandObject(data.iname, data.objectId);
|
2010-07-23 11:30:07 +02:00
|
|
|
}
|
2010-06-25 14:08:53 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-22 13:00:26 +02:00
|
|
|
foreach (WatchData data, locals) {
|
|
|
|
|
data.iname = "local." + data.exp;
|
|
|
|
|
watchHandler()->insertData(data);
|
2010-07-22 14:58:37 +02:00
|
|
|
|
2010-07-23 11:30:07 +02:00
|
|
|
if (watchHandler()->expandedINames().contains(data.iname)) {
|
|
|
|
|
needPing = true;
|
2010-07-22 14:58:37 +02:00
|
|
|
expandObject(data.iname, data.objectId);
|
2010-07-23 11:30:07 +02:00
|
|
|
}
|
2010-07-05 11:28:38 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-23 11:30:07 +02:00
|
|
|
if (needPing)
|
|
|
|
|
sendPing();
|
|
|
|
|
else
|
|
|
|
|
watchHandler()->endCycle();
|
2010-07-16 11:44:29 +02:00
|
|
|
|
2010-08-11 10:46:45 +02:00
|
|
|
// Ensure we got the right ui right now.
|
|
|
|
|
Debugger::DebuggerUISwitcher *uiSwitcher
|
|
|
|
|
= Debugger::DebuggerUISwitcher::instance();
|
2010-07-23 15:26:58 +02:00
|
|
|
uiSwitcher->setActiveLanguage("C++");
|
|
|
|
|
|
2010-07-23 18:40:12 +02:00
|
|
|
bool becauseOfexception;
|
|
|
|
|
stream >> becauseOfexception;
|
|
|
|
|
if (becauseOfexception) {
|
|
|
|
|
QString error;
|
|
|
|
|
stream >> error;
|
|
|
|
|
|
2010-08-11 10:46:45 +02:00
|
|
|
QString msg =
|
|
|
|
|
tr("<p>An Uncaught Exception occured in <i>%1</i>:</p><p>%2</p>")
|
|
|
|
|
.arg(stackFrames.value(0).file, Qt::escape(error));
|
2010-07-23 18:40:12 +02:00
|
|
|
showMessageBox(QMessageBox::Information, tr("Uncaught Exception"), msg);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-23 15:26:58 +02:00
|
|
|
|
2010-06-25 14:08:53 +02:00
|
|
|
} else if (command == "RESULT") {
|
|
|
|
|
WatchData data;
|
2010-07-22 13:00:26 +02:00
|
|
|
QByteArray iname;
|
|
|
|
|
stream >> iname >> data;
|
|
|
|
|
data.iname = iname;
|
2010-06-25 14:08:53 +02:00
|
|
|
watchHandler()->insertData(data);
|
2010-07-22 14:58:37 +02:00
|
|
|
|
|
|
|
|
} else if (command == "EXPANDED") {
|
|
|
|
|
QList<WatchData> result;
|
|
|
|
|
QByteArray iname;
|
|
|
|
|
stream >> iname >> result;
|
2010-07-23 11:30:07 +02:00
|
|
|
bool needPing = false;
|
2010-07-22 14:58:37 +02:00
|
|
|
foreach (WatchData data, result) {
|
|
|
|
|
data.iname = iname + '.' + data.exp;
|
|
|
|
|
watchHandler()->insertData(data);
|
|
|
|
|
|
2010-07-23 11:30:07 +02:00
|
|
|
if (watchHandler()->expandedINames().contains(data.iname)) {
|
|
|
|
|
needPing = true;
|
2010-07-22 14:58:37 +02:00
|
|
|
expandObject(data.iname, data.objectId);
|
2010-07-23 11:30:07 +02:00
|
|
|
}
|
2010-07-22 14:58:37 +02:00
|
|
|
}
|
2010-07-23 11:30:07 +02:00
|
|
|
if (needPing)
|
|
|
|
|
sendPing();
|
2010-07-22 15:22:46 +02:00
|
|
|
} else if (command == "LOCALS") {
|
|
|
|
|
QList<WatchData> locals;
|
|
|
|
|
int frameId;
|
|
|
|
|
stream >> frameId >> locals;
|
|
|
|
|
watchHandler()->beginCycle();
|
2010-07-23 11:30:07 +02:00
|
|
|
bool needPing = false;
|
2010-07-22 15:22:46 +02:00
|
|
|
foreach (WatchData data, locals) {
|
|
|
|
|
data.iname = "local." + data.exp;
|
|
|
|
|
watchHandler()->insertData(data);
|
2010-07-23 11:30:07 +02:00
|
|
|
if (watchHandler()->expandedINames().contains(data.iname)) {
|
|
|
|
|
needPing = true;
|
2010-07-22 15:22:46 +02:00
|
|
|
expandObject(data.iname, data.objectId);
|
2010-07-23 11:30:07 +02:00
|
|
|
}
|
2010-07-22 15:22:46 +02:00
|
|
|
}
|
2010-07-23 11:30:07 +02:00
|
|
|
if (needPing)
|
|
|
|
|
sendPing();
|
|
|
|
|
else
|
|
|
|
|
watchHandler()->endCycle();
|
|
|
|
|
|
|
|
|
|
} else if (command == "PONG") {
|
|
|
|
|
int ping;
|
|
|
|
|
stream >> ping;
|
|
|
|
|
if (ping == m_ping)
|
|
|
|
|
watchHandler()->endCycle();
|
2010-06-25 14:08:53 +02:00
|
|
|
} else {
|
|
|
|
|
qDebug() << Q_FUNC_INFO << "Unknown command: " << command;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:42:44 +02:00
|
|
|
void QmlEngine::disconnected()
|
|
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
plugin()->showMessage(tr("QML Debugger disconnected."), StatusBar);
|
2010-08-10 14:42:44 +02:00
|
|
|
notifyInferiorExited();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Debugger
|
2010-07-01 11:48:43 +02:00
|
|
|
|