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).
|
|
|
|
|
**
|
2012-07-19 12:26:56 +02:00
|
|
|
** Contact: http://www.qt-project.org/
|
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-06-09 16:13:47 +02:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "qmlengine.h"
|
2012-04-18 12:06:10 +02:00
|
|
|
#include "baseqmldebuggerclient.h"
|
2012-04-18 14:20:54 +02:00
|
|
|
#include "qmlinspectoragent.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"
|
2012-02-15 12:35:43 +01:00
|
|
|
#include "qtmessageloghandler.h"
|
2010-06-09 16:13:47 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2012-04-18 12:06:10 +02:00
|
|
|
#include <qmldebug/baseenginedebugclient.h>
|
2011-11-30 15:23:02 +01:00
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
2012-02-28 17:30:15 +01:00
|
|
|
#include <qmljs/parser/qmljsast_p.h>
|
|
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.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-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
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDateTime>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QTimer>
|
2010-06-09 16:13:47 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QToolTip>
|
2010-06-09 16:13:47 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTcpSocket>
|
|
|
|
|
#include <QHostAddress>
|
2010-07-01 11:48:43 +02:00
|
|
|
|
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
|
|
|
|
|
|
2012-02-28 17:30:15 +01:00
|
|
|
using namespace QmlJS;
|
|
|
|
|
using namespace AST;
|
2011-01-12 14:26:50 +01:00
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
namespace Debugger {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
class ASTWalker : public Visitor
|
2012-02-28 17:30:15 +01:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
void operator()(Node *ast, quint32 *l, quint32 *c)
|
|
|
|
|
{
|
|
|
|
|
done = false;
|
|
|
|
|
line = l;
|
|
|
|
|
column = c;
|
|
|
|
|
Node::accept(ast, this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool preVisit(Node *ast)
|
|
|
|
|
{
|
|
|
|
|
return ast->lastSourceLocation().startLine >= *line && !done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Case 1: Breakpoint is between sourceStart(exclusive) and
|
|
|
|
|
// sourceEnd(inclusive) --> End tree walk.
|
|
|
|
|
//Case 2: Breakpoint is on sourceStart --> Check for the start
|
|
|
|
|
// of the first executable code. Set the line number and
|
|
|
|
|
// column number. End tree walk.
|
|
|
|
|
//Case 3: Breakpoint is on "unbreakable" code --> Find the next "breakable"
|
|
|
|
|
// code and check for Case 2. End tree walk.
|
|
|
|
|
|
|
|
|
|
//Add more types when suitable.
|
|
|
|
|
|
|
|
|
|
bool visit(UiScriptBinding *ast)
|
|
|
|
|
{
|
2012-03-09 08:57:19 +01:00
|
|
|
if (!ast->statement)
|
|
|
|
|
return true;
|
|
|
|
|
|
2012-02-28 17:30:15 +01:00
|
|
|
quint32 sourceStartLine = ast->firstSourceLocation().startLine;
|
|
|
|
|
quint32 statementStartLine;
|
|
|
|
|
quint32 statementColumn;
|
|
|
|
|
|
|
|
|
|
if (ast->statement->kind == Node::Kind_ExpressionStatement) {
|
|
|
|
|
statementStartLine = ast->statement->firstSourceLocation().
|
|
|
|
|
startLine;
|
|
|
|
|
statementColumn = ast->statement->firstSourceLocation().startColumn;
|
|
|
|
|
|
|
|
|
|
} else if (ast->statement->kind == Node::Kind_Block) {
|
|
|
|
|
Block *block = static_cast<Block *>(ast->statement);
|
2012-03-09 08:57:19 +01:00
|
|
|
if (!block || !block->statements)
|
|
|
|
|
return true;
|
2012-02-28 17:30:15 +01:00
|
|
|
statementStartLine = block->statements->firstSourceLocation().
|
|
|
|
|
startLine;
|
|
|
|
|
statementColumn = block->statements->firstSourceLocation().
|
|
|
|
|
startColumn;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Case 1
|
|
|
|
|
//Check for possible relocation within the binding statement
|
|
|
|
|
|
|
|
|
|
//Rewritten to (function <token>() { { }})
|
|
|
|
|
//The offset 16 is position of inner lbrace without token length.
|
|
|
|
|
const int offset = 16;
|
|
|
|
|
|
|
|
|
|
//Case 2
|
|
|
|
|
if (statementStartLine == *line) {
|
|
|
|
|
if (sourceStartLine == *line)
|
|
|
|
|
*column = offset + ast->qualifiedId->identifierToken.length;
|
|
|
|
|
done = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Case 3
|
|
|
|
|
if (statementStartLine > *line) {
|
|
|
|
|
*line = statementStartLine;
|
|
|
|
|
if (sourceStartLine == *line)
|
|
|
|
|
*column = offset + ast->qualifiedId->identifierToken.length;
|
|
|
|
|
else
|
|
|
|
|
*column = statementColumn;
|
|
|
|
|
done = true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool visit(FunctionDeclaration *ast) {
|
|
|
|
|
quint32 sourceStartLine = ast->firstSourceLocation().startLine;
|
|
|
|
|
quint32 sourceStartColumn = ast->firstSourceLocation().startColumn;
|
|
|
|
|
quint32 statementStartLine = ast->body->firstSourceLocation().startLine;
|
|
|
|
|
quint32 statementColumn = ast->body->firstSourceLocation().startColumn;
|
|
|
|
|
|
|
|
|
|
//Case 1
|
|
|
|
|
//Check for possible relocation within the function declaration
|
|
|
|
|
|
|
|
|
|
//Case 2
|
|
|
|
|
if (statementStartLine == *line) {
|
|
|
|
|
if (sourceStartLine == *line)
|
|
|
|
|
*column = statementColumn - sourceStartColumn + 1;
|
|
|
|
|
done = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Case 3
|
|
|
|
|
if (statementStartLine > *line) {
|
|
|
|
|
*line = statementStartLine;
|
|
|
|
|
if (sourceStartLine == *line)
|
|
|
|
|
*column = statementColumn - sourceStartColumn + 1;
|
|
|
|
|
else
|
|
|
|
|
*column = statementColumn;
|
|
|
|
|
done = true;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool visit(EmptyStatement *ast)
|
|
|
|
|
{
|
|
|
|
|
*line = ast->lastSourceLocation().startLine + 1;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool visit(VariableStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(VariableDeclarationList *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(VariableDeclaration *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(ExpressionStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(IfStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(DoWhileStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(WhileStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(ForStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(LocalForStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(ForEachStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(LocalForEachStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(ContinueStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(BreakStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(ReturnStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(WithStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(SwitchStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(CaseBlock *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(CaseClauses *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(CaseClause *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(DefaultClause *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(LabelledStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(ThrowStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(TryStatement *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(Catch *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(Finally *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(FunctionExpression *ast) { test(ast); return true; }
|
|
|
|
|
bool visit(DebuggerStatement *ast) { test(ast); return true; }
|
|
|
|
|
|
|
|
|
|
void test(Node *ast)
|
|
|
|
|
{
|
|
|
|
|
quint32 statementStartLine = ast->firstSourceLocation().startLine;
|
|
|
|
|
//Case 1/2
|
|
|
|
|
if (statementStartLine <= *line &&
|
|
|
|
|
*line <= ast->lastSourceLocation().startLine)
|
|
|
|
|
done = true;
|
|
|
|
|
|
|
|
|
|
//Case 3
|
|
|
|
|
if (statementStartLine > *line) {
|
|
|
|
|
*line = statementStartLine;
|
|
|
|
|
*column = ast->firstSourceLocation().startColumn;
|
|
|
|
|
done = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool done;
|
|
|
|
|
quint32 *line;
|
|
|
|
|
quint32 *column;
|
|
|
|
|
};
|
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)
|
2012-05-09 14:56:04 +02:00
|
|
|
: DebuggerEngine(startParameters, QmlLanguage, masterEngine)
|
|
|
|
|
, m_adapter(this)
|
|
|
|
|
, m_inspectorAdapter(&m_adapter, this)
|
|
|
|
|
, m_retryOnConnectFail(false)
|
|
|
|
|
, m_automaticConnect(false)
|
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
|
|
|
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(this);
|
2011-07-28 17:04:35 +02:00
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_adapter, SIGNAL(connectionError(QAbstractSocket::SocketError)),
|
2011-07-28 17:04:35 +02:00
|
|
|
SLOT(connectionError(QAbstractSocket::SocketError)));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_adapter, SIGNAL(serviceConnectionError(QString)),
|
2011-07-28 17:04:35 +02:00
|
|
|
SLOT(serviceConnectionError(QString)));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_adapter, SIGNAL(connected()),
|
2011-07-28 17:04:35 +02:00
|
|
|
SLOT(connectionEstablished()));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_adapter, SIGNAL(connectionStartupFailed()),
|
2011-07-28 17:04:35 +02:00
|
|
|
SLOT(connectionStartupFailed()));
|
|
|
|
|
|
2012-02-15 12:35:43 +01:00
|
|
|
connect(this, SIGNAL(stateChanged(Debugger::DebuggerState)),
|
|
|
|
|
SLOT(updateCurrentContext()));
|
|
|
|
|
connect(this->stackHandler(), SIGNAL(currentIndexChanged()),
|
|
|
|
|
SLOT(updateCurrentContext()));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_inspectorAdapter, SIGNAL(selectionChanged()),
|
2012-02-15 12:35:43 +01:00
|
|
|
SLOT(updateCurrentContext()));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(m_inspectorAdapter.agent(), SIGNAL(
|
2012-04-18 14:20:54 +02:00
|
|
|
expressionResult(quint32,QVariant)),
|
|
|
|
|
SLOT(expressionEvaluated(quint32,QVariant)));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(m_adapter.messageClient(),
|
2012-02-22 11:50:05 +01:00
|
|
|
SIGNAL(message(QtMsgType,QString,
|
2012-04-18 12:06:10 +02:00
|
|
|
QmlDebug::QDebugContextInfo)),
|
2012-02-22 11:50:05 +01:00
|
|
|
SLOT(appendDebugOutput(QtMsgType,QString,
|
2012-04-18 12:06:10 +02:00
|
|
|
QmlDebug::QDebugContextInfo)));
|
2012-02-15 12:35:43 +01:00
|
|
|
|
2012-04-18 14:20:54 +02:00
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_applicationLauncher,
|
2011-07-28 17:04:35 +02:00
|
|
|
SIGNAL(processExited(int)),
|
|
|
|
|
SLOT(disconnected()));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_applicationLauncher,
|
2012-03-05 22:30:59 +01:00
|
|
|
SIGNAL(appendMessage(QString,Utils::OutputFormat)),
|
|
|
|
|
SLOT(appendMessage(QString,Utils::OutputFormat)));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_applicationLauncher,
|
2011-09-14 16:58:10 +02:00
|
|
|
SIGNAL(processStarted()),
|
2012-05-09 14:56:04 +02:00
|
|
|
&m_noDebugOutputTimer,
|
2011-09-14 16:58:10 +02:00
|
|
|
SLOT(start()));
|
2011-07-28 10:38:39 +02:00
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
m_outputParser.setNoOutputText(ProjectExplorer::ApplicationLauncher
|
|
|
|
|
::msgWinCannotRetrieveDebuggingOutput());
|
|
|
|
|
connect(&m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
|
2012-02-21 15:47:55 +01:00
|
|
|
this, SLOT(beginConnection(quint16)));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_outputParser, SIGNAL(waitingForConnectionViaOst()),
|
2011-10-31 16:42:31 +01:00
|
|
|
this, SLOT(beginConnection()));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_outputParser, SIGNAL(noOutputMessage()),
|
2012-03-14 15:28:01 +01:00
|
|
|
this, SLOT(tryToConnect()));
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_outputParser, SIGNAL(errorMessage(QString)),
|
2012-03-14 15:33:33 +01:00
|
|
|
this, SLOT(appStartupFailed(QString)));
|
2011-10-31 16:42:31 +01:00
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
// Only wait 8 seconds for the 'Waiting for connection' on application output,
|
|
|
|
|
// then just try to connect (application output might be redirected / blocked)
|
|
|
|
|
m_noDebugOutputTimer.setSingleShot(true);
|
|
|
|
|
m_noDebugOutputTimer.setInterval(8000);
|
|
|
|
|
connect(&m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(tryToConnect()));
|
2012-02-15 12:35:43 +01:00
|
|
|
|
|
|
|
|
qtMessageLogHandler()->setHasEditableRow(true);
|
2012-02-28 17:30:15 +01:00
|
|
|
|
|
|
|
|
connect(ModelManagerInterface::instance(),
|
|
|
|
|
SIGNAL(documentUpdated(QmlJS::Document::Ptr)),
|
|
|
|
|
this,
|
|
|
|
|
SLOT(documentUpdated(QmlJS::Document::Ptr)));
|
2012-03-14 15:28:01 +01:00
|
|
|
|
|
|
|
|
// we won't get any debug output
|
2012-03-16 12:55:00 +01:00
|
|
|
if (startParameters.useTerminal) {
|
2012-05-09 14:56:04 +02:00
|
|
|
m_noDebugOutputTimer.setInterval(0);
|
|
|
|
|
m_retryOnConnectFail = true;
|
|
|
|
|
m_automaticConnect = true;
|
2012-03-16 12:55:00 +01:00
|
|
|
}
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlEngine::~QmlEngine()
|
2011-07-06 19:07:38 +02:00
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
if (ExtensionSystem::PluginManager::allObjects().contains(this)) {
|
|
|
|
|
ExtensionSystem::PluginManager::removeObject(this);
|
2011-07-28 17:04:35 +02:00
|
|
|
}
|
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;
|
2012-05-09 14:56:04 +02:00
|
|
|
for (iter = m_sourceEditors.begin(); iter != m_sourceEditors.end(); ++iter) {
|
2011-11-30 15:23:02 +01:00
|
|
|
QWeakPointer<TextEditor::ITextEditor> textEditPtr = iter.value();
|
|
|
|
|
if (textEditPtr)
|
|
|
|
|
editorsToClose << textEditPtr.data();
|
|
|
|
|
}
|
|
|
|
|
Core::EditorManager::instance()->closeEditors(editorsToClose);
|
2011-07-06 19:07:38 +02:00
|
|
|
}
|
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();
|
2012-03-22 13:00:56 +01:00
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_automaticConnect)
|
2012-03-22 13:00:56 +01:00
|
|
|
beginConnection();
|
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
|
|
|
|
2012-03-14 15:28:01 +01:00
|
|
|
void QmlEngine::tryToConnect(quint16 port)
|
|
|
|
|
{
|
2012-03-16 12:55:00 +01:00
|
|
|
showMessage(QLatin1String("QML Debugger: No application output received in time, trying to connect ..."), LogStatus);
|
2012-05-09 14:56:04 +02:00
|
|
|
m_retryOnConnectFail = true;
|
2012-06-12 10:48:54 +02:00
|
|
|
if (state() == EngineRunRequested) {
|
|
|
|
|
if (isSlaveEngine()) {
|
|
|
|
|
// Probably cpp is being debugged and hence we did not get the output yet.
|
|
|
|
|
if (!masterEngine()->isDying())
|
|
|
|
|
m_noDebugOutputTimer.start();
|
|
|
|
|
else
|
|
|
|
|
appStartupFailed(tr("No application output received in time"));
|
|
|
|
|
} else {
|
|
|
|
|
beginConnection(port);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
m_automaticConnect = true;
|
2012-06-12 10:48:54 +02:00
|
|
|
}
|
2012-03-14 15:28:01 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-21 15:47:55 +01:00
|
|
|
void QmlEngine::beginConnection(quint16 port)
|
2011-07-28 10:38:39 +02:00
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
m_noDebugOutputTimer.stop();
|
2012-03-22 13:00:56 +01:00
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
if (state() != EngineRunRequested && m_retryOnConnectFail)
|
2012-03-22 13:00:56 +01:00
|
|
|
return;
|
|
|
|
|
|
2012-04-17 08:01:25 +02:00
|
|
|
QTC_ASSERT(state() == EngineRunRequested, return);
|
2012-03-22 13:00:56 +01:00
|
|
|
|
2012-02-21 15:47:55 +01:00
|
|
|
if (port > 0) {
|
|
|
|
|
QTC_CHECK(startParameters().communicationChannel
|
|
|
|
|
== DebuggerStartParameters::CommunicationChannelTcpIp);
|
|
|
|
|
QTC_ASSERT(startParameters().connParams.port == 0
|
|
|
|
|
|| startParameters().connParams.port == port,
|
|
|
|
|
qWarning() << "Port " << port << "from application output does not match"
|
2012-04-17 08:01:25 +02:00
|
|
|
<< startParameters().connParams.port << "from start parameters.");
|
2012-05-09 14:56:04 +02:00
|
|
|
m_adapter.beginConnectionTcp(startParameters().qmlServerAddress, port);
|
2012-02-21 15:47:55 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (startParameters().communicationChannel
|
|
|
|
|
== DebuggerStartParameters::CommunicationChannelTcpIp) {
|
|
|
|
|
// no port from application output, use the one from start parameters ...
|
2012-05-09 14:56:04 +02:00
|
|
|
m_adapter.beginConnectionTcp(startParameters().qmlServerAddress,
|
2012-02-21 15:47:55 +01:00
|
|
|
startParameters().qmlServerPort);
|
|
|
|
|
} else {
|
|
|
|
|
QTC_CHECK(startParameters().communicationChannel
|
|
|
|
|
== DebuggerStartParameters::CommunicationChannelUsb);
|
2012-05-09 14:56:04 +02:00
|
|
|
m_adapter.beginConnectionOst(startParameters().remoteChannel);
|
2012-02-21 15:47:55 +01:00
|
|
|
}
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-14 15:33:33 +01:00
|
|
|
void QmlEngine::connectionStartupFailed()
|
2010-08-13 14:18:10 +02:00
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_retryOnConnectFail) {
|
2012-03-16 12:55:00 +01:00
|
|
|
// retry after 3 seconds ...
|
|
|
|
|
QTimer::singleShot(3000, this, SLOT(beginConnection()));
|
2012-03-14 15:28:01 +01:00
|
|
|
return;
|
|
|
|
|
}
|
2011-10-13 15:32:42 +02:00
|
|
|
|
2012-01-24 15:36:40 +01:00
|
|
|
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
|
2011-02-24 10:03:44 +01:00
|
|
|
infoBox->setIcon(QMessageBox::Critical);
|
|
|
|
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
2012-03-14 15:33:33 +01:00
|
|
|
infoBox->setText(tr("Could not connect to the in-process QML debugger."
|
|
|
|
|
"\nDo you want to retry?"));
|
|
|
|
|
infoBox->setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel |
|
|
|
|
|
QMessageBox::Help);
|
|
|
|
|
infoBox->setDefaultButton(QMessageBox::Retry);
|
2011-02-24 10:03:44 +01:00
|
|
|
infoBox->setModal(true);
|
|
|
|
|
|
|
|
|
|
connect(infoBox, SIGNAL(finished(int)),
|
2012-02-23 13:03:22 +01:00
|
|
|
this, SLOT(errorMessageBoxFinished(int)));
|
2011-02-24 10:03:44 +01:00
|
|
|
|
|
|
|
|
infoBox->show();
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-14 15:33:33 +01:00
|
|
|
void QmlEngine::appStartupFailed(const QString &errorMessage)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
|
|
|
|
|
infoBox->setIcon(QMessageBox::Critical);
|
|
|
|
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
|
|
|
|
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);
|
|
|
|
|
connect(infoBox, SIGNAL(finished(int)),
|
|
|
|
|
this, SLOT(errorMessageBoxFinished(int)));
|
|
|
|
|
infoBox->show();
|
|
|
|
|
|
|
|
|
|
notifyEngineRunFailed();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-23 13:03:22 +01:00
|
|
|
void QmlEngine::errorMessageBoxFinished(int result)
|
2011-02-24 10:03:44 +01:00
|
|
|
{
|
|
|
|
|
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();
|
2012-03-14 15:33:33 +01:00
|
|
|
} else if (state() == EngineRunRequested) {
|
2012-02-23 13:03:22 +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
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
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
|
2012-05-09 14:56:04 +02:00
|
|
|
QTC_ASSERT(m_sourceDocuments.contains(fileName), return);
|
2011-11-30 15:23:02 +01:00
|
|
|
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) {
|
2012-05-08 09:43:14 +02:00
|
|
|
editor = Core::EditorManager::openEditorWithContents(QmlJSEditor::Constants::C_QMLJSEDITOR_ID,
|
2011-11-30 15:23:02 +01:00
|
|
|
&titlePattern);
|
|
|
|
|
if (editor) {
|
|
|
|
|
editor->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
updateEditor(editor, m_sourceDocuments.value(fileName));
|
2011-12-21 10:39:54 +01:00
|
|
|
}
|
2012-05-08 09:43:14 +02:00
|
|
|
Core::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()));
|
2012-05-09 14:56:04 +02:00
|
|
|
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
|
|
|
|
2012-02-01 09:03:05 +01:00
|
|
|
if (!isSlaveEngine()) {
|
2012-02-27 10:04:34 +01:00
|
|
|
if (startParameters().startMode == AttachToRemoteServer)
|
2012-06-13 11:55:16 +02:00
|
|
|
m_noDebugOutputTimer.start();
|
|
|
|
|
else if (startParameters().startMode == AttachToRemoteProcess)
|
2012-02-27 10:04:34 +01:00
|
|
|
beginConnection();
|
|
|
|
|
else
|
2012-02-01 09:03:05 +01:00
|
|
|
startApplicationLauncher();
|
2012-03-14 15:28:01 +01:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
m_noDebugOutputTimer.start();
|
2012-02-01 09:03:05 +01:00
|
|
|
}
|
2010-11-15 17:09:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::startApplicationLauncher()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (!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);
|
2012-05-09 14:56:04 +02:00
|
|
|
m_applicationLauncher.start(ProjectExplorer::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()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_applicationLauncher.isRunning()) {
|
|
|
|
|
disconnect(&m_applicationLauncher, SIGNAL(processExited(int)),
|
|
|
|
|
this, SLOT(disconnected()));
|
|
|
|
|
m_applicationLauncher.stop();
|
2010-11-15 17:09:28 +01:00
|
|
|
}
|
2010-08-18 13:54:12 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-13 11:29:26 +02:00
|
|
|
void QmlEngine::notifyEngineRemoteSetupDone(int gdbServerPort, int qmlPort)
|
2010-09-16 17:08:07 +02:00
|
|
|
{
|
2011-02-11 16:02:41 +01:00
|
|
|
if (qmlPort != -1)
|
|
|
|
|
startParameters().qmlServerPort = qmlPort;
|
2012-01-31 13:23:05 +01:00
|
|
|
|
2012-06-13 11:29:26 +02:00
|
|
|
DebuggerEngine::notifyEngineRemoteSetupDone(gdbServerPort, qmlPort);
|
2012-01-13 15:00:04 +01:00
|
|
|
notifyEngineSetupOk();
|
2012-06-12 10:48:54 +02:00
|
|
|
|
|
|
|
|
// The remote setup can take while especialy with mixed debugging.
|
|
|
|
|
// Just waiting for 8 seconds is not enough. Increase the timeout
|
|
|
|
|
// to 60 s
|
|
|
|
|
// In case we get an output the m_outputParser will start the connection.
|
|
|
|
|
m_noDebugOutputTimer.setInterval(60000);
|
2010-09-16 17:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
2012-06-13 11:29:26 +02:00
|
|
|
void QmlEngine::notifyEngineRemoteSetupFailed(const QString &message)
|
2010-09-16 17:08:07 +02:00
|
|
|
{
|
2012-06-13 11:29:26 +02:00
|
|
|
DebuggerEngine::notifyEngineRemoteSetupFailed(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));
|
2012-01-31 13:23:05 +01:00
|
|
|
|
2012-01-13 15:00:04 +01:00
|
|
|
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
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
|
|
|
|
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();
|
2012-03-06 09:21:27 +01:00
|
|
|
closeConnection();
|
2011-08-17 13:42:41 +02:00
|
|
|
|
2010-07-09 17:07:59 +02:00
|
|
|
notifyInferiorShutdownOk();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::shutdownEngine()
|
|
|
|
|
{
|
2012-05-10 12:20:13 +02:00
|
|
|
m_noDebugOutputTimer.stop();
|
|
|
|
|
|
|
|
|
|
// double check (ill engine?):
|
2010-11-15 17:09:28 +01:00
|
|
|
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-06-13 11:29:26 +02:00
|
|
|
if (startParameters().remoteSetupNeeded) {
|
2012-01-13 15:00:04 +01:00
|
|
|
// we need to get the port first
|
2012-01-31 13:23:05 +01:00
|
|
|
notifyEngineRequestRemoteSetup();
|
2012-01-13 15:00:04 +01:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
m_applicationLauncher.setEnvironment(startParameters().environment);
|
|
|
|
|
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
|
2012-05-09 14:56:04 +02:00
|
|
|
connect(&m_applicationLauncher, SIGNAL(bringToForegroundRequested(qint64)),
|
2012-01-13 15:00:04 +01:00
|
|
|
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());
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->continueInferior();
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
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()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->interruptInferior();
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
2011-08-17 13:42:41 +02:00
|
|
|
notifyInferiorStopOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStep()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->executeStep();
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStepI()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->executeStepI();
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStepOut()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->executeStepOut();
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
2010-07-13 08:41:27 +02:00
|
|
|
notifyInferiorRunRequested();
|
|
|
|
|
notifyInferiorRunOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeNext()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->executeNext();
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
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();
|
2012-02-28 17:30:15 +01:00
|
|
|
ContextData modifiedData = data;
|
|
|
|
|
quint32 line = data.lineNumber;
|
|
|
|
|
quint32 column;
|
|
|
|
|
bool valid;
|
|
|
|
|
if (adjustBreakpointLineAndColumn(data.fileName, &line, &column, &valid))
|
|
|
|
|
modifiedData.lineNumber = line;
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
|
|
|
|
m_adapter.activeDebuggerClient()->executeRunToLine(modifiedData);
|
2011-12-22 18:43:09 +01:00
|
|
|
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;
|
|
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->activateFrame(index);
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
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);
|
|
|
|
|
|
2012-02-28 17:30:15 +01:00
|
|
|
const BreakpointParameters ¶ms = handler->breakpointData(id);
|
|
|
|
|
quint32 line = params.lineNumber;
|
|
|
|
|
quint32 column = 0;
|
|
|
|
|
if (params.type == BreakpointByFileAndLine) {
|
|
|
|
|
bool valid = false;
|
|
|
|
|
if (!adjustBreakpointLineAndColumn(params.fileName, &line, &column,
|
|
|
|
|
&valid)) {
|
2012-05-09 14:56:04 +02:00
|
|
|
pendingBreakpoints.insertMulti(params.fileName, id);
|
2012-02-28 17:30:15 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!valid)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->insertBreakpoint(id, line, column);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
foreach (BaseQmlDebuggerClient *client, m_adapter.debuggerClients()) {
|
2012-02-28 17:30:15 +01:00
|
|
|
client->insertBreakpoint(id, line, column);
|
2011-08-17 11:47:42 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::removeBreakpoint(BreakpointModelId id)
|
|
|
|
|
{
|
|
|
|
|
BreakHandler *handler = breakHandler();
|
2012-02-28 17:30:15 +01:00
|
|
|
|
|
|
|
|
const BreakpointParameters ¶ms = handler->breakpointData(id);
|
|
|
|
|
if (params.type == BreakpointByFileAndLine &&
|
2012-05-09 14:56:04 +02:00
|
|
|
pendingBreakpoints.contains(params.fileName)) {
|
2012-02-28 17:30:15 +01:00
|
|
|
QHash<QString, BreakpointModelId>::iterator i =
|
2012-05-09 14:56:04 +02:00
|
|
|
pendingBreakpoints.find(params.fileName);
|
|
|
|
|
while (i != pendingBreakpoints.end() && i.key() == params.fileName) {
|
2012-02-28 17:30:15 +01:00
|
|
|
if (i.value() == id) {
|
2012-05-09 14:56:04 +02:00
|
|
|
pendingBreakpoints.erase(i);
|
2012-02-28 17:30:15 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-17 11:47:42 +02:00
|
|
|
BreakpointState state = handler->state(id);
|
|
|
|
|
QTC_ASSERT(state == BreakpointRemoveRequested, qDebug() << id << this << state);
|
|
|
|
|
handler->notifyBreakpointRemoveProceeding(id);
|
|
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->removeBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
foreach (BaseQmlDebuggerClient *client, 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);
|
|
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->changeBreakpoint(id);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
foreach (BaseQmlDebuggerClient *client, 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
|
|
|
|
2012-03-02 12:24:19 +01:00
|
|
|
DebuggerEngine *bpOwner = isSlaveEngine() ? masterEngine() : this;
|
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))
|
2012-03-02 12:24:19 +01:00
|
|
|
handler->setEngine(id, bpOwner);
|
2010-11-23 16:12:16 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-02 12:24:19 +01:00
|
|
|
foreach (BreakpointModelId id, handler->engineBreakpointIds(bpOwner)) {
|
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
|
|
|
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->synchronizeBreakpoints();
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
foreach (BaseQmlDebuggerClient *client, 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
|
|
|
{
|
2012-01-24 16:41:30 +01:00
|
|
|
if (!breakHandler()->breakpointData(id).isCppBreakpoint())
|
2011-09-13 12:47:46 +02:00
|
|
|
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;
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
acceptBreakpoint = m_adapter.activeDebuggerClient()->acceptsBreakpoint(id);
|
2011-09-13 12:47:46 +02:00
|
|
|
}
|
|
|
|
|
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()
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->getSourceFiles();
|
2011-11-30 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2012-05-23 14:55:48 +02:00
|
|
|
if (!expression.isEmpty()) {
|
|
|
|
|
if (data->isInspect() && m_inspectorAdapter.agent())
|
|
|
|
|
m_inspectorAdapter.agent()->assignValue(data, expression, valueV);
|
|
|
|
|
else if (m_adapter.activeDebuggerClient())
|
|
|
|
|
m_adapter.activeDebuggerClient()->assignValueInDebugger(data, expression, valueV);
|
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();
|
2012-04-18 14:20:54 +02:00
|
|
|
//showStatusMessage(tr("Stopped."), 5000);
|
2010-06-25 14:08:53 +02:00
|
|
|
|
2012-05-15 09:46:24 +02:00
|
|
|
if (data.isInspect()) {
|
2012-05-09 14:56:04 +02:00
|
|
|
m_inspectorAdapter.agent()->updateWatchData(data);
|
2012-04-18 14:20:54 +02:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
if (!data.name.isEmpty() && m_adapter.activeDebuggerClient()) {
|
2012-04-18 14:20:54 +02:00
|
|
|
if (data.isValueNeeded()) {
|
2012-05-09 14:56:04 +02:00
|
|
|
m_adapter.activeDebuggerClient()->updateWatchData(data);
|
2012-04-18 14:20:54 +02:00
|
|
|
}
|
|
|
|
|
if (data.isChildrenNeeded()
|
|
|
|
|
&& watchHandler()->isExpandedIName(data.iname)) {
|
2012-05-09 14:56:04 +02:00
|
|
|
m_adapter.activeDebuggerClient()->expandObject(data.iname, data.id);
|
2012-04-18 14:20:54 +02:00
|
|
|
}
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
2012-04-18 14:20:54 +02:00
|
|
|
synchronizeWatchers();
|
2011-02-23 16:09:56 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-22 14:58:37 +02:00
|
|
|
|
2011-02-23 16:09:56 +01:00
|
|
|
if (!data.isSomethingNeeded())
|
2012-05-18 02:28:41 +02:00
|
|
|
watchHandler()->insertIncompleteData(data);
|
2011-02-23 16:09:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->synchronizeWatchers(watchedExpressions);
|
2011-08-17 11:47:42 +02:00
|
|
|
} else {
|
2012-05-09 14:56:04 +02:00
|
|
|
foreach (BaseQmlDebuggerClient *client, m_adapter.debuggerClients())
|
2011-07-26 16:22:49 +02:00
|
|
|
client->synchronizeWatchers(watchedExpressions);
|
|
|
|
|
}
|
2010-07-23 11:30:07 +02:00
|
|
|
}
|
|
|
|
|
|
2012-03-07 16:19:55 +01:00
|
|
|
void QmlEngine::expressionEvaluated(quint32 queryId, const QVariant &result)
|
2012-02-15 12:35:43 +01:00
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if (queryIds.contains(queryId)) {
|
|
|
|
|
queryIds.removeOne(queryId);
|
2012-03-21 15:06:18 +01:00
|
|
|
QtMessageLogItem *item = constructLogItemTree(qtMessageLogHandler()->root(),
|
2012-03-22 15:09:50 +01:00
|
|
|
result);
|
2012-02-16 15:58:40 +01:00
|
|
|
if (item)
|
|
|
|
|
qtMessageLogHandler()->appendItem(item);
|
2012-03-07 16:19:55 +01:00
|
|
|
}
|
2012-02-15 12:35:43 +01: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
|
|
|
}
|
|
|
|
|
|
2012-06-12 10:48:54 +02:00
|
|
|
void QmlEngine::quitDebugger()
|
|
|
|
|
{
|
|
|
|
|
m_noDebugOutputTimer.stop();
|
|
|
|
|
m_automaticConnect = false;
|
|
|
|
|
m_retryOnConnectFail = false;
|
|
|
|
|
DebuggerEngine::quitDebugger();
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-28 17:30:15 +01:00
|
|
|
void QmlEngine::documentUpdated(QmlJS::Document::Ptr doc)
|
|
|
|
|
{
|
|
|
|
|
QString fileName = doc->fileName();
|
2012-05-09 14:56:04 +02:00
|
|
|
if (pendingBreakpoints.contains(fileName)) {
|
|
|
|
|
QList<BreakpointModelId> ids = pendingBreakpoints.values(fileName);
|
|
|
|
|
pendingBreakpoints.remove(fileName);
|
2012-02-28 17:30:15 +01:00
|
|
|
foreach (const BreakpointModelId &id, ids)
|
|
|
|
|
insertBreakpoint(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-15 12:35:43 +01:00
|
|
|
void QmlEngine::updateCurrentContext()
|
|
|
|
|
{
|
|
|
|
|
const QString context = state() == InferiorStopOk ?
|
|
|
|
|
stackHandler()->currentFrame().function :
|
2012-05-09 14:56:04 +02:00
|
|
|
m_inspectorAdapter.currentSelectedDisplayName();
|
2012-02-15 12:35:43 +01:00
|
|
|
showMessage(tr("Context: ").append(context), QtMessageLogStatus);
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-22 11:50:05 +01:00
|
|
|
void QmlEngine::appendDebugOutput(QtMsgType type, const QString &message,
|
2012-04-18 12:06:10 +02:00
|
|
|
const QmlDebug::QDebugContextInfo &info)
|
2012-02-15 12:35:43 +01:00
|
|
|
{
|
|
|
|
|
QtMessageLogHandler::ItemType itemType;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case QtDebugMsg:
|
|
|
|
|
itemType = QtMessageLogHandler::DebugType;
|
|
|
|
|
break;
|
|
|
|
|
case QtWarningMsg:
|
|
|
|
|
itemType = QtMessageLogHandler::WarningType;
|
|
|
|
|
break;
|
|
|
|
|
case QtCriticalMsg:
|
|
|
|
|
case QtFatalMsg:
|
|
|
|
|
itemType = QtMessageLogHandler::ErrorType;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
//This case is not possible
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-03-21 15:06:18 +01:00
|
|
|
QtMessageLogItem *item = new QtMessageLogItem(qtMessageLogHandler()->root(),
|
|
|
|
|
itemType, message);
|
2012-02-22 11:50:05 +01:00
|
|
|
item->file = info.file;
|
|
|
|
|
item->line = info.line;
|
|
|
|
|
qtMessageLogHandler()->appendItem(item);
|
2012-02-15 12:35:43 +01:00
|
|
|
}
|
|
|
|
|
|
2012-04-10 09:36:15 +02:00
|
|
|
void QmlEngine::executeDebuggerCommand(const QString &command, DebuggerLanguages languages)
|
2010-08-26 16:02:41 +02:00
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
if ((languages & QmlLanguage) && m_adapter.activeDebuggerClient()) {
|
|
|
|
|
m_adapter.activeDebuggerClient()->executeDebuggerCommand(command);
|
2011-09-14 16:58:10 +02:00
|
|
|
}
|
2010-08-26 16:02:41 +02:00
|
|
|
}
|
|
|
|
|
|
2012-04-18 14:20:54 +02:00
|
|
|
bool QmlEngine::evaluateScriptExpression(const QString &expression)
|
2012-02-15 12:35:43 +01:00
|
|
|
{
|
|
|
|
|
bool didEvaluate = true;
|
|
|
|
|
//Check if string is only white spaces
|
|
|
|
|
if (!expression.trimmed().isEmpty()) {
|
2012-04-18 14:20:54 +02:00
|
|
|
//check if it can be evaluated
|
|
|
|
|
if (canEvaluateScript(expression)) {
|
|
|
|
|
//Evaluate expression based on engine state
|
|
|
|
|
//When engine->state() == InferiorStopOk, the expression
|
|
|
|
|
//is sent to V8DebugService. In all other cases, the
|
|
|
|
|
//expression is evaluated by QDeclarativeEngine.
|
|
|
|
|
if (state() != InferiorStopOk) {
|
2012-05-09 14:56:04 +02:00
|
|
|
QmlInspectorAgent *agent = m_inspectorAdapter.agent();
|
2012-04-18 14:20:54 +02:00
|
|
|
quint32 queryId
|
|
|
|
|
= agent->queryExpressionResult(
|
2012-05-09 14:56:04 +02:00
|
|
|
m_inspectorAdapter.currentSelectedDebugId(),
|
2012-04-18 14:20:54 +02:00
|
|
|
expression);
|
|
|
|
|
if (queryId) {
|
2012-05-09 14:56:04 +02:00
|
|
|
queryIds << queryId;
|
2012-02-15 12:35:43 +01:00
|
|
|
} else {
|
2012-04-18 14:20:54 +02:00
|
|
|
didEvaluate = false;
|
|
|
|
|
qtMessageLogHandler()->
|
|
|
|
|
appendItem(
|
|
|
|
|
new QtMessageLogItem(
|
|
|
|
|
qtMessageLogHandler()->root(),
|
|
|
|
|
QtMessageLogHandler::ErrorType,
|
|
|
|
|
_("Error evaluating expression.")));
|
2012-02-15 12:35:43 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
2012-04-18 14:20:54 +02:00
|
|
|
executeDebuggerCommand(expression, QmlLanguage);
|
2012-02-15 12:35:43 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
2012-04-18 14:20:54 +02:00
|
|
|
didEvaluate = false;
|
2012-02-15 12:35:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return didEvaluate;
|
|
|
|
|
}
|
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;
|
2012-02-22 11:50:05 +01:00
|
|
|
QString fullName = toFileInProject(file);
|
2011-11-30 15:23:02 +01:00
|
|
|
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;
|
2012-05-09 14:56:04 +02:00
|
|
|
if (m_sourceDocuments.contains(fileName)) {
|
|
|
|
|
document = m_sourceDocuments.value(fileName);
|
2011-11-30 15:23:02 +01:00
|
|
|
} else {
|
|
|
|
|
document = new QTextDocument(this);
|
2012-05-09 14:56:04 +02:00
|
|
|
m_sourceDocuments.insert(fileName, document);
|
2011-11-30 15:23:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
}
|
|
|
|
|
|
2012-02-15 12:35:43 +01:00
|
|
|
bool QmlEngine::canEvaluateScript(const QString &script)
|
|
|
|
|
{
|
2012-05-09 14:56:04 +02:00
|
|
|
m_interpreter.clearText();
|
|
|
|
|
m_interpreter.appendText(script);
|
|
|
|
|
return m_interpreter.canEvaluate();
|
2012-02-15 12:35:43 +01:00
|
|
|
}
|
|
|
|
|
|
2012-02-16 15:58:40 +01:00
|
|
|
QtMessageLogItem *QmlEngine::constructLogItemTree(
|
2012-03-21 15:06:18 +01:00
|
|
|
QtMessageLogItem *parent, const QVariant &result, const QString &key)
|
2012-02-16 15:58:40 +01:00
|
|
|
{
|
|
|
|
|
if (!result.isValid())
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-03-21 15:06:18 +01:00
|
|
|
QtMessageLogItem *item = new QtMessageLogItem(parent);
|
2012-02-16 15:58:40 +01:00
|
|
|
if (result.type() == QVariant::Map) {
|
|
|
|
|
if (key.isEmpty())
|
2012-05-07 11:16:03 +02:00
|
|
|
item->setText(_("Object"));
|
2012-02-16 15:58:40 +01:00
|
|
|
else
|
2012-05-07 11:16:03 +02:00
|
|
|
item->setText(key + _(" : Object"));
|
2012-02-16 15:58:40 +01:00
|
|
|
|
|
|
|
|
QMapIterator<QString, QVariant> i(result.toMap());
|
|
|
|
|
while (i.hasNext()) {
|
|
|
|
|
i.next();
|
2012-03-21 15:06:18 +01:00
|
|
|
QtMessageLogItem *child = constructLogItemTree(item,
|
|
|
|
|
i.value(), i.key());
|
2012-02-16 15:58:40 +01:00
|
|
|
if (child)
|
2012-03-22 12:00:47 +01:00
|
|
|
item->insertChild(child);
|
2012-02-16 15:58:40 +01:00
|
|
|
}
|
|
|
|
|
} else if (result.type() == QVariant::List) {
|
|
|
|
|
if (key.isEmpty())
|
2012-05-07 11:16:03 +02:00
|
|
|
item->setText(_("List"));
|
2012-02-16 15:58:40 +01:00
|
|
|
else
|
2012-05-07 11:16:03 +02:00
|
|
|
item->setText(QString(_("[%1] : List")).arg(key));
|
2012-02-16 15:58:40 +01:00
|
|
|
QVariantList resultList = result.toList();
|
|
|
|
|
for (int i = 0; i < resultList.count(); i++) {
|
2012-03-21 15:06:18 +01:00
|
|
|
QtMessageLogItem *child = constructLogItemTree(item, resultList.at(i),
|
2012-02-16 15:58:40 +01:00
|
|
|
QString::number(i));
|
|
|
|
|
if (child)
|
2012-03-22 12:00:47 +01:00
|
|
|
item->insertChild(child);
|
2012-02-16 15:58:40 +01:00
|
|
|
}
|
|
|
|
|
} else if (result.canConvert(QVariant::String)) {
|
2012-05-07 11:16:03 +02:00
|
|
|
item->setText(result.toString());
|
2012-02-16 15:58:40 +01:00
|
|
|
} else {
|
2012-05-07 11:16:03 +02:00
|
|
|
item->setText(_("Unknown Value"));
|
2012-02-16 15:58:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-28 17:30:15 +01:00
|
|
|
bool QmlEngine::adjustBreakpointLineAndColumn(
|
|
|
|
|
const QString &filePath, quint32 *line, quint32 *column, bool *valid)
|
|
|
|
|
{
|
|
|
|
|
bool success = true;
|
|
|
|
|
//check if file is in the latest snapshot
|
|
|
|
|
//ignoring documentChangedOnDisk
|
|
|
|
|
//TODO:: update breakpoints if document is changed.
|
|
|
|
|
Document::Ptr doc = ModelManagerInterface::instance()->newestSnapshot().
|
|
|
|
|
document(filePath);
|
|
|
|
|
if (doc.isNull()) {
|
|
|
|
|
ModelManagerInterface::instance()->updateSourceFiles(
|
|
|
|
|
QStringList() << filePath, false);
|
|
|
|
|
success = false;
|
|
|
|
|
} else {
|
|
|
|
|
ASTWalker walker;
|
|
|
|
|
walker(doc->ast(), line, column);
|
|
|
|
|
*valid = walker.done;
|
|
|
|
|
}
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|