2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-06-09 16:13:47 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2010-06-09 16:13:47 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-06-09 16:13:47 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2010-06-09 16:13:47 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** General Public License version 2.1 or version 3 as published by the Free
|
|
|
|
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
|
|
|
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
|
|
|
|
** following information to ensure the GNU Lesser General Public License
|
|
|
|
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
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
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/debuggeractions.h>
|
|
|
|
|
#include <debugger/debuggercore.h>
|
|
|
|
|
#include <debugger/debuggerinternalconstants.h>
|
|
|
|
|
#include <debugger/debuggermainwindow.h>
|
2014-10-17 13:40:04 +02:00
|
|
|
#include <debugger/debuggerruncontrol.h>
|
|
|
|
|
#include <debugger/debuggerstartparameters.h>
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/debuggerstringutils.h>
|
|
|
|
|
#include <debugger/debuggertooltipmanager.h>
|
|
|
|
|
#include <debugger/localsandexpressionswindow.h>
|
|
|
|
|
#include <debugger/watchwindow.h>
|
2010-06-16 11:08:54 +02:00
|
|
|
|
2013-08-29 16:36:42 +02:00
|
|
|
#include <debugger/breakhandler.h>
|
|
|
|
|
#include <debugger/stackhandler.h>
|
|
|
|
|
#include <debugger/watchhandler.h>
|
|
|
|
|
#include <debugger/sourcefileshandler.h>
|
2014-10-17 13:40:04 +02:00
|
|
|
|
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>
|
2012-10-08 13:17:10 +02:00
|
|
|
#include <qmljs/consolemanagerinterface.h>
|
2010-07-01 11:48:43 +02:00
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
|
2014-09-26 09:14:03 +02:00
|
|
|
#include <texteditor/textdocument.h>
|
|
|
|
|
#include <texteditor/texteditor.h>
|
2011-11-30 15:23:02 +01:00
|
|
|
#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>
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QDir>
|
2014-10-17 13:40:04 +02:00
|
|
|
#include <QDockWidget>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPlainTextEdit>
|
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 {
|
|
|
|
|
|
2014-06-04 14:45:10 +02:00
|
|
|
static QTreeView *inspectorTreeView()
|
|
|
|
|
{
|
2014-10-22 13:04:47 +02:00
|
|
|
return Internal::inspectorView();
|
2014-06-04 14:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
2012-10-08 13:17:10 +02:00
|
|
|
QmlJS::ConsoleManagerInterface *qmlConsoleManager()
|
|
|
|
|
{
|
|
|
|
|
return QmlJS::ConsoleManagerInterface::instance();
|
|
|
|
|
}
|
|
|
|
|
|
2010-06-09 16:13:47 +02:00
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// QmlEngine
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2012-11-27 17:16:57 +01:00
|
|
|
QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters, DebuggerEngine *masterEngine)
|
2012-08-15 14:33:39 +02:00
|
|
|
: DebuggerEngine(startParameters)
|
2012-05-09 14:56:04 +02:00
|
|
|
, 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-11-27 17:16:57 +01:00
|
|
|
if (masterEngine)
|
|
|
|
|
setMasterEngine(masterEngine);
|
|
|
|
|
|
2014-05-05 17:18:11 +02:00
|
|
|
connect(&m_adapter, SIGNAL(connectionError(QDebugSupport::Error)),
|
|
|
|
|
SLOT(connectionError(QDebugSupport::Error)));
|
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-11-27 17:16:57 +01:00
|
|
|
connect(stackHandler(), SIGNAL(stackChanged()),
|
2012-02-15 12:35:43 +01:00
|
|
|
SLOT(updateCurrentContext()));
|
2012-11-27 17:16:57 +01:00
|
|
|
connect(stackHandler(), SIGNAL(currentIndexChanged()),
|
2012-02-15 12:35:43 +01:00
|
|
|
SLOT(updateCurrentContext()));
|
2012-10-05 13:42:14 +02:00
|
|
|
connect(inspectorTreeView(), SIGNAL(currentIndexChanged(QModelIndex)),
|
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,
|
2013-10-10 17:41:34 +02:00
|
|
|
SIGNAL(processExited(int,QProcess::ExitStatus)),
|
2011-07-28 17:04:35 +02:00
|
|
|
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(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
|
|
|
|
2012-10-08 13:17:10 +02:00
|
|
|
ModelManagerInterface *mmIface = ModelManagerInterface::instance();
|
|
|
|
|
if (mmIface) {
|
|
|
|
|
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
|
|
|
}
|
2012-10-08 13:17:10 +02:00
|
|
|
if (qmlConsoleManager())
|
|
|
|
|
qmlConsoleManager()->setScriptEvaluator(this);
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QmlEngine::~QmlEngine()
|
2011-07-06 19:07:38 +02:00
|
|
|
{
|
2014-08-15 16:23:32 +02:00
|
|
|
QSet<Core::IDocument *> documentsToClose;
|
2011-11-30 15:23:02 +01:00
|
|
|
|
2014-07-23 19:10:38 +02:00
|
|
|
QHash<QString, QWeakPointer<TextEditor::BaseTextEditor> >::iterator iter;
|
2012-05-09 14:56:04 +02:00
|
|
|
for (iter = m_sourceEditors.begin(); iter != m_sourceEditors.end(); ++iter) {
|
2014-07-23 19:10:38 +02:00
|
|
|
QWeakPointer<TextEditor::BaseTextEditor> textEditPtr = iter.value();
|
2011-11-30 15:23:02 +01:00
|
|
|
if (textEditPtr)
|
2014-08-15 16:23:32 +02:00
|
|
|
documentsToClose << textEditPtr.data()->document();
|
2011-11-30 15:23:02 +01:00
|
|
|
}
|
2014-08-15 16:23:32 +02:00
|
|
|
Core::EditorManager::closeDocuments(documentsToClose.toList());
|
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();
|
|
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (!watchHandler()->watcherNames().isEmpty())
|
2011-04-21 12:25:06 +02:00
|
|
|
synchronizeWatchers();
|
2013-08-17 00:59:42 +02:00
|
|
|
connect(watchModel(),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.
|
2013-04-10 15:03:02 +02:00
|
|
|
if (!masterEngine()->isDying()) {
|
|
|
|
|
m_noDebugOutputTimer.setInterval(4000);
|
2012-06-12 10:48:54 +02:00
|
|
|
m_noDebugOutputTimer.start();
|
2013-04-10 15:03:02 +02:00
|
|
|
}
|
2012-06-12 10:48:54 +02:00
|
|
|
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-11-06 15:46:19 +01:00
|
|
|
QString host = startParameters().qmlServerAddress;
|
|
|
|
|
// Use localhost as default
|
|
|
|
|
if (host.isEmpty())
|
|
|
|
|
host = QLatin1String("localhost");
|
|
|
|
|
|
2013-07-11 12:04:34 +02:00
|
|
|
/*
|
|
|
|
|
* Let plugin-specific code override the port printed by the application. This is necessary
|
|
|
|
|
* in the case of port forwarding, when the port the application listens on is not the same that
|
|
|
|
|
* we want to connect to.
|
|
|
|
|
* NOTE: It is still necessary to wait for the output in that case, because otherwise we cannot
|
|
|
|
|
* be sure that the port is already open. The usual method of trying to connect repeatedly
|
|
|
|
|
* will not work, because the intermediate port is already open. So the connection
|
|
|
|
|
* will be accepted on that port but the forwarding to the target port will fail and
|
|
|
|
|
* the connection will be closed again (instead of returning the "connection refused"
|
|
|
|
|
* error that we expect).
|
|
|
|
|
*/
|
|
|
|
|
if (startParameters().qmlServerPort > 0)
|
|
|
|
|
port = startParameters().qmlServerPort;
|
|
|
|
|
|
|
|
|
|
m_adapter.beginConnectionTcp(host, port);
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-11 12:04:34 +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)
|
|
|
|
|
{
|
2014-03-18 12:55:26 +01:00
|
|
|
QString error = tr("Could not connect to the in-process QML debugger."
|
|
|
|
|
"\n%1").arg(errorMessage);
|
|
|
|
|
|
|
|
|
|
if (isMasterEngine()) {
|
|
|
|
|
QMessageBox *infoBox = new QMessageBox(Core::ICore::mainWindow());
|
|
|
|
|
infoBox->setIcon(QMessageBox::Critical);
|
|
|
|
|
infoBox->setWindowTitle(tr("Qt Creator"));
|
|
|
|
|
infoBox->setText(error);
|
|
|
|
|
infoBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Help);
|
|
|
|
|
infoBox->setDefaultButton(QMessageBox::Ok);
|
|
|
|
|
connect(infoBox, SIGNAL(finished(int)),
|
|
|
|
|
this, SLOT(errorMessageBoxFinished(int)));
|
|
|
|
|
infoBox->show();
|
|
|
|
|
} else {
|
|
|
|
|
showMessage(error, StatusBar);
|
|
|
|
|
}
|
2012-03-14 15:33:33 +01:00
|
|
|
|
|
|
|
|
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: {
|
2013-08-29 19:00:34 +02:00
|
|
|
Core::HelpManager::handleHelpRequest(QLatin1String("qthelp://org.qt-project.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
|
|
|
}
|
|
|
|
|
|
2014-05-05 17:18:11 +02:00
|
|
|
void QmlEngine::connectionError(QDebugSupport::Error error)
|
2010-08-13 14:18:10 +02:00
|
|
|
{
|
2014-05-05 17:18:11 +02:00
|
|
|
if (error == QDebugSupport::RemoteClosedConnectionError)
|
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)
|
|
|
|
|
{
|
2014-04-17 14:09:47 +02:00
|
|
|
showMessage(tr("QML Debugger: Could not connect to service \"%1\".")
|
2010-11-10 11:39:01 +01:00
|
|
|
.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
|
|
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (channel == AppOutput || channel == AppError)
|
2011-02-21 17:01:40 +01:00
|
|
|
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();
|
2013-04-25 13:05:27 +02:00
|
|
|
if (QUrl(fileName).isLocalFile()) {
|
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
|
|
|
|
2011-12-21 10:22:55 +01:00
|
|
|
QString titlePattern = tr("JS Source for %1").arg(fileName);
|
2013-07-09 12:14:33 +02:00
|
|
|
//Check if there are open documents with the same title
|
2014-05-07 16:25:04 +02:00
|
|
|
foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) {
|
2013-07-09 12:14:33 +02:00
|
|
|
if (document->displayName() == titlePattern) {
|
2013-08-29 15:46:04 +02:00
|
|
|
Core::EditorManager::activateEditorForDocument(document);
|
2013-07-09 12:14:33 +02:00
|
|
|
return;
|
2011-12-21 10:22:55 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-07-09 12:14:33 +02:00
|
|
|
Core::IEditor *editor = Core::EditorManager::openEditorWithContents(
|
|
|
|
|
QmlJSEditor::Constants::C_QMLJSEDITOR_ID, &titlePattern);
|
|
|
|
|
if (editor) {
|
|
|
|
|
editor->document()->setProperty(Constants::OPENED_BY_DEBUGGER, true);
|
|
|
|
|
QPlainTextEdit *plainTextEdit =
|
|
|
|
|
qobject_cast<QPlainTextEdit *>(editor->widget());
|
|
|
|
|
if (plainTextEdit)
|
|
|
|
|
plainTextEdit->setReadOnly(true);
|
|
|
|
|
updateDocument(editor->document(), m_sourceDocuments.value(fileName));
|
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()
|
|
|
|
|
{
|
2013-08-17 00:59:42 +02:00
|
|
|
disconnect(watchModel(),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()) {
|
2013-08-01 17:38:49 +02:00
|
|
|
disconnect(&m_applicationLauncher, SIGNAL(processExited(int,QProcess::ExitStatus)),
|
2012-05-09 14:56:04 +02:00
|
|
|
this, SLOT(disconnected()));
|
|
|
|
|
m_applicationLauncher.stop();
|
2010-11-15 17:09:28 +01:00
|
|
|
}
|
2010-08-18 13:54:12 +02:00
|
|
|
}
|
|
|
|
|
|
2014-09-18 19:21:27 +02:00
|
|
|
void QmlEngine::notifyEngineRemoteSetupFinished(const RemoteSetupResult &result)
|
2010-09-16 17:08:07 +02:00
|
|
|
{
|
2014-09-18 19:21:27 +02:00
|
|
|
DebuggerEngine::notifyEngineRemoteSetupFinished(result);
|
2012-06-12 10:48:54 +02:00
|
|
|
|
2014-09-18 19:21:27 +02:00
|
|
|
if (result.success) {
|
|
|
|
|
if (result.qmlServerPort != InvalidPort)
|
|
|
|
|
startParameters().qmlServerPort = result.qmlServerPort;
|
2010-09-16 17:08:07 +02:00
|
|
|
|
2014-09-18 19:21:27 +02:00
|
|
|
notifyEngineSetupOk();
|
2012-01-31 13:23:05 +01:00
|
|
|
|
2014-09-18 19:21:27 +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);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if (isMasterEngine())
|
|
|
|
|
QMessageBox::critical(Core::ICore::dialogParent(), tr("Failed to start application"),
|
|
|
|
|
tr("Application startup failed: %1").arg(result.reason));
|
|
|
|
|
notifyEngineSetupFailed();
|
|
|
|
|
}
|
2010-09-16 17:08:07 +02:00
|
|
|
}
|
|
|
|
|
|
2013-04-18 10:01:05 +02:00
|
|
|
void QmlEngine::notifyEngineRemoteServerRunning(const QByteArray &serverChannel, int pid)
|
|
|
|
|
{
|
|
|
|
|
bool ok = false;
|
|
|
|
|
quint16 qmlPort = serverChannel.toUInt(&ok);
|
|
|
|
|
if (ok)
|
|
|
|
|
startParameters().qmlServerPort = qmlPort;
|
|
|
|
|
else
|
2013-06-05 09:39:11 +02:00
|
|
|
qWarning() << tr("QML debugging port not set: Unable to convert %1 to unsigned int.").arg(QString::fromLatin1(serverChannel));
|
2013-04-18 10:01:05 +02:00
|
|
|
|
|
|
|
|
DebuggerEngine::notifyEngineRemoteServerRunning(serverChannel, pid);
|
|
|
|
|
notifyEngineSetupOk();
|
|
|
|
|
|
|
|
|
|
// The remote setup can take a while especially 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-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
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (isSlaveEngine())
|
2010-11-15 17:09:28 +01:00
|
|
|
resetLocation();
|
|
|
|
|
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()
|
|
|
|
|
{
|
2013-07-16 14:17:32 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
|
|
|
|
m_adapter.activeDebuggerClient()->resetSession();
|
|
|
|
|
|
2012-10-08 13:17:10 +02:00
|
|
|
if (qmlConsoleManager())
|
|
|
|
|
qmlConsoleManager()->setScriptEvaluator(0);
|
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());
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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()
|
|
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
m_adapter.activeDebuggerClient()->interruptInferior();
|
2011-08-17 13:42:41 +02:00
|
|
|
notifyInferiorStopOk();
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void QmlEngine::executeStep()
|
|
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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()
|
|
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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()
|
|
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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()
|
|
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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());
|
2012-08-28 13:18:50 +02:00
|
|
|
showStatusMessage(tr("Run to line %1 (%2) requested...").arg(data.lineNumber).arg(data.fileName), 5000);
|
2011-12-22 18:43:09 +01:00
|
|
|
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;
|
|
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2012-10-19 16:37:57 +02:00
|
|
|
void QmlEngine::selectThread(ThreadId threadId)
|
2010-06-09 16:13:47 +02:00
|
|
|
{
|
2012-10-19 16:37:57 +02:00
|
|
|
Q_UNUSED(threadId)
|
2010-06-09 16:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (handler->state(id) == BreakpointRemoveProceeding)
|
2011-08-17 11:47:42 +02:00
|
|
|
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
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (handler->state(id) == BreakpointChangeProceeding)
|
2011-08-17 11:47:42 +02:00
|
|
|
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;
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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()
|
|
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
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
|
|
|
|
|
//
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2014-09-26 11:37:54 +02:00
|
|
|
bool QmlEngine::setToolTipExpression(TextEditor::TextEditorWidget *editorWidget,
|
2014-07-08 18:16:54 +02:00
|
|
|
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.
|
2014-09-19 15:26:41 +02:00
|
|
|
emit tooltipRequested(ctx.mousePosition, editorWidget, 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()) {
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!data.isSomethingNeeded())
|
2012-10-09 16:13:29 +02:00
|
|
|
watchHandler()->insertData(data);
|
2011-02-23 16:09:56 +01:00
|
|
|
}
|
|
|
|
|
|
2012-11-23 13:35:44 +01:00
|
|
|
void QmlEngine::watchDataSelected(const QByteArray &iname)
|
|
|
|
|
{
|
|
|
|
|
const WatchData *wd = watchHandler()->findData(iname);
|
|
|
|
|
if (wd && wd->isInspect())
|
|
|
|
|
m_inspectorAdapter.agent()->watchDataSelected(wd);
|
|
|
|
|
}
|
|
|
|
|
|
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-10-08 13:17:10 +02:00
|
|
|
QmlJS::ConsoleItem *constructLogItemTree(QmlJS::ConsoleItem *parent,
|
2012-10-04 14:54:59 +02:00
|
|
|
const QVariant &result,
|
|
|
|
|
const QString &key = QString())
|
|
|
|
|
{
|
2012-10-08 13:17:10 +02:00
|
|
|
using namespace QmlJS;
|
2014-07-28 14:23:52 +02:00
|
|
|
bool sorted = boolSetting(SortStructMembers);
|
2012-10-04 14:54:59 +02:00
|
|
|
if (!result.isValid())
|
|
|
|
|
return 0;
|
|
|
|
|
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleItem *item = new ConsoleItem(parent);
|
2012-10-04 14:54:59 +02:00
|
|
|
if (result.type() == QVariant::Map) {
|
|
|
|
|
if (key.isEmpty())
|
|
|
|
|
item->setText(_("Object"));
|
|
|
|
|
else
|
|
|
|
|
item->setText(key + _(" : Object"));
|
|
|
|
|
|
|
|
|
|
QMapIterator<QString, QVariant> i(result.toMap());
|
|
|
|
|
while (i.hasNext()) {
|
|
|
|
|
i.next();
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleItem *child = constructLogItemTree(item, i.value(), i.key());
|
2012-10-04 14:54:59 +02:00
|
|
|
if (child)
|
|
|
|
|
item->insertChild(child, sorted);
|
|
|
|
|
}
|
|
|
|
|
} else if (result.type() == QVariant::List) {
|
|
|
|
|
if (key.isEmpty())
|
|
|
|
|
item->setText(_("List"));
|
|
|
|
|
else
|
|
|
|
|
item->setText(QString(_("[%1] : List")).arg(key));
|
|
|
|
|
QVariantList resultList = result.toList();
|
|
|
|
|
for (int i = 0; i < resultList.count(); i++) {
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleItem *child = constructLogItemTree(item, resultList.at(i),
|
2012-10-04 14:54:59 +02:00
|
|
|
QString::number(i));
|
|
|
|
|
if (child)
|
|
|
|
|
item->insertChild(child, sorted);
|
|
|
|
|
}
|
|
|
|
|
} else if (result.canConvert(QVariant::String)) {
|
|
|
|
|
item->setText(result.toString());
|
|
|
|
|
} else {
|
|
|
|
|
item->setText(_("Unknown Value"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return item;
|
|
|
|
|
}
|
|
|
|
|
|
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-10-08 13:17:10 +02:00
|
|
|
using namespace QmlJS;
|
|
|
|
|
ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
2012-10-04 14:54:59 +02:00
|
|
|
if (consoleManager) {
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleItem *item = constructLogItemTree(consoleManager->rootItem(), result);
|
2012-10-04 14:54:59 +02:00
|
|
|
if (item)
|
|
|
|
|
consoleManager->printToConsolePane(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()
|
|
|
|
|
{
|
2012-10-05 13:42:14 +02:00
|
|
|
QString context;
|
|
|
|
|
if (state() == InferiorStopOk) {
|
|
|
|
|
context = stackHandler()->currentFrame().function;
|
|
|
|
|
} else {
|
|
|
|
|
QModelIndex currentIndex = inspectorTreeView()->currentIndex();
|
|
|
|
|
const WatchData *currentData = watchHandler()->watchData(currentIndex);
|
|
|
|
|
const WatchData *parentData = watchHandler()->watchData(currentIndex.parent());
|
|
|
|
|
const WatchData *grandParentData = watchHandler()->watchData(
|
|
|
|
|
currentIndex.parent().parent());
|
|
|
|
|
if (currentData->id != parentData->id)
|
|
|
|
|
context = currentData->name;
|
|
|
|
|
else if (parentData->id != grandParentData->id)
|
|
|
|
|
context = parentData->name;
|
|
|
|
|
else
|
|
|
|
|
context = grandParentData->name;
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-21 16:58:39 +01:00
|
|
|
synchronizeWatchers();
|
|
|
|
|
|
2012-10-08 13:17:10 +02:00
|
|
|
QmlJS::ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
2012-10-04 14:54:59 +02:00
|
|
|
if (consoleManager)
|
2013-10-17 14:52:10 +02:00
|
|
|
consoleManager->setContext(tr("Context:") + QLatin1Char(' ') + context);
|
2012-02-15 12:35:43 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
{
|
2012-10-08 13:17:10 +02:00
|
|
|
using namespace QmlJS;
|
|
|
|
|
ConsoleItem::ItemType itemType;
|
2012-02-15 12:35:43 +01:00
|
|
|
switch (type) {
|
|
|
|
|
case QtDebugMsg:
|
2012-10-08 13:17:10 +02:00
|
|
|
itemType = ConsoleItem::DebugType;
|
2012-02-15 12:35:43 +01:00
|
|
|
break;
|
|
|
|
|
case QtWarningMsg:
|
2012-10-08 13:17:10 +02:00
|
|
|
itemType = ConsoleItem::WarningType;
|
2012-02-15 12:35:43 +01:00
|
|
|
break;
|
|
|
|
|
case QtCriticalMsg:
|
|
|
|
|
case QtFatalMsg:
|
2012-10-08 13:17:10 +02:00
|
|
|
itemType = ConsoleItem::ErrorType;
|
2012-02-15 12:35:43 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
//This case is not possible
|
|
|
|
|
return;
|
|
|
|
|
}
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
2012-10-04 14:54:59 +02:00
|
|
|
if (consoleManager) {
|
2012-10-08 13:17:10 +02:00
|
|
|
ConsoleItem *item = new ConsoleItem(consoleManager->rootItem(), itemType, message);
|
2012-10-04 14:54:59 +02:00
|
|
|
item->file = info.file;
|
|
|
|
|
item->line = info.line;
|
|
|
|
|
consoleManager->printToConsolePane(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
|
|
|
{
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if ((languages & QmlLanguage) && m_adapter.activeDebuggerClient())
|
2012-05-09 14:56:04 +02:00
|
|
|
m_adapter.activeDebuggerClient()->executeDebuggerCommand(command);
|
2010-08-26 16:02:41 +02:00
|
|
|
}
|
|
|
|
|
|
2012-10-08 13:17:10 +02:00
|
|
|
bool QmlEngine::evaluateScript(const QString &expression)
|
2012-02-15 12:35:43 +01:00
|
|
|
{
|
|
|
|
|
bool didEvaluate = true;
|
2012-10-04 14:54:59 +02:00
|
|
|
// Evaluate expression based on engine state
|
|
|
|
|
// When engine->state() == InferiorStopOk, the expression is sent to debuggerClient.
|
|
|
|
|
if (state() != InferiorStopOk) {
|
2012-10-05 13:42:14 +02:00
|
|
|
QModelIndex currentIndex = inspectorTreeView()->currentIndex();
|
2012-10-04 14:54:59 +02:00
|
|
|
QmlInspectorAgent *agent = m_inspectorAdapter.agent();
|
2012-10-05 13:42:14 +02:00
|
|
|
quint32 queryId = agent->queryExpressionResult(watchHandler()->watchData(currentIndex)->id,
|
2012-10-04 14:54:59 +02:00
|
|
|
expression);
|
|
|
|
|
if (queryId) {
|
|
|
|
|
queryIds << queryId;
|
2012-02-15 12:35:43 +01:00
|
|
|
} else {
|
2012-04-18 14:20:54 +02:00
|
|
|
didEvaluate = false;
|
2012-10-08 13:17:10 +02:00
|
|
|
using namespace QmlJS;
|
|
|
|
|
ConsoleManagerInterface *consoleManager = qmlConsoleManager();
|
2012-10-04 14:54:59 +02:00
|
|
|
if (consoleManager) {
|
2012-10-08 13:17:10 +02:00
|
|
|
consoleManager->printToConsolePane(ConsoleItem::ErrorType,
|
2012-10-04 14:54:59 +02:00
|
|
|
_("Error evaluating expression."));
|
|
|
|
|
}
|
2012-02-15 12:35:43 +01:00
|
|
|
}
|
2012-10-04 14:54:59 +02:00
|
|
|
} else {
|
|
|
|
|
executeDebuggerCommand(expression, QmlLanguage);
|
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
|
2014-05-07 16:25:04 +02:00
|
|
|
foreach (Core::IDocument *doc, Core::DocumentModel::openedDocuments()) {
|
2013-07-09 12:14:33 +02:00
|
|
|
if (doc->displayName() == titlePattern) {
|
|
|
|
|
updateDocument(doc, document);
|
2011-12-21 10:39:54 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-09 12:14:33 +02:00
|
|
|
void QmlEngine::updateDocument(Core::IDocument *document, const QTextDocument *textDocument)
|
2011-12-21 10:39:54 +01:00
|
|
|
{
|
2014-09-22 18:43:31 +02:00
|
|
|
TextEditor::TextDocument *baseTextDocument
|
|
|
|
|
= qobject_cast<TextEditor::TextDocument *>(document);
|
2013-07-09 12:14:33 +02:00
|
|
|
if (!baseTextDocument)
|
2011-12-21 10:39:54 +01:00
|
|
|
return;
|
|
|
|
|
|
2013-07-09 12:14:33 +02:00
|
|
|
baseTextDocument->document()->setPlainText(textDocument->toPlainText());
|
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-28 17:30:15 +01:00
|
|
|
bool QmlEngine::adjustBreakpointLineAndColumn(
|
|
|
|
|
const QString &filePath, quint32 *line, quint32 *column, bool *valid)
|
|
|
|
|
{
|
2012-10-08 13:17:10 +02:00
|
|
|
bool success = false;
|
2012-02-28 17:30:15 +01:00
|
|
|
//check if file is in the latest snapshot
|
|
|
|
|
//ignoring documentChangedOnDisk
|
|
|
|
|
//TODO:: update breakpoints if document is changed.
|
2012-10-08 13:17:10 +02:00
|
|
|
ModelManagerInterface *mmIface = ModelManagerInterface::instance();
|
|
|
|
|
if (mmIface) {
|
|
|
|
|
Document::Ptr doc = mmIface->newestSnapshot().
|
|
|
|
|
document(filePath);
|
|
|
|
|
if (doc.isNull()) {
|
|
|
|
|
ModelManagerInterface::instance()->updateSourceFiles(
|
|
|
|
|
QStringList() << filePath, false);
|
|
|
|
|
} else {
|
|
|
|
|
ASTWalker walker;
|
|
|
|
|
walker(doc->ast(), line, column);
|
|
|
|
|
*valid = walker.done;
|
|
|
|
|
success = true;
|
|
|
|
|
}
|
2012-02-28 17:30:15 +01:00
|
|
|
}
|
|
|
|
|
return success;
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-15 14:33:39 +02:00
|
|
|
DebuggerEngine *createQmlEngine(const DebuggerStartParameters &sp)
|
2011-01-12 12:10:12 +01:00
|
|
|
{
|
2012-08-15 14:33:39 +02:00
|
|
|
return new QmlEngine(sp);
|
2011-01-12 12:10:12 +01:00
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|