forked from qt-creator/qt-creator
Debugger: Fix QML-only debugging on Harmattan
Actually wait for the 'Waiting for debugger on port ' ... message to appear in the application output before connecting, and also use the port specified there. Change-Id: Ib498e5306bc49f2f3d468353b1c5d1ea38a809e6 Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
|
||||
#include "qdeclarativeoutputparser.h"
|
||||
#include "qmljsdebugclientconstants.h"
|
||||
#include <QRegExp>
|
||||
|
||||
namespace QmlJsDebugClient {
|
||||
|
||||
@@ -70,7 +71,22 @@ void QDeclarativeOutputParser::processOutput(const QString &output)
|
||||
static QString connectionEstablished = QLatin1String(Constants::STR_CONNECTION_ESTABLISHED);
|
||||
|
||||
if (status.startsWith(waitingForConnection)) {
|
||||
emit waitingForConnectionMessage();
|
||||
status.remove(0, waitingForConnection.size()); // chop of 'Waiting for connection '
|
||||
|
||||
static QRegExp waitingTcp(
|
||||
QString::fromLatin1(Constants::STR_ON_PORT_PATTERN));
|
||||
if (waitingTcp.indexIn(status) > -1) {
|
||||
bool canConvert;
|
||||
quint16 port = waitingTcp.cap(1).toUShort(&canConvert);
|
||||
if (canConvert)
|
||||
emit waitingForConnectionOnPort(port);
|
||||
continue;
|
||||
}
|
||||
|
||||
static QString waitingOst
|
||||
= QLatin1String(Constants::STR_VIA_OST);
|
||||
if (status.startsWith(waitingOst))
|
||||
emit waitingForConnectionViaOst();
|
||||
} else if (status.startsWith(unableToListen)) {
|
||||
//: Error message shown after 'Could not connect ... debugger:"
|
||||
emit errorMessage(tr("The port seems to be in use."));
|
||||
|
||||
@@ -48,7 +48,8 @@ public:
|
||||
void processOutput(const QString &output);
|
||||
|
||||
signals:
|
||||
void waitingForConnectionMessage();
|
||||
void waitingForConnectionOnPort(quint16 port);
|
||||
void waitingForConnectionViaOst();
|
||||
void connectionEstablishedMessage();
|
||||
void errorMessage(const QString &detailedError);
|
||||
void unknownMessage(const QString &unknownMessage);
|
||||
|
||||
@@ -5,6 +5,8 @@ namespace QmlJsDebugClient {
|
||||
namespace Constants {
|
||||
|
||||
const char STR_WAITING_FOR_CONNECTION[] = "Waiting for connection ";
|
||||
const char STR_ON_PORT_PATTERN[] = "on port (\\d+)";
|
||||
const char STR_VIA_OST[] = "via OST";
|
||||
const char STR_UNABLE_TO_LISTEN[] = "Unable to listen ";
|
||||
const char STR_IGNORING_DEBUGGER[] = "Ignoring \"-qmljsdebugger=";
|
||||
const char STR_IGNORING_DEBUGGER2[] = "Ignoring\"-qmljsdebugger="; // There is (was?) a bug in one of the error strings - safest to handle both
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include "qmladapter.h"
|
||||
|
||||
#include "debuggerstartparameters.h"
|
||||
#include "qscriptdebuggerclient.h"
|
||||
#include "qmlv8debuggerclient.h"
|
||||
#include "qmljsprivateapi.h"
|
||||
@@ -46,6 +45,7 @@
|
||||
|
||||
#include <QTimer>
|
||||
#include <QDebug>
|
||||
#include <QWeakPointer>
|
||||
|
||||
namespace Debugger {
|
||||
namespace Internal {
|
||||
@@ -108,23 +108,28 @@ QmlAdapter::~QmlAdapter()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void QmlAdapter::beginConnection()
|
||||
void QmlAdapter::beginConnectionTcp(const QString &address, quint16 port)
|
||||
{
|
||||
if (d->m_engine.isNull()
|
||||
|| (d->m_conn && d->m_conn->state() != QAbstractSocket::UnconnectedState))
|
||||
return;
|
||||
|
||||
const DebuggerStartParameters ¶meters = d->m_engine.data()->startParameters();
|
||||
if (parameters.communicationChannel == DebuggerStartParameters::CommunicationChannelUsb) {
|
||||
const QString &port = parameters.remoteChannel;
|
||||
showConnectionStatusMessage(tr("Connecting to debug server on %1").arg(port));
|
||||
d->m_conn->connectToOst(port);
|
||||
} else {
|
||||
const QString &address = parameters.qmlServerAddress;
|
||||
quint16 port = parameters.qmlServerPort;
|
||||
showConnectionStatusMessage(tr("Connecting to debug server %1:%2").arg(address).arg(QString::number(port)));
|
||||
d->m_conn->connectToHost(address, port);
|
||||
}
|
||||
showConnectionStatusMessage(tr("Connecting to debug server %1:%2").arg(address).arg(
|
||||
QString::number(port)));
|
||||
d->m_conn->connectToHost(address, port);
|
||||
|
||||
//A timeout to check the connection state
|
||||
d->m_connectionTimer.start();
|
||||
}
|
||||
|
||||
void QmlAdapter::beginConnectionOst(const QString &channel)
|
||||
{
|
||||
if (d->m_engine.isNull()
|
||||
|| (d->m_conn && d->m_conn->state() != QAbstractSocket::UnconnectedState))
|
||||
return;
|
||||
|
||||
showConnectionStatusMessage(tr("Connecting to debug server on %1").arg(channel));
|
||||
d->m_conn->connectToOst(channel);
|
||||
|
||||
//A timeout to check the connection state
|
||||
d->m_connectionTimer.start();
|
||||
|
||||
@@ -62,7 +62,8 @@ public:
|
||||
explicit QmlAdapter(DebuggerEngine *engine, QObject *parent = 0);
|
||||
virtual ~QmlAdapter();
|
||||
|
||||
void beginConnection();
|
||||
void beginConnectionTcp(const QString &address, quint16 port);
|
||||
void beginConnectionOst(const QString &port);
|
||||
void closeConnection();
|
||||
|
||||
bool isConnected() const;
|
||||
|
||||
@@ -172,7 +172,9 @@ QmlEngine::QmlEngine(const DebuggerStartParameters &startParameters,
|
||||
SLOT(start()));
|
||||
|
||||
d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
|
||||
connect(&d->m_outputParser, SIGNAL(waitingForConnectionMessage()),
|
||||
connect(&d->m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
|
||||
this, SLOT(beginConnection(quint16)));
|
||||
connect(&d->m_outputParser, SIGNAL(waitingForConnectionViaOst()),
|
||||
this, SLOT(beginConnection()));
|
||||
connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
|
||||
this, SLOT(beginConnection()));
|
||||
@@ -235,10 +237,29 @@ void QmlEngine::connectionEstablished()
|
||||
notifyEngineRunAndInferiorRunOk();
|
||||
}
|
||||
|
||||
void QmlEngine::beginConnection()
|
||||
void QmlEngine::beginConnection(quint16 port)
|
||||
{
|
||||
d->m_noDebugOutputTimer.stop();
|
||||
d->m_adapter.beginConnection();
|
||||
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"
|
||||
<< startParameters().connParams.port << "from start parameters.")
|
||||
d->m_adapter.beginConnectionTcp(startParameters().qmlServerAddress, port);
|
||||
return;
|
||||
}
|
||||
if (startParameters().communicationChannel
|
||||
== DebuggerStartParameters::CommunicationChannelTcpIp) {
|
||||
// no port from application output, use the one from start parameters ...
|
||||
d->m_adapter.beginConnectionTcp(startParameters().qmlServerAddress,
|
||||
startParameters().qmlServerPort);
|
||||
} else {
|
||||
QTC_CHECK(startParameters().communicationChannel
|
||||
== DebuggerStartParameters::CommunicationChannelUsb);
|
||||
d->m_adapter.beginConnectionOst(startParameters().remoteChannel);
|
||||
}
|
||||
}
|
||||
|
||||
void QmlEngine::connectionStartupFailed()
|
||||
@@ -393,8 +414,6 @@ void QmlEngine::runEngine()
|
||||
if (!isSlaveEngine()) {
|
||||
if (startParameters().startMode != AttachToRemoteServer)
|
||||
startApplicationLauncher();
|
||||
else
|
||||
beginConnection();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ signals:
|
||||
TextEditor::ITextEditor *editor, int cursorPos);
|
||||
|
||||
private slots:
|
||||
void beginConnection();
|
||||
void beginConnection(quint16 port = 0);
|
||||
void connectionEstablished();
|
||||
void connectionStartupFailed();
|
||||
void connectionError(QAbstractSocket::SocketError error);
|
||||
|
||||
@@ -149,7 +149,9 @@ QmlProfilerEngine::QmlProfilerEngine(IAnalyzerTool *tool,
|
||||
connect(&d->m_noDebugOutputTimer, SIGNAL(timeout()), this, SLOT(processIsRunning()));
|
||||
|
||||
d->m_outputParser.setNoOutputText(ApplicationLauncher::msgWinCannotRetrieveDebuggingOutput());
|
||||
connect(&d->m_outputParser, SIGNAL(waitingForConnectionMessage()),
|
||||
connect(&d->m_outputParser, SIGNAL(waitingForConnectionOnPort(quint16)),
|
||||
this, SLOT(processIsRunning(quint16)));
|
||||
connect(&d->m_outputParser, SIGNAL(waitingForConnectionViaOst()),
|
||||
this, SLOT(processIsRunning()));
|
||||
connect(&d->m_outputParser, SIGNAL(noOutputMessage()),
|
||||
this, SLOT(processIsRunning()));
|
||||
@@ -331,10 +333,19 @@ void QmlProfilerEngine::showNonmodalWarning(const QString &warningMsg)
|
||||
noExecWarning->show();
|
||||
}
|
||||
|
||||
void QmlProfilerEngine::processIsRunning()
|
||||
void QmlProfilerEngine::processIsRunning(quint16 port)
|
||||
{
|
||||
d->m_noDebugOutputTimer.stop();
|
||||
emit processRunning(d->m_runner->debugPort());
|
||||
|
||||
QTC_ASSERT(port == 0
|
||||
|| port == d->m_runner->debugPort(),
|
||||
qWarning() << "Port " << port << "from application output does not match"
|
||||
<< startParameters().connParams.port << "from start parameters.");
|
||||
|
||||
if (port > 0)
|
||||
emit processRunning(port);
|
||||
else
|
||||
emit processRunning(d->m_runner->debugPort());
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -70,7 +70,7 @@ private slots:
|
||||
void logApplicationMessage(const QString &msg, Utils::OutputFormat format);
|
||||
void wrongSetupMessageBox(const QString &errorMessage);
|
||||
void wrongSetupMessageBoxFinished(int);
|
||||
void processIsRunning();
|
||||
void processIsRunning(quint16 port = 0);
|
||||
|
||||
private:
|
||||
class QmlProfilerEnginePrivate;
|
||||
|
||||
@@ -99,7 +99,7 @@ DebuggerStartParameters AbstractRemoteLinuxDebugSupport::startParameters(const R
|
||||
if (runConfig->useQmlDebugger()) {
|
||||
params.languages |= QmlLanguage;
|
||||
params.qmlServerAddress = runConfig->deviceConfig()->sshParameters().host;
|
||||
params.qmlServerPort = -1;
|
||||
params.qmlServerPort = 0; // port is selected later on
|
||||
}
|
||||
if (runConfig->debuggerAspect()->useCppDebugger()) {
|
||||
params.languages |= CppLanguage;
|
||||
|
||||
Reference in New Issue
Block a user