return true;
}
+bool AppxEngine::enableDebugging(const QString &debuggerExecutable, const QString &debuggerArguments)
+{
+ Q_D(AppxEngine);
+
+ const QString &debuggerCommand = debuggerExecutable + QLatin1Char(' ') + debuggerArguments;
+ HRESULT hr = d->packageDebug->EnableDebugging(wchar(d->packageFullName),
+ wchar(debuggerCommand),
+ NULL);
+ if (FAILED(hr)) {
+ qCWarning(lcWinRtRunner).nospace() << "Failed to enable debugging for application. (0x"
+ << QByteArray::number(hr, 16).constData()
+ << ' ' << qt_error_string(hr) << ')';
+ return false;
+ }
+ return true;
+}
+
+bool AppxEngine::disableDebugging()
+{
+ Q_D(AppxEngine);
+
+ HRESULT hr = d->packageDebug->DisableDebugging(wchar(d->packageFullName));
+ if (FAILED(hr)) {
+ qCWarning(lcWinRtRunner).nospace() << "Failed to disable debugging for application. (0x"
+ << QByteArray::number(hr, 16).constData()
+ << ' ' << qt_error_string(hr) << ')';
+ return false;
+ }
+ return true;
+}
+
bool AppxEngine::suspend()
{
Q_D(AppxEngine);
bool install(bool removeFirst = false) Q_DECL_OVERRIDE;
bool remove() Q_DECL_OVERRIDE;
bool start() Q_DECL_OVERRIDE;
+ bool enableDebugging(const QString &debuggerExecutable,
+ const QString &debuggerArguments) Q_DECL_OVERRIDE;
+ bool disableDebugging() Q_DECL_OVERRIDE;
bool suspend() Q_DECL_OVERRIDE;
bool waitForFinished(int secs) Q_DECL_OVERRIDE;
bool stop() Q_DECL_OVERRIDE;
"force reinstallation."));
parser.addOption(startOption);
+ QCommandLineOption debugOption(QStringLiteral("debug"),
+ QLatin1String("Start the package with the debugger attached. "
+ "The package is installed if it is not already "
+ "installed. Pass --install to force "
+ "reinstallation."),
+ QLatin1Literal("debugger"));
+ parser.addOption(debugOption);
+
+ QCommandLineOption debuggerArgumentsOption(QStringLiteral("debugger-arguments"),
+ QLatin1String("Arguments that are passed to the "
+ "debugger when --debug is used. If no "
+ "debugger was provided this option is "
+ "ignored."),
+ QLatin1String("arguments"));
+ parser.addOption(debuggerArgumentsOption);
+
QCommandLineOption suspendOption(QStringLiteral("suspend"),
QLatin1String("Suspend a running package. When combined "
"with --stop or --test, the app will be "
// 7 - Stop failed
// 8 - Test setup failed
// 9 - Test results retrieval failed
+ // 10 - Enabling debugging failed
// In "test" mode, the exit code of the app is returned
bool ignoreErrors = parser.isSet(ignoreErrorsOption);
bool testEnabled = parser.isSet(testOption);
- bool startEnabled = testEnabled || parser.isSet(startOption);
+ bool startEnabled = testEnabled || parser.isSet(startOption) || parser.isSet(debugOption);
bool suspendEnabled = parser.isSet(suspendOption);
bool waitEnabled = testEnabled || parser.isSet(waitOption);
bool stopEnabled = !testEnabled && parser.isSet(stopOption); // test and stop are mutually exclusive
return ignoreErrors ? 0 : 3;
}
- if (startEnabled && !runner.start()) {
+ if (parser.isSet(debugOption)) {
+ const QString &debuggerExecutable = parser.value(debugOption);
+ const QString &debuggerArguments = parser.value(debuggerArgumentsOption);
+ qCDebug(lcWinRtRunner) << "Debugger: " << debuggerExecutable;
+ qCDebug(lcWinRtRunner) << "Debugger Options: " << debuggerArguments;
+ if (debuggerExecutable.isEmpty()
+ || !runner.enableDebugging(debuggerExecutable, debuggerArguments)) {
+ qCDebug(lcWinRtRunner) << "Failed to enable debugging, exiting with code 10.";
+ return ignoreErrors ? 0 : 10;
+ }
+ }
+
+ bool startFailed = startEnabled && !runner.start();
+
+ if (parser.isSet(debugOption) && !runner.disableDebugging())
+ qCDebug(lcWinRtRunner) << "Failed to disable debugging";
+
+ if (startFailed) {
qCDebug(lcWinRtRunner) << "Start failed, exiting with code 5.";
return ignoreErrors ? 0 : 5;
}
return d->engine->start();
}
+bool Runner::enableDebugging(const QString &debuggerExecutable, const QString &debuggerArguments)
+{
+ Q_D(Runner);
+ Q_ASSERT(d->engine);
+
+ return d->engine->enableDebugging(debuggerExecutable, debuggerArguments);
+}
+
+bool Runner::disableDebugging()
+{
+ Q_D(Runner);
+ Q_ASSERT(d->engine);
+
+ return d->engine->disableDebugging();
+}
+
bool Runner::suspend()
{
Q_D(Runner);
bool install(bool removeFirst = false);
bool remove();
bool start();
+ bool enableDebugging(const QString &debuggerExecutable, const QString &debuggerArguments);
+ bool disableDebugging();
bool suspend();
bool stop();
bool wait(int maxWaitTime = 0);
virtual bool install(bool removeFirst = false) = 0;
virtual bool remove() = 0;
virtual bool start() = 0;
+ virtual bool enableDebugging(const QString &debugger, const QString &debuggerArguments) = 0;
+ virtual bool disableDebugging() = 0;
virtual bool suspend() = 0;
virtual bool waitForFinished(int secs) = 0;
virtual bool stop() = 0;
return true;
}
+bool XapEngine::enableDebugging(const QString &debuggerExecutable, const QString &debuggerArguments)
+{
+ Q_UNUSED(debuggerExecutable);
+ Q_UNUSED(debuggerArguments);
+ return false;
+}
+
+bool XapEngine::disableDebugging()
+{
+ return false;
+}
+
bool XapEngine::suspend()
{
qCDebug(lcWinRtRunner) << __FUNCTION__;
bool install(bool removeFirst = false) Q_DECL_OVERRIDE;
bool remove() Q_DECL_OVERRIDE;
bool start() Q_DECL_OVERRIDE;
+ bool enableDebugging(const QString &debuggerExecutable,
+ const QString &debuggerArguments) Q_DECL_OVERRIDE;
+ bool disableDebugging() Q_DECL_OVERRIDE;
bool suspend() Q_DECL_OVERRIDE;
bool waitForFinished(int secs) Q_DECL_OVERRIDE;
bool stop() Q_DECL_OVERRIDE;