forked from qt-creator/qt-creator
WinRT: Fix C++ debugging when qml debugging is also enabled.
This is also a preparation to enable QML debugging. Unfortunately the WinRT QML library isn't printing the needed "Waiting for connection" output so far. Change-Id: I5e106de0272a0876749aaf77f1ebf74b952d3471 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
This commit is contained in:
@@ -518,19 +518,20 @@ void DebuggerRunControlCreator::enrich(const RunConfiguration *runConfig, const
|
|||||||
const bool wantQmlDebugger = m_debuggerAspect->useQmlDebugger() && (m_rp.languages & QmlLanguage);
|
const bool wantQmlDebugger = m_debuggerAspect->useQmlDebugger() && (m_rp.languages & QmlLanguage);
|
||||||
|
|
||||||
if (wantQmlDebugger) {
|
if (wantQmlDebugger) {
|
||||||
QString qmlArgs;
|
QmlDebug::QmlDebugServicesPreset service;
|
||||||
if (wantCppDebugger) {
|
if (wantCppDebugger) {
|
||||||
if (m_rp.nativeMixedEnabled) {
|
if (m_rp.nativeMixedEnabled) {
|
||||||
qmlArgs = QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlNativeDebuggerServices);
|
service = QmlDebug::QmlNativeDebuggerServices;
|
||||||
} else {
|
} else {
|
||||||
m_rp.masterEngineType = QmlCppEngineType;
|
m_rp.masterEngineType = QmlCppEngineType;
|
||||||
qmlArgs = QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlDebuggerServices, m_rp.qmlServerPort);
|
service = QmlDebug::QmlDebuggerServices;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_rp.masterEngineType = QmlEngineType;
|
m_rp.masterEngineType = QmlEngineType;
|
||||||
qmlArgs = QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlDebuggerServices, m_rp.qmlServerPort);
|
service = QmlDebug::QmlDebuggerServices;
|
||||||
}
|
}
|
||||||
QtcProcess::addArg(&m_rp.processArgs, qmlArgs);
|
if (m_rp.startMode != AttachExternal)
|
||||||
|
QtcProcess::addArg(&m_rp.processArgs, QmlDebug::qmlDebugCommandLineArguments(service, m_rp.qmlServerPort));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,14 +33,18 @@
|
|||||||
#include "winrtrunnerhelper.h"
|
#include "winrtrunnerhelper.h"
|
||||||
|
|
||||||
#include <debugger/debuggerkitinformation.h>
|
#include <debugger/debuggerkitinformation.h>
|
||||||
|
#include <debugger/debuggerrunconfigurationaspect.h>
|
||||||
#include <debugger/debuggerruncontrol.h>
|
#include <debugger/debuggerruncontrol.h>
|
||||||
#include <debugger/debuggerstartparameters.h>
|
#include <debugger/debuggerstartparameters.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
#include <projectexplorer/toolchain.h>
|
#include <projectexplorer/toolchain.h>
|
||||||
|
|
||||||
|
#include <qmldebug/qmldebugcommandlinearguments.h>
|
||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QLocalServer>
|
#include <QLocalServer>
|
||||||
#include <QLocalSocket>
|
#include <QLocalSocket>
|
||||||
|
#include <QTcpServer>
|
||||||
|
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
@@ -57,6 +61,24 @@ WinRtDebugSupport::WinRtDebugSupport(RunControl *runControl, WinRtRunnerHelper *
|
|||||||
connect(m_debugRunControl, SIGNAL(finished()), this, SLOT(finish()));
|
connect(m_debugRunControl, SIGNAL(finished()), this, SLOT(finish()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WinRtDebugSupport::useQmlDebugging(WinRtRunConfiguration *runConfig)
|
||||||
|
{
|
||||||
|
Debugger::DebuggerRunConfigurationAspect *extraAspect =
|
||||||
|
runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
|
||||||
|
return extraAspect && extraAspect->useQmlDebugger();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WinRtDebugSupport::getFreePort(quint16 &qmlDebuggerPort, QString *errorMessage)
|
||||||
|
{
|
||||||
|
QTcpServer server;
|
||||||
|
if (!server.listen(QHostAddress::LocalHost, qmlDebuggerPort)) {
|
||||||
|
*errorMessage = tr("Not enough free ports for QML debugging.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
qmlDebuggerPort = server.serverPort();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
WinRtDebugSupport::~WinRtDebugSupport()
|
WinRtDebugSupport::~WinRtDebugSupport()
|
||||||
{
|
{
|
||||||
delete m_runner;
|
delete m_runner;
|
||||||
@@ -87,6 +109,16 @@ RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runC
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (useQmlDebugging(runConfig)) {
|
||||||
|
quint16 qmlDebugPort = 0;
|
||||||
|
if (!getFreePort(qmlDebugPort, errorMessage))
|
||||||
|
return 0;
|
||||||
|
runConfig->setArguments(runConfig->arguments() + QLatin1Char(' ')
|
||||||
|
+ QmlDebug::qmlDebugCommandLineArguments(QmlDebug::QmlDebuggerServices, qmlDebugPort));
|
||||||
|
params.qmlServerAddress = QHostAddress::LocalHost;
|
||||||
|
params.qmlServerPort = qmlDebugPort;
|
||||||
|
}
|
||||||
|
|
||||||
WinRtRunnerHelper *runner = new WinRtRunnerHelper(runConfig, errorMessage);
|
WinRtRunnerHelper *runner = new WinRtRunnerHelper(runConfig, errorMessage);
|
||||||
if (!errorMessage->isEmpty())
|
if (!errorMessage->isEmpty())
|
||||||
return 0;
|
return 0;
|
||||||
@@ -121,7 +153,7 @@ RunControl *WinRtDebugSupport::createDebugRunControl(WinRtRunConfiguration *runC
|
|||||||
server.close();
|
server.close();
|
||||||
Debugger::DebuggerRunControl *debugRunControl
|
Debugger::DebuggerRunControl *debugRunControl
|
||||||
= createDebuggerRunControl(params, runConfig, errorMessage, mode);
|
= createDebuggerRunControl(params, runConfig, errorMessage, mode);
|
||||||
runner->setRunControl(debugRunControl);
|
runner->setDebugRunControl(debugRunControl);
|
||||||
new WinRtDebugSupport(debugRunControl, runner);
|
new WinRtDebugSupport(debugRunControl, runner);
|
||||||
return debugRunControl;
|
return debugRunControl;
|
||||||
}
|
}
|
||||||
|
@@ -54,6 +54,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
WinRtDebugSupport(ProjectExplorer::RunControl *runControl, WinRtRunnerHelper *runner);
|
WinRtDebugSupport(ProjectExplorer::RunControl *runControl, WinRtRunnerHelper *runner);
|
||||||
|
|
||||||
|
static bool useQmlDebugging(WinRtRunConfiguration *runConfig);
|
||||||
|
static bool getFreePort(quint16 &qmlDebuggerPort, QString *errorMessage);
|
||||||
|
|
||||||
ProjectExplorer::RunControl *m_debugRunControl;
|
ProjectExplorer::RunControl *m_debugRunControl;
|
||||||
WinRtRunnerHelper *m_runner;
|
WinRtRunnerHelper *m_runner;
|
||||||
|
|
||||||
|
@@ -45,6 +45,7 @@
|
|||||||
#include <qtsupport/baseqtversion.h>
|
#include <qtsupport/baseqtversion.h>
|
||||||
#include <qtsupport/qtkitinformation.h>
|
#include <qtsupport/qtkitinformation.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
#include <debugger/debuggerruncontrol.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ using namespace WinRt::Internal;
|
|||||||
WinRtRunnerHelper::WinRtRunnerHelper(WinRtRunConfiguration *runConfiguration, QString *errormessage)
|
WinRtRunnerHelper::WinRtRunnerHelper(WinRtRunConfiguration *runConfiguration, QString *errormessage)
|
||||||
: QObject()
|
: QObject()
|
||||||
, m_messenger(0)
|
, m_messenger(0)
|
||||||
|
, m_debugMessenger(0)
|
||||||
, m_runConfiguration(runConfiguration)
|
, m_runConfiguration(runConfiguration)
|
||||||
, m_process(0)
|
, m_process(0)
|
||||||
{
|
{
|
||||||
@@ -63,6 +65,7 @@ WinRtRunnerHelper::WinRtRunnerHelper(WinRtRunConfiguration *runConfiguration, QS
|
|||||||
WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunControl *runControl)
|
WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunControl *runControl)
|
||||||
: QObject(runControl)
|
: QObject(runControl)
|
||||||
, m_messenger(runControl)
|
, m_messenger(runControl)
|
||||||
|
, m_debugMessenger(0)
|
||||||
, m_runConfiguration(0)
|
, m_runConfiguration(0)
|
||||||
, m_process(0)
|
, m_process(0)
|
||||||
{
|
{
|
||||||
@@ -112,6 +115,17 @@ bool WinRtRunnerHelper::init(WinRtRunConfiguration *runConfiguration, QString *e
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WinRtRunnerHelper::appendMessage(const QString &message, Utils::OutputFormat format)
|
||||||
|
{
|
||||||
|
if (m_debugMessenger && (format == Utils::StdOutFormat || format == Utils::StdErrFormat)){
|
||||||
|
// We wan to filter out the waiting for connection message from the QML debug server
|
||||||
|
m_debugMessenger->showMessage(message, format == Utils::StdOutFormat ? Debugger::AppOutput
|
||||||
|
: Debugger::AppError);
|
||||||
|
} else if (m_messenger) {
|
||||||
|
m_messenger->appendMessage(message, format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WinRtRunnerHelper::debug(const QString &debuggerExecutable, const QString &debuggerArguments)
|
void WinRtRunnerHelper::debug(const QString &debuggerExecutable, const QString &debuggerArguments)
|
||||||
{
|
{
|
||||||
m_debuggerExecutable = debuggerExecutable;
|
m_debuggerExecutable = debuggerExecutable;
|
||||||
@@ -138,27 +152,22 @@ bool WinRtRunnerHelper::waitForStarted(int msecs)
|
|||||||
return m_process->waitForStarted(msecs);
|
return m_process->waitForStarted(msecs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinRtRunnerHelper::setRunControl(ProjectExplorer::RunControl *runControl)
|
void WinRtRunnerHelper::setDebugRunControl(Debugger::DebuggerRunControl *runControl)
|
||||||
{
|
{
|
||||||
|
m_debugMessenger = runControl;
|
||||||
m_messenger = runControl;
|
m_messenger = runControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinRtRunnerHelper::onProcessReadyReadStdOut()
|
void WinRtRunnerHelper::onProcessReadyReadStdOut()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_process, return);
|
QTC_ASSERT(m_process, return);
|
||||||
if (m_messenger) {
|
appendMessage(QString::fromLocal8Bit(m_process->readAllStandardOutput()), Utils::StdOutFormat);
|
||||||
m_messenger->appendMessage(QString::fromLocal8Bit(
|
|
||||||
m_process->readAllStandardOutput()), Utils::StdOutFormat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinRtRunnerHelper::onProcessReadyReadStdErr()
|
void WinRtRunnerHelper::onProcessReadyReadStdErr()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_process, return);
|
QTC_ASSERT(m_process, return);
|
||||||
if (m_messenger) {
|
appendMessage(QString::fromLocal8Bit(m_process->readAllStandardError()), Utils::StdErrFormat);
|
||||||
m_messenger->appendMessage(QString::fromLocal8Bit(
|
|
||||||
m_process->readAllStandardError()), Utils::StdErrFormat);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WinRtRunnerHelper::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
void WinRtRunnerHelper::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
||||||
@@ -173,11 +182,8 @@ void WinRtRunnerHelper::onProcessFinished(int exitCode, QProcess::ExitStatus exi
|
|||||||
void WinRtRunnerHelper::onProcessError(QProcess::ProcessError processError)
|
void WinRtRunnerHelper::onProcessError(QProcess::ProcessError processError)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_process, return);
|
QTC_ASSERT(m_process, return);
|
||||||
if (m_messenger) {
|
appendMessage(tr("Error while executing the WinRT Runner Tool: %1\n").arg(
|
||||||
m_messenger->appendMessage(tr("Error while executing the WinRT Runner Tool: %1\n").arg(
|
m_process->errorString()), Utils::ErrorMessageFormat);
|
||||||
m_process->errorString()),
|
|
||||||
Utils::ErrorMessageFormat);
|
|
||||||
}
|
|
||||||
m_process->disconnect();
|
m_process->disconnect();
|
||||||
m_process->deleteLater();
|
m_process->deleteLater();
|
||||||
m_process = 0;
|
m_process = 0;
|
||||||
@@ -193,16 +199,16 @@ void WinRtRunnerHelper::startWinRtRunner(const RunConf &conf)
|
|||||||
QtcProcess::addArg(&runnerArgs, QString::number(m_device->deviceId()));
|
QtcProcess::addArg(&runnerArgs, QString::number(m_device->deviceId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::QtcProcess *process = 0;
|
QtcProcess *process = 0;
|
||||||
bool connectProcess = false;
|
bool connectProcess = false;
|
||||||
|
|
||||||
switch (conf) {
|
switch (conf) {
|
||||||
case Debug:
|
case Debug:
|
||||||
Utils::QtcProcess::addArg(&runnerArgs, QStringLiteral("--debug"));
|
QtcProcess::addArg(&runnerArgs, QStringLiteral("--debug"));
|
||||||
Utils::QtcProcess::addArg(&runnerArgs, m_debuggerExecutable);
|
QtcProcess::addArg(&runnerArgs, m_debuggerExecutable);
|
||||||
if (!m_debuggerArguments.isEmpty()) {
|
if (!m_debuggerArguments.isEmpty()) {
|
||||||
Utils::QtcProcess::addArg(&runnerArgs, QStringLiteral("--debugger-arguments"));
|
QtcProcess::addArg(&runnerArgs, QStringLiteral("--debugger-arguments"));
|
||||||
Utils::QtcProcess::addArg(&runnerArgs, m_debuggerArguments);
|
QtcProcess::addArg(&runnerArgs, m_debuggerArguments);
|
||||||
}
|
}
|
||||||
// fall through
|
// fall through
|
||||||
case Start:
|
case Start:
|
||||||
@@ -213,7 +219,7 @@ void WinRtRunnerHelper::startWinRtRunner(const RunConf &conf)
|
|||||||
process = m_process;
|
process = m_process;
|
||||||
break;
|
break;
|
||||||
case Stop:
|
case Stop:
|
||||||
Utils::QtcProcess::addArgs(&runnerArgs, QStringLiteral("--stop"));
|
QtcProcess::addArgs(&runnerArgs, QStringLiteral("--stop"));
|
||||||
process = new QtcProcess(this);
|
process = new QtcProcess(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -225,10 +231,7 @@ void WinRtRunnerHelper::startWinRtRunner(const RunConf &conf)
|
|||||||
if (!m_arguments.isEmpty())
|
if (!m_arguments.isEmpty())
|
||||||
QtcProcess::addArgs(&runnerArgs, m_arguments);
|
QtcProcess::addArgs(&runnerArgs, m_arguments);
|
||||||
|
|
||||||
if (m_messenger) {
|
appendMessage(QStringLiteral("winrtrunner ") + runnerArgs + QLatin1Char('\n'), NormalMessageFormat);
|
||||||
m_messenger->appendMessage(QStringLiteral("winrtrunner ") + runnerArgs + QLatin1Char('\n'),
|
|
||||||
Utils::NormalMessageFormat);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connectProcess) {
|
if (connectProcess) {
|
||||||
connect(process, SIGNAL(started()), SIGNAL(started()));
|
connect(process, SIGNAL(started()), SIGNAL(started()));
|
||||||
|
@@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
namespace Utils { class QtcProcess; }
|
namespace Utils { class QtcProcess; }
|
||||||
namespace ProjectExplorer { class RunControl; }
|
namespace ProjectExplorer { class RunControl; }
|
||||||
|
namespace Debugger { class DebuggerRunControl; }
|
||||||
|
|
||||||
namespace WinRt {
|
namespace WinRt {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -62,7 +63,7 @@ public:
|
|||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
bool waitForStarted(int msecs = 10000);
|
bool waitForStarted(int msecs = 10000);
|
||||||
void setRunControl(ProjectExplorer::RunControl *runControl);
|
void setDebugRunControl(Debugger::DebuggerRunControl *runControl);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void started();
|
void started();
|
||||||
@@ -79,8 +80,10 @@ private:
|
|||||||
enum RunConf { Start, Stop, Debug };
|
enum RunConf { Start, Stop, Debug };
|
||||||
void startWinRtRunner(const RunConf &conf);
|
void startWinRtRunner(const RunConf &conf);
|
||||||
bool init(WinRtRunConfiguration *runConfiguration, QString *errorMessage);
|
bool init(WinRtRunConfiguration *runConfiguration, QString *errorMessage);
|
||||||
|
void appendMessage(const QString &message, Utils::OutputFormat format);
|
||||||
|
|
||||||
ProjectExplorer::RunControl *m_messenger;
|
ProjectExplorer::RunControl *m_messenger;
|
||||||
|
Debugger::DebuggerRunControl *m_debugMessenger;
|
||||||
WinRtRunConfiguration *m_runConfiguration;
|
WinRtRunConfiguration *m_runConfiguration;
|
||||||
WinRtDevice::ConstPtr m_device;
|
WinRtDevice::ConstPtr m_device;
|
||||||
Utils::Environment m_environment;
|
Utils::Environment m_environment;
|
||||||
|
Reference in New Issue
Block a user