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).
|
|
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-06-09 16:13:47 +02:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** 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.
|
2010-06-09 16:13:47 +02:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
2011-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-06-09 16:13:47 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmlengine.h"
|
2010-08-13 14:18:10 +02:00
|
|
|
#include "qmladapter.h"
|
2010-06-09 16:13:47 +02:00
|
|
|
|
2011-01-10 10:14:23 +01:00
|
|
|
#include "debuggerstartparameters.h"
|
2010-09-28 17:26:27 +02:00
|
|
|
#include "debuggeractions.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerconstants.h"
|
2010-11-10 16:33:11 +01:00
|
|
|
#include "debuggercore.h"
|
2010-06-09 16:13:47 +02:00
|
|
|
#include "debuggerdialogs.h"
|
2011-11-30 15:23:02 +01:00
|
|
|
#include "debuggerinternalconstants.h"
|
2010-12-02 17:43:14 +01:00
|
|
|
#include "debuggermainwindow.h"
|
2010-11-10 16:33:11 +01:00
|
|
|
#include "debuggerrunner.h"
|
2010-06-16 11:08:54 +02:00
|
|
|
#include "debuggerstringutils.h"
|
2011-02-11 15:00:13 +01:00
|
|
|
#include "debuggertooltipmanager.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"
|
2011-11-30 15:23:02 +01:00
|
|
|
#include "sourcefileshandler.h"
|
2010-06-09 16:13:47 +02:00
|
|
|
#include "watchutils.h"
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2010-09-13 13:30:35 +02:00
|
|
|
#include <projectexplorer/applicationlauncher.h>
|
2011-10-31 16:42:31 +01:00
|
|
|
#include <qmljsdebugclient/qdeclarativeoutputparser.h>
|
2011-11-30 15:23:02 +01:00
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
2010-07-01 11:48:43 +02:00
|
|
|
|
2010-09-23 10:35:23 +02:00
|
|
|
#include <utils/environment.h>
|
2010-06-09 16:13:47 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2011-02-25 11:57:34 +01:00
|
|
|
#include <utils/fileinprojectfinder.h>
|
2010-06-09 16:13:47 +02:00
|
|
|
|
2011-11-30 15:23:02 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2011-02-16 14:35:26 +01:00
|
|
|
#include <coreplugin/helpmanager.h>
|
2011-11-30 15:23:02 +01:00
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
#include <texteditor/itexteditor.h>
|
2011-02-16 14:35:26 +01:00
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
#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>
|
2011-11-30 15:23:02 +01:00
|
|
|
#include <QtGui/QPlainTextEdit>
|
2010-06-09 16:13:47 +02:00
|
|
|
#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
|
|
|
|
|
|
2011-01-12 14:26:50 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-11-22 10:20:31 +01:00
|
|
|
class QmlEnginePrivate
|
|
|
|
|
{
|
2010-11-15 17:09:28 +01:00
|
|
|
public:
|
2010-09-13 13:30:35 +02:00
|
|
|
explicit QmlEnginePrivate(QmlEngine *q);
|
|
|
|
|
|
2010-11-15 17:09:28 +01:00
|
|
|
private:
|
2010-12-03 12:07:32 +01:00
|
|
|
friend class QmlEngine;
|
2011-01-12 14:26:50 +01:00
|
|
|
QmlAdapter m_adapter;
|
|
|
|
|
ApplicationLauncher m_applicationLauncher;
|
2011-02-25 11:57:34 +01:00
|
|
|
Utils::FileInProjectFinder fileFinder;
|
2011-07-28 10:38:39 +02:00
|
|
|
QTimer m_noDebugOutputTimer;
|
2011-10-31 16:42:31 +01:00
|
|
|
QmlJsDebugClient::QDeclarativeOutputParser m_outputParser;
|
2011-11-30 15:23:02 +01:00
|
|
|
QHash<QString, QTextDocument*> m_sourceDocuments;
|
|
|
|
|
QHash<QString, QWeakPointer<TextEditor::ITextEditor> > m_sourceEditors;
|
2010-09-13 13:30:35 +02:00
|
|
|
};
|
|
|
|
|
|
2010-11-22 10:20:31 +01:00
|
|
|
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *q)
|
2011-07-26 16:22:49 +02:00
|
|
|
: m_adapter(q)
|
2010-11-22 10:20:31 +01:00
|
|
|
{}
|
|
|
|
|
|
2010-09-13 13:30:35 +02:00
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// QmlEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-01-12 12:10:12 +01:00
|
|
|
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
|
|
|
|
|
DebuggerEngine *masterEngine)
|
2011-10-12 16:28:33 +02:00
|
|
|
: DebuggerEngine(startParameters, QmlLanguage, masterEngine),
|
2011-01-12 12:10:12 +01:00
|
|
|
d(new QmlEnginePrivate(this))
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2010-08-24 15:35:46 +02:00
|
|
|
setObjectName(QLatin1String("QmlEngine"));
|
2011-07-28 17:04:35 +02:00
|
|
|
|
|
|
|
|
ExtensionSystem::PluginManager *pluginManager =
|
|
|
|
|
ExtensionSystem::PluginManager::instance();
|
|
|
|
|
pluginManager->addObject(this);
|
|
|
|
|
|
|
|
|
|
connect(&d->m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)),
|
|
|
|
|
SLOT(connectionError(QAbstractSocket::SocketError)));
|
|
|
|
|
connect(&d->m_adapter, SIGNAL(serviceConnectionError(QString)),
|
|
|
|
|
SLOT(serviceConnectionError(QString)));
|
|
|
|
|
connect(&d->m_adapter, SIGNAL(connected()),
|
|
|
|
|
SLOT(connectionEstablished()));
|
|
|
|
|
connect(&d->m_adapter, SIGNAL(connectionStartupFailed()),
|
|
|
|
|
SLOT(connectionStartupFailed()));
|
|
|
|
|
|
|
|
|
|
connect(&d->m_applicationLauncher,
|
|
|
|
|
SIGNAL(processExited(int)),
|
|
|
|
|
SLOT(disconnected()));
|
|
|
|
|
connect(&d->m_applicationLauncher,
|
2011-09-14 16:58:10 +02:00
|
|
|
SIGNAL(appendMessage(QString, Utils::OutputFormat)),
|
|
|
|
|
SLOT(appendMessage(QString, Utils::OutputFormat)));
|
|
|
|
|
connect(&d->m_applicationLauncher,
|
|
|
|
|
SIGNAL(processStarted()),
|
|
|
|
|
&d->m_noDebugOutputTimer,
|
|
|
|
|
SLOT(start()));
|
2011-07-28 10:38:39 +02:00
|
|
|
|
2011-10-31 16:42:31 +01:00
|
|
|
d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
|
|
|
|
|
connect(&d->m_outputParser, SIGNAL(waitingForConnectionMessage()),
|
|
|
|
|
this, SLOT(beginConnection()));
|
|
|
|
|
connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
|
|
|
|
|
this, SLOT(beginConnection()));
|
|
|
|
|
connect(&d->m_outputParser, SIGNAL(errorMessage(QString)),
|
|
|
|
|
this, SLOT(wrongSetupMessageBox(QString)));
|
|
|
|
|
|
2011-09-14 16:58:10 +02:00
|
|
|
// Only wait 8 seconds for the 'Waiting for connection' on application ouput, then just try to connect
|
2011-07-28 10:38:39 +02:00
|
|
|
// (application output might be redirected / blocked)
|
|
|
|
|
d->m_noDebugOutputTimer.setSingleShot(true);
|
|
|
|
|
d->m_noDebugOutputTimer.setInterval(8000);
|
|
|
|
|
connect(&d->m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(beginConnection()));
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlEngine::~QmlEngine()
|
2011-07-06 19:07:38 +02:00
|
|
|
{
|
2011-07-28 17:04:35 +02:00
|
|
|
ExtensionSystem::PluginManager *pluginManager =
|
|
|
|
|
ExtensionSystem::PluginManager::instance();
|
|
|
|
|
|
|
|
|
|
if (pluginManager->allObjects().contains(this)) {
|
|
|
|
|
pluginManager->removeObject(this);
|
|
|
|
|
}
|
2011-07-29 17:57:59 +02:00
|
|
|
|
2011-11-30 15:23:02 +01:00
|
|
|
QList<Core::IEditor *> editorsToClose;
|
|
|
|
|
|
|
|
|
|
QHash<QString, QWeakPointer<TextEditor::ITextEditor> >::iterator iter;
|
|
|
|
|
for (iter = d->m_sourceEditors.begin(); iter != d->m_sourceEditors.end(); ++iter) {
|
|
|
|
|
QWeakPointer<TextEditor::ITextEditor> textEditPtr = iter.value();
|
|
|
|
|
if (textEditPtr)
|
|
|
|
|
editorsToClose << textEditPtr.data();
|
|
|
|
|
}
|
|
|
|
|
Core::EditorManager::instance()->closeEditors(editorsToClose);
|
|
|
|
|
|
2011-07-06 19:07:38 +02:00
|
|
|
delete d;
|
|
|
|
|
}
|
2010-08-18 13:54:12 +02:00
|
|
|
|
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
|
|
|
|
2012-01-13 15:00:04 +01:00
|
|
|
notifyInferiorSetupOk();
|
2010-07-09 17:07:59 +02:00
|
|
|
}
|
2010-07-05 11:28:38 +02:00
|
|
|
|
2011-04-15 12:59:44 +02:00
|
|
|
void QmlEngine::appendMessage(const QString &msg, Utils::OutputFormat /* format */)
|
2010-12-03 16:18:50 +01:00
|
|
|
{
|
2011-02-21 17:01:40 +01:00
|
|
|
showMessage(msg, AppOutput); // FIXME: Redirect to RunControl
|
2010-12-03 16:18:50 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void QmlEngine::connectionEstablished()
|
|
|
|
|
{
|
|
|
|
|
attemptBreakpointSynchronization();
|
|
|
|
|
|
2011-04-21 12:25:06 +02:00
|
|
|
if (!watchHandler()->watcherNames().isEmpty()) {
|
|
|
|
|
synchronizeWatchers();
|
|
|
|
|
}
|
|
|
|
|
connect(watchersModel(),SIGNAL(layoutChanged()),this,SLOT(synchronizeWatchers()));
|
2011-02-23 16:09:56 +01:00
|
|
|
|
2011-10-19 17:49:24 +02:00
|
|
|
if (state() == EngineRunRequested)
|
|
|
|
|
notifyEngineRunAndInferiorRunOk();
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
2010-11-15 17:09:28 +01:00
|
|
|
|
2011-07-28 10:38:39 +02:00
|
|
|
void QmlEngine::beginConnection()
|
|
|
|
|
{
|
|
|
|
|
d->m_noDebugOutputTimer.stop();
|
|
|
|
|
d->m_adapter.beginConnection();
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::connectionStartupFailed()
|
|
|
|
|
{
|
2011-10-13 15:32:42 +02:00
|
|
|
if (isSlaveEngine()) {
|
|
|
|
|
if (masterEngine()->state() != InferiorRunOk) {
|
|
|
|
|
// we're right now debugging C++, just try longer ...
|
|
|
|
|
beginConnection();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-24 10:03:44 +01:00
|
|
|
Core::ICore * const core = Core::ICore::instance();
|
|
|
|
|
QMessageBox *infoBox = new QMessageBox(core->mainWindow());
|
|
|
|
|
infoBox->setIcon(QMessageBox::Critical);
|
|
|
|
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
|
|
|
|
infoBox->setText(tr("Could not connect to the in-process QML debugger.\n"
|
|
|
|
|
"Do you want to retry?"));
|
|
|
|
|
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel | QMessageBox::Help);
|
|
|
|
|
infoBox->setDefaultButton(QMessageBox::Retry);
|
|
|
|
|
infoBox->setModal(true);
|
|
|
|
|
|
|
|
|
|
connect(infoBox, SIGNAL(finished(int)),
|
|
|
|
|
this, SLOT(retryMessageBoxFinished(int)));
|
|
|
|
|
|
|
|
|
|
infoBox->show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::retryMessageBoxFinished(int result)
|
|
|
|
|
{
|
|
|
|
|
switch (result) {
|
2011-02-16 14:35:26 +01:00
|
|
|
case QMessageBox::Retry: {
|
2011-07-28 10:38:39 +02:00
|
|
|
beginConnection();
|
2011-02-16 14:35:26 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case QMessageBox::Help: {
|
|
|
|
|
Core::HelpManager *helpManager = Core::HelpManager::instance();
|
2011-12-21 13:29:31 +01:00
|
|
|
helpManager->handleHelpRequest(QLatin1String("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html"));
|
2011-02-24 10:03:44 +01:00
|
|
|
// fall through
|
2011-02-16 14:35:26 +01:00
|
|
|
}
|
|
|
|
|
default:
|
2011-10-19 17:49:24 +02:00
|
|
|
if (state() == InferiorRunOk) {
|
|
|
|
|
notifyInferiorSpontaneousStop();
|
|
|
|
|
notifyInferiorIll();
|
|
|
|
|
} else {
|
2011-02-16 14:35:26 +01:00
|
|
|
notifyEngineRunFailed();
|
2011-10-19 17:49:24 +02:00
|
|
|
}
|
2011-02-16 14:37:37 +01:00
|
|
|
break;
|
2011-02-16 14:35:26 +01:00
|
|
|
}
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-31 16:42:31 +01:00
|
|
|
void QmlEngine::wrongSetupMessageBox(const QString &errorMessage)
|
|
|
|
|
{
|
|
|
|
|
d->m_noDebugOutputTimer.stop();
|
|
|
|
|
notifyEngineRunFailed();
|
|
|
|
|
|
|
|
|
|
Core::ICore * const core = Core::ICore::instance();
|
|
|
|
|
QMessageBox *infoBox = new QMessageBox(core->mainWindow());
|
|
|
|
|
infoBox->setIcon(QMessageBox::Critical);
|
|
|
|
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
|
|
|
|
//: %1 is detailed error message
|
|
|
|
|
infoBox->setText(tr("Could not connect to the in-process QML debugger:\n%1")
|
|
|
|
|
.arg(errorMessage));
|
|
|
|
|
infoBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Help);
|
|
|
|
|
infoBox->setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
infoBox->setModal(true);
|
|
|
|
|
|
|
|
|
|
connect(infoBox, SIGNAL(finished(int)),
|
|
|
|
|
this, SLOT(wrongSetupMessageBoxFinished(int)));
|
|
|
|
|
|
|
|
|
|
infoBox->show();
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-27 13:11:55 +02:00
|
|
|
void QmlEngine::connectionError(QAbstractSocket::SocketError socketError)
|
2010-08-13 14:18:10 +02:00
|
|
|
{
|
2011-01-12 14:26:50 +01:00
|
|
|
if (socketError == QAbstractSocket::RemoteHostClosedError)
|
2010-11-10 11:39:01 +01:00
|
|
|
showMessage(tr("QML Debugger: Remote host closed connection."), StatusBar);
|
2011-09-14 16:58:10 +02:00
|
|
|
|
2011-09-29 16:49:18 +02:00
|
|
|
if (!isSlaveEngine()) { // normal flow for slave engine when gdb exits
|
|
|
|
|
notifyInferiorSpontaneousStop();
|
|
|
|
|
notifyInferiorIll();
|
|
|
|
|
}
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-30 14:05:20 +02:00
|
|
|
void QmlEngine::serviceConnectionError(const QString &serviceName)
|
|
|
|
|
{
|
2010-11-10 11:39:01 +01:00
|
|
|
showMessage(tr("QML Debugger: Could not connect to service '%1'.")
|
|
|
|
|
.arg(serviceName), StatusBar);
|
2010-09-30 14:05:20 +02:00
|
|
|
}
|
|
|
|
|
|
2011-01-24 16:58:35 +01:00
|
|
|
bool QmlEngine::canDisplayTooltip() const
|
|
|
|
|
{
|
|
|
|
|
return state() == InferiorRunOk || state() == InferiorStopOk;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-31 16:00:45 +01:00
|
|
|
void QmlEngine::filterApplicationMessage(const QString &output, int /*channel*/)
|
2011-02-21 17:01:40 +01:00
|
|
|
{
|
2011-10-31 16:42:31 +01:00
|
|
|
d->m_outputParser.processOutput(output);
|
2011-02-21 17:01:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::showMessage(const QString &msg, int channel, int timeout) const
|
|
|
|
|
{
|
|
|
|
|
if (channel == AppOutput || channel == AppError) {
|
|
|
|
|
const_cast<QmlEngine*>(this)->filterApplicationMessage(msg, channel);
|
|
|
|
|
}
|
|
|
|
|
DebuggerEngine::showMessage(msg, channel, timeout);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-30 15:23:02 +01:00
|
|
|
void QmlEngine::gotoLocation(const Location &location)
|
|
|
|
|
{
|
|
|
|
|
const QString fileName = location.fileName();
|
2011-12-20 19:04:44 +01:00
|
|
|
// TODO: QUrl::isLocalFile() once we depend on Qt 4.8
|
|
|
|
|
if (QUrl(fileName).scheme().compare(QLatin1String("file"), Qt::CaseInsensitive) == 0) {
|
2011-11-30 15:23:02 +01:00
|
|
|
// internal file from source files -> show generated .js
|
|
|
|
|
QTC_ASSERT(d->m_sourceDocuments.contains(fileName), return);
|
|
|
|
|
Core::IEditor *editor = 0;
|
|
|
|
|
|
|
|
|
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
2011-12-21 10:22:55 +01:00
|
|
|
QString titlePattern = tr("JS Source for %1").arg(fileName);
|
|
|
|
|
//Check if there are open editors with the same title
|
|
|
|
|
QList<Core::IEditor *> editors = editorManager->openedEditors();
|
|
|
|
|
foreach (Core::IEditor *ed, editors) {
|
|
|
|
|
if (ed->displayName() == titlePattern) {
|
|
|
|
|
editor = ed;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!editor) {
|
2011-11-30 15:23:02 +01:00
|
|
|
editor = editorManager->openEditorWithContents(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
|
|
|
|
|
&titlePattern);
|
|
|
|
|
if (editor) {
|
|
|
|
|
editor->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
|
|
|
|
}
|
|
|
|
|
|
2011-12-21 10:39:54 +01:00
|
|
|
updateEditor(editor, d->m_sourceDocuments.value(fileName));
|
|
|
|
|
}
|
2011-11-30 15:23:02 +01:00
|
|
|
editorManager->activateEditor(editor);
|
2011-12-21 10:39:54 +01:00
|
|
|
|
2011-11-30 15:23:02 +01:00
|
|
|
} else {
|
|
|
|
|
DebuggerEngine::gotoLocation(location);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-15 17:09:28 +01:00
|
|
|
void QmlEngine::closeConnection()
|
|
|
|
|
{
|
2011-04-21 12:25:06 +02:00
|
|
|
disconnect(watchersModel(),SIGNAL(layoutChanged()),this,SLOT(synchronizeWatchers()));
|
2011-02-08 16:10:28 +01:00
|
|
|
d->m_adapter.closeConnection();
|
2010-11-15 17:09:28 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2011-09-16 11:04:11 +02:00
|
|
|
if (!isSlaveEngine() && startParameters().startMode != AttachToRemoteServer
|
2011-09-13 17:26:02 +02:00
|
|
|
&& startParameters().startMode != AttachToQmlPort)
|
2010-11-15 17:09:28 +01:00
|
|
|
startApplicationLauncher();
|
2011-09-14 16:58:10 +02:00
|
|
|
|
|
|
|
|
if (startParameters().startMode == AttachToQmlPort)
|
|
|
|
|
beginConnection();
|
2010-11-15 17:09:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::startApplicationLauncher()
|
|
|
|
|
{
|
|
|
|
|
if (!d->m_applicationLauncher.isRunning()) {
|
2011-03-30 13:14:30 +02:00
|
|
|
appendMessage(tr("Starting %1 %2").arg(
|
|
|
|
|
QDir::toNativeSeparators(startParameters().executable),
|
|
|
|
|
startParameters().processArgs)
|
|
|
|
|
+ QLatin1Char('\n')
|
2011-04-15 12:59:44 +02:00
|
|
|
, Utils::NormalMessageFormat);
|
2011-01-12 14:26:50 +01:00
|
|
|
d->m_applicationLauncher.start(ApplicationLauncher::Gui,
|
2010-08-18 13:54:12 +02:00
|
|
|
startParameters().executable,
|
|
|
|
|
startParameters().processArgs);
|
|
|
|
|
}
|
2010-11-15 17:09:28 +01:00
|
|
|
}
|
2010-08-13 14:18:10 +02:00
|
|
|
|
2010-11-15 17:09:28 +01:00
|
|
|
void QmlEngine::stopApplicationLauncher()
|
|
|
|
|
{
|
|
|
|
|
if (d->m_applicationLauncher.isRunning()) {
|
|
|
|
|
disconnect(&d->m_applicationLauncher, SIGNAL(processExited(int)), this, SLOT(disconnected()));
|
|
|
|
|
d->m_applicationLauncher.stop();
|
|
|
|
|
}
|
2010-08-18 13:54:12 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-11 16:02:41 +01:00
|
|
|
void QmlEngine::handleRemoteSetupDone(int gdbServerPort, int qmlPort)
|
2010-09-16 17:08:07 +02:00
|
|
|
{
|
2011-02-11 16:02:41 +01:00
|
|
|
Q_UNUSED(gdbServerPort);
|
|
|
|
|
if (qmlPort != -1)
|
|
|
|
|
startParameters().qmlServerPort = qmlPort;
|
2012-01-13 15:00:04 +01:00
|
|
|
notifyEngineSetupOk();
|
2010-09-16 17:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::handleRemoteSetupFailed(const QString &message)
|
|
|
|
|
{
|
2012-01-13 15:00:04 +01:00
|
|
|
if (isMasterEngine())
|
|
|
|
|
QMessageBox::critical(0,tr("Failed to start application"),
|
|
|
|
|
tr("Application startup failed: %1").arg(message));
|
|
|
|
|
notifyEngineSetupFailed();
|
2010-09-16 17:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
void QmlEngine::shutdownInferior()
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2011-09-14 16:58:10 +02:00
|
|
|
d->m_noDebugOutputTimer.stop();
|
|
|
|
|
|
|
|
|
|
if (d->m_adapter.activeDebuggerClient())
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->endSession();
|
2011-08-17 13:42:41 +02:00
|
|
|
|
2010-11-15 17:09:28 +01:00
|
|
|
if (isSlaveEngine()) {
|
|
|
|
|
resetLocation();
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
2010-11-15 17:09:28 +01:00
|
|
|
stopApplicationLauncher();
|
2011-08-17 13:42:41 +02:00
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
notifyInferiorShutdownOk();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::shutdownEngine()
|
|
|
|
|
{
|
2010-11-15 17:09:28 +01:00
|
|
|
closeConnection();
|
2010-08-13 14:18:10 +02:00
|
|
|
|
2010-11-15 17:09:28 +01:00
|
|
|
// double check (ill engine?):
|
|
|
|
|
stopApplicationLauncher();
|
2010-08-13 14:18:10 +02:00
|
|
|
|
2010-08-10 14:42:44 +02:00
|
|
|
notifyEngineShutdownOk();
|
2010-11-15 17:09:28 +01:00
|
|
|
if (!isSlaveEngine())
|
|
|
|
|
showMessage(QString(), StatusBar);
|
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
|
|
|
{
|
2012-01-23 14:57:51 +01:00
|
|
|
if (startParameters().requestRemoteSetup) {
|
2012-01-13 15:00:04 +01:00
|
|
|
// we need to get the port first
|
|
|
|
|
emit requestRemoteSetup();
|
|
|
|
|
} else {
|
|
|
|
|
d->m_applicationLauncher.setEnvironment(startParameters().environment);
|
|
|
|
|
d->m_applicationLauncher.setWorkingDirectory(startParameters().workingDirectory);
|
2010-08-13 14:18:10 +02:00
|
|
|
|
2012-01-13 15:00:04 +01:00
|
|
|
// We can't do this in the constructore because runControl() isn't yet defined
|
|
|
|
|
connect(&d->m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
|
|
|
|
runControl(), SLOT(bringApplicationToForeground(qint64)),
|
|
|
|
|
Qt::UniqueConnection);
|
|
|
|
|
|
|
|
|
|
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());
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->continueInferior();
|
|
|
|
|
}
|
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()
|
|
|
|
|
{
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->interruptInferior();
|
|
|
|
|
}
|
2011-08-17 13:42:41 +02:00
|
|
|
notifyInferiorStopOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStep()
|
|
|
|
|
{
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->executeStep();
|
|
|
|
|
}
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStepI()
|
|
|
|
|
{
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->executeStepI();
|
|
|
|
|
}
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStepOut()
|
|
|
|
|
{
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->executeStepOut();
|
|
|
|
|
}
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeNext()
|
|
|
|
|
{
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->executeNext();
|
|
|
|
|
}
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeNextI()
|
|
|
|
|
{
|
2011-10-13 11:10:25 +02:00
|
|
|
executeNext();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
2011-02-23 10:16:11 +01:00
|
|
|
void QmlEngine::executeRunToLine(const ContextData &data)
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2011-12-22 18:43:09 +01:00
|
|
|
QTC_ASSERT(state() == InferiorStopOk, qDebug() << state());
|
|
|
|
|
showStatusMessage(tr("Run to line %1 (%2) requested...").arg(data.lineNumber).arg(data.fileName), 5000);
|
|
|
|
|
resetLocation();
|
|
|
|
|
if (d->m_adapter.activeDebuggerClient())
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->executeRunToLine(data);
|
|
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeRunToFunction(const QString &functionName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(functionName)
|
|
|
|
|
XSDEBUG("FIXME: QmlEngine::executeRunToFunction()");
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-23 10:16:11 +01:00
|
|
|
void QmlEngine::executeJumpToLine(const ContextData &data)
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2011-02-23 10:16:11 +01:00
|
|
|
Q_UNUSED(data)
|
2010-06-09 16:13:47 +02:00
|
|
|
XSDEBUG("FIXME: QmlEngine::executeJumpToLine()");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::activateFrame(int index)
|
|
|
|
|
{
|
2011-10-17 15:23:42 +02:00
|
|
|
if (state() != InferiorStopOk && state() != InferiorUnrunnable)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->activateFrame(index);
|
|
|
|
|
}
|
2010-12-16 19:06:33 +01:00
|
|
|
gotoLocation(stackHandler()->frames().value(index));
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::selectThread(int index)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 11:47:42 +02:00
|
|
|
void QmlEngine::insertBreakpoint(BreakpointModelId id)
|
|
|
|
|
{
|
|
|
|
|
BreakHandler *handler = breakHandler();
|
|
|
|
|
BreakpointState state = handler->state(id);
|
|
|
|
|
QTC_ASSERT(state == BreakpointInsertRequested, qDebug() << id << this << state);
|
|
|
|
|
handler->notifyBreakpointInsertProceeding(id);
|
|
|
|
|
|
|
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
2011-08-22 17:23:34 +02:00
|
|
|
d->m_adapter.activeDebuggerClient()->insertBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
|
|
|
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
2011-08-22 17:23:34 +02:00
|
|
|
client->insertBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::removeBreakpoint(BreakpointModelId id)
|
|
|
|
|
{
|
|
|
|
|
BreakHandler *handler = breakHandler();
|
|
|
|
|
BreakpointState state = handler->state(id);
|
|
|
|
|
QTC_ASSERT(state == BreakpointRemoveRequested, qDebug() << id << this << state);
|
|
|
|
|
handler->notifyBreakpointRemoveProceeding(id);
|
|
|
|
|
|
|
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
2011-08-22 17:23:34 +02:00
|
|
|
d->m_adapter.activeDebuggerClient()->removeBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
|
|
|
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
2011-08-22 17:23:34 +02:00
|
|
|
client->removeBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (handler->state(id) == BreakpointRemoveProceeding) {
|
|
|
|
|
handler->notifyBreakpointRemoveOk(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::changeBreakpoint(BreakpointModelId id)
|
|
|
|
|
{
|
|
|
|
|
BreakHandler *handler = breakHandler();
|
|
|
|
|
BreakpointState state = handler->state(id);
|
|
|
|
|
QTC_ASSERT(state == BreakpointChangeRequested, qDebug() << id << this << state);
|
|
|
|
|
handler->notifyBreakpointChangeProceeding(id);
|
|
|
|
|
|
|
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
2011-08-22 17:23:34 +02:00
|
|
|
d->m_adapter.activeDebuggerClient()->changeBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
|
|
|
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
2011-08-22 17:23:34 +02:00
|
|
|
client->changeBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (handler->state(id) == BreakpointChangeProceeding) {
|
|
|
|
|
handler->notifyBreakpointChangeOk(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
void QmlEngine::attemptBreakpointSynchronization()
|
|
|
|
|
{
|
2011-08-17 11:47:42 +02:00
|
|
|
if (!stateAcceptsBreakpointChanges()) {
|
|
|
|
|
showMessage(_("BREAKPOINT SYNCHRONIZATION NOT POSSIBLE IN CURRENT STATE"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
BreakHandler *handler = breakHandler();
|
2010-11-23 16:12:16 +01:00
|
|
|
|
2011-06-24 16:25:30 +02:00
|
|
|
foreach (BreakpointModelId id, handler->unclaimedBreakpointIds()) {
|
2010-11-23 16:12:16 +01:00
|
|
|
// Take ownership of the breakpoint. Requests insertion.
|
|
|
|
|
if (acceptsBreakpoint(id))
|
|
|
|
|
handler->setEngine(id, this);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-24 16:25:30 +02:00
|
|
|
foreach (BreakpointModelId id, handler->engineBreakpointIds(this)) {
|
2011-08-17 11:47:42 +02:00
|
|
|
switch (handler->state(id)) {
|
|
|
|
|
case BreakpointNew:
|
|
|
|
|
// Should not happen once claimed.
|
|
|
|
|
QTC_CHECK(false);
|
|
|
|
|
continue;
|
|
|
|
|
case BreakpointInsertRequested:
|
|
|
|
|
insertBreakpoint(id);
|
|
|
|
|
continue;
|
|
|
|
|
case BreakpointChangeRequested:
|
|
|
|
|
changeBreakpoint(id);
|
|
|
|
|
continue;
|
|
|
|
|
case BreakpointRemoveRequested:
|
|
|
|
|
removeBreakpoint(id);
|
|
|
|
|
continue;
|
|
|
|
|
case BreakpointChangeProceeding:
|
|
|
|
|
case BreakpointInsertProceeding:
|
|
|
|
|
case BreakpointRemoveProceeding:
|
|
|
|
|
case BreakpointInserted:
|
|
|
|
|
case BreakpointDead:
|
|
|
|
|
continue;
|
2010-11-30 11:35:17 +01:00
|
|
|
}
|
2011-08-17 11:47:42 +02:00
|
|
|
QTC_ASSERT(false, qDebug() << "UNKNOWN STATE" << id << state());
|
2010-06-25 14:08:53 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-17 11:47:42 +02:00
|
|
|
DebuggerEngine::attemptBreakpointSynchronization();
|
2010-12-17 10:18:34 +01:00
|
|
|
|
2011-07-26 16:22:49 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
2011-10-26 10:02:37 +02:00
|
|
|
d->m_adapter.activeDebuggerClient()->synchronizeBreakpoints();
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
|
|
|
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients()) {
|
2011-10-26 10:02:37 +02:00
|
|
|
client->synchronizeBreakpoints();
|
2011-08-17 11:47:42 +02:00
|
|
|
}
|
2010-12-17 10:18:34 +01:00
|
|
|
}
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
2011-06-24 16:25:30 +02:00
|
|
|
bool QmlEngine::acceptsBreakpoint(BreakpointModelId id) const
|
2010-10-05 11:01:14 +02:00
|
|
|
{
|
2011-09-13 12:47:46 +02:00
|
|
|
if (!DebuggerEngine::isCppBreakpoint(breakHandler()->breakpointData(id)))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
//If it is a Cpp Breakpoint query if the type can be also handled by the debugger client
|
|
|
|
|
//TODO: enable setting of breakpoints before start of debug session
|
|
|
|
|
//For now, the event breakpoint can be set after the activeDebuggerClient is known
|
2011-09-28 17:55:48 +02:00
|
|
|
//This is because the older client does not support BreakpointOnQmlSignalHandler
|
2011-09-13 12:47:46 +02:00
|
|
|
bool acceptBreakpoint = false;
|
|
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
acceptBreakpoint = d->m_adapter.activeDebuggerClient()->acceptsBreakpoint(id);
|
|
|
|
|
}
|
|
|
|
|
return acceptBreakpoint;
|
2010-10-05 11:01:14 +02:00
|
|
|
}
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
void QmlEngine::loadSymbols(const QString &moduleName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(moduleName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::loadAllSymbols()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::reloadModules()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-30 15:23:02 +01:00
|
|
|
void QmlEngine::reloadSourceFiles()
|
|
|
|
|
{
|
|
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->getSourceFiles();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
void QmlEngine::requestModuleSymbols(const QString &moduleName)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(moduleName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Tooltip specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-02-17 10:08:57 +01:00
|
|
|
bool QmlEngine::setToolTipExpression(const QPoint &mousePos,
|
2011-02-11 15:00:13 +01:00
|
|
|
TextEditor::ITextEditor *editor, const DebuggerToolTipContext &ctx)
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2011-10-06 17:38:28 +02:00
|
|
|
// This is processed by QML inspector, which has dependencies to
|
2010-10-27 15:23:30 +02:00
|
|
|
// the qml js editor. Makes life easier.
|
2011-02-11 15:00:13 +01:00
|
|
|
emit tooltipRequested(mousePos, editor, ctx.position);
|
2011-02-17 10:08:57 +01:00
|
|
|
return true;
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Watch specific stuff
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2011-07-26 16:22:49 +02:00
|
|
|
void QmlEngine::assignValueInDebugger(const WatchData *data,
|
2010-10-27 15:23:30 +02:00
|
|
|
const QString &expression, const QVariant &valueV)
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2011-07-26 16:22:49 +02:00
|
|
|
quint64 objectId = data->id;
|
2011-09-14 16:58:10 +02:00
|
|
|
if (objectId > 0 && !expression.isEmpty() && d->m_adapter.activeDebuggerClient()) {
|
2011-07-26 16:22:49 +02:00
|
|
|
d->m_adapter.activeDebuggerClient()->assignValueInDebugger(expression.toUtf8(), objectId, expression, valueV.toString());
|
2010-07-22 19:06:26 +02:00
|
|
|
}
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
2010-11-10 16:33:11 +01:00
|
|
|
void QmlEngine::updateWatchData(const WatchData &data,
|
|
|
|
|
const WatchUpdateFlags &)
|
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
|
|
|
|
2011-09-14 16:58:10 +02:00
|
|
|
if (!data.name.isEmpty() && d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
if (data.isValueNeeded()) {
|
2011-10-26 10:02:37 +02:00
|
|
|
d->m_adapter.activeDebuggerClient()->updateWatchData(data);
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
|
|
|
|
if (data.isChildrenNeeded()
|
|
|
|
|
&& watchHandler()->isExpandedIName(data.iname)) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->expandObject(data.iname, data.id);
|
|
|
|
|
}
|
2011-02-23 16:09:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
synchronizeWatchers();
|
2010-07-22 14:58:37 +02:00
|
|
|
|
2011-02-23 16:09:56 +01:00
|
|
|
if (!data.isSomethingNeeded())
|
|
|
|
|
watchHandler()->insertData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::synchronizeWatchers()
|
|
|
|
|
{
|
2011-07-26 16:22:49 +02:00
|
|
|
QStringList watchedExpressions = watchHandler()->watchedExpressions();
|
2011-04-21 12:25:06 +02:00
|
|
|
// send watchers list
|
2011-07-26 16:22:49 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->synchronizeWatchers(watchedExpressions);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
2011-07-26 16:22:49 +02:00
|
|
|
foreach (QmlDebuggerClient *client, d->m_adapter.debuggerClients())
|
|
|
|
|
client->synchronizeWatchers(watchedExpressions);
|
|
|
|
|
}
|
2010-07-23 11:30:07 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-12 20:28:17 +01:00
|
|
|
bool QmlEngine::hasCapability(unsigned cap) const
|
2010-07-16 11:44:29 +02:00
|
|
|
{
|
2012-01-12 20:28:17 +01:00
|
|
|
return cap & (AddWatcherCapability
|
2011-12-22 18:43:09 +01:00
|
|
|
| AddWatcherWhileRunningCapability
|
2012-01-12 20:28:17 +01:00
|
|
|
| RunToLineCapability);
|
2010-07-16 11:44:29 +02:00
|
|
|
/*ReverseSteppingCapability | SnapshotCapability
|
|
|
|
|
| AutoDerefPointersCapability | DisassemblerCapability
|
|
|
|
|
| RegisterCapability | ShowMemoryCapability
|
|
|
|
|
| JumpToLineCapability | ReloadModuleCapability
|
|
|
|
|
| ReloadModuleSymbolsCapability | BreakOnThrowAndCatchCapability
|
|
|
|
|
| ReturnFromFunctionCapability
|
|
|
|
|
| CreateFullBacktraceCapability
|
|
|
|
|
| WatchpointCapability
|
|
|
|
|
| AddWatcherCapability;*/
|
2010-06-25 14:08:53 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-19 17:48:57 +02:00
|
|
|
QString QmlEngine::toFileInProject(const QUrl &fileUrl)
|
2011-02-25 11:57:34 +01:00
|
|
|
{
|
2011-10-11 15:21:00 +02:00
|
|
|
// make sure file finder is properly initialized
|
|
|
|
|
d->fileFinder.setProjectDirectory(startParameters().projectSourceDirectory);
|
|
|
|
|
d->fileFinder.setProjectFiles(startParameters().projectSourceFiles);
|
|
|
|
|
d->fileFinder.setSysroot(startParameters().sysroot);
|
2011-02-25 11:57:34 +01:00
|
|
|
|
2011-07-19 17:48:57 +02:00
|
|
|
return d->fileFinder.findFile(fileUrl);
|
2011-02-25 11:57:34 +01:00
|
|
|
}
|
|
|
|
|
|
2011-07-26 16:22:49 +02:00
|
|
|
void QmlEngine::inferiorSpontaneousStop()
|
2010-06-25 14:08:53 +02:00
|
|
|
{
|
2011-07-26 16:22:49 +02:00
|
|
|
if (state() == InferiorRunOk)
|
|
|
|
|
notifyInferiorSpontaneousStop();
|
2010-06-25 14:08:53 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-10 14:42:44 +02:00
|
|
|
void QmlEngine::disconnected()
|
|
|
|
|
{
|
2010-11-10 11:39:01 +01:00
|
|
|
showMessage(tr("QML Debugger disconnected."), StatusBar);
|
2010-08-10 14:42:44 +02:00
|
|
|
notifyInferiorExited();
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-24 10:03:44 +01:00
|
|
|
void QmlEngine::wrongSetupMessageBoxFinished(int result)
|
2011-02-21 17:01:40 +01:00
|
|
|
{
|
|
|
|
|
if (result == QMessageBox::Help) {
|
|
|
|
|
Core::HelpManager *helpManager = Core::HelpManager::instance();
|
|
|
|
|
helpManager->handleHelpRequest(
|
|
|
|
|
QLatin1String("qthelp://com.nokia.qtcreator/doc/creator-debugging-qml.html"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-26 16:02:41 +02:00
|
|
|
void QmlEngine::executeDebuggerCommand(const QString& command)
|
|
|
|
|
{
|
2011-09-14 16:58:10 +02:00
|
|
|
if (d->m_adapter.activeDebuggerClient()) {
|
|
|
|
|
d->m_adapter.activeDebuggerClient()->executeDebuggerCommand(command);
|
|
|
|
|
}
|
2010-08-26 16:02:41 +02:00
|
|
|
}
|
|
|
|
|
|
2010-09-08 13:31:12 +02:00
|
|
|
|
|
|
|
|
QString QmlEngine::qmlImportPath() const
|
|
|
|
|
{
|
2011-12-21 13:29:31 +01:00
|
|
|
return startParameters().environment.value(QLatin1String("QML_IMPORT_PATH"));
|
2010-09-08 13:31:12 +02:00
|
|
|
}
|
|
|
|
|
|
2011-12-07 10:23:26 +01:00
|
|
|
void QmlEngine::logMessage(const QString &service, LogDirection direction, const QString &message)
|
2010-12-17 10:18:34 +01:00
|
|
|
{
|
2011-12-07 10:23:26 +01:00
|
|
|
QString msg = service;
|
2011-12-21 13:29:31 +01:00
|
|
|
msg += direction == LogSend ? QLatin1String(": sending ") : QLatin1String(": receiving ");
|
2010-12-17 10:18:34 +01:00
|
|
|
msg += message;
|
|
|
|
|
showMessage(msg, LogDebug);
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-30 15:23:02 +01:00
|
|
|
void QmlEngine::setSourceFiles(const QStringList &fileNames)
|
|
|
|
|
{
|
|
|
|
|
QMap<QString,QString> files;
|
|
|
|
|
foreach (const QString &file, fileNames) {
|
|
|
|
|
QString shortName = file;
|
|
|
|
|
QString fullName = d->fileFinder.findFile(file);
|
|
|
|
|
files.insert(shortName, fullName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sourceFilesHandler()->setSourceFiles(files);
|
2011-12-21 10:39:54 +01:00
|
|
|
//update open editors
|
|
|
|
|
|
2011-11-30 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::updateScriptSource(const QString &fileName, int lineOffset, int columnOffset,
|
|
|
|
|
const QString &source)
|
|
|
|
|
{
|
|
|
|
|
QTextDocument *document = 0;
|
|
|
|
|
if (d->m_sourceDocuments.contains(fileName)) {
|
|
|
|
|
document = d->m_sourceDocuments.value(fileName);
|
|
|
|
|
} else {
|
|
|
|
|
document = new QTextDocument(this);
|
|
|
|
|
d->m_sourceDocuments.insert(fileName, document);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// We're getting an unordered set of snippets that can even interleave
|
|
|
|
|
// Therefore we've to carefully update the existing document
|
|
|
|
|
|
|
|
|
|
QTextCursor cursor(document);
|
|
|
|
|
for (int i = 0; i < lineOffset; ++i) {
|
|
|
|
|
if (!cursor.movePosition(QTextCursor::NextBlock))
|
|
|
|
|
cursor.insertBlock();
|
|
|
|
|
}
|
|
|
|
|
QTC_CHECK(cursor.blockNumber() == lineOffset);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < columnOffset; ++i) {
|
|
|
|
|
if (!cursor.movePosition(QTextCursor::NextCharacter))
|
|
|
|
|
cursor.insertText(QLatin1String(" "));
|
|
|
|
|
}
|
|
|
|
|
QTC_CHECK(cursor.positionInBlock() == columnOffset);
|
|
|
|
|
|
|
|
|
|
QStringList lines = source.split(QLatin1Char('\n'));
|
|
|
|
|
foreach (QString line, lines) {
|
|
|
|
|
if (line.endsWith(QLatin1Char('\r')))
|
|
|
|
|
line.remove(line.size() -1, 1);
|
|
|
|
|
|
|
|
|
|
// line already there?
|
|
|
|
|
QTextCursor existingCursor(cursor);
|
|
|
|
|
existingCursor.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor);
|
|
|
|
|
if (existingCursor.selectedText() != line)
|
|
|
|
|
cursor.insertText(line);
|
|
|
|
|
|
|
|
|
|
if (!cursor.movePosition(QTextCursor::NextBlock))
|
|
|
|
|
cursor.insertBlock();
|
|
|
|
|
}
|
2011-12-21 10:39:54 +01:00
|
|
|
|
|
|
|
|
//update open editors
|
|
|
|
|
QString titlePattern = tr("JS Source for %1").arg(fileName);
|
|
|
|
|
//Check if there are open editors with the same title
|
|
|
|
|
QList<Core::IEditor *> editors = Core::EditorManager::instance()->openedEditors();
|
|
|
|
|
foreach (Core::IEditor *editor, editors) {
|
|
|
|
|
if (editor->displayName() == titlePattern) {
|
|
|
|
|
updateEditor(editor, document);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::updateEditor(Core::IEditor *editor, const QTextDocument *document)
|
|
|
|
|
{
|
|
|
|
|
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
|
|
|
|
if (!textEditor)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QPlainTextEdit *plainTextEdit =
|
|
|
|
|
qobject_cast<QPlainTextEdit *>(editor->widget());
|
|
|
|
|
if (!plainTextEdit)
|
|
|
|
|
return;
|
|
|
|
|
plainTextEdit->setPlainText(document->toPlainText());
|
|
|
|
|
plainTextEdit->setReadOnly(true);
|
2011-11-30 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-06 17:38:28 +02:00
|
|
|
QmlAdapter *QmlEngine::adapter() const
|
|
|
|
|
{
|
|
|
|
|
return &d->m_adapter;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-21 17:01:40 +01:00
|
|
|
QmlEngine *createQmlEngine(const DebuggerStartParameters &sp,
|
2011-01-12 12:10:12 +01:00
|
|
|
DebuggerEngine *masterEngine)
|
|
|
|
|
{
|
|
|
|
|
return new QmlEngine(sp, masterEngine);
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-03 12:07:32 +01:00
|
|
|
} // namespace Internal
|
2010-06-09 16:13:47 +02:00
|
|
|
} // namespace Debugger
|
2010-07-01 11:48:43 +02:00
|
|
|
|