diff options
author | Tyler Mandry <[email protected]> | 2012-06-24 19:32:45 -0700 |
---|---|---|
committer | Tobias Hunger <[email protected]> | 2012-07-17 23:47:31 +0200 |
commit | fcd01af1437c7ab5c5347c0b2bfd78b306daf8a6 (patch) | |
tree | 9b2ccb63e302adb664243d73c744583c6b8fa7a2 /src/plugins/android/androidrunner.cpp | |
parent | 70ce95b44f36f1e29d10c5f08d76dcce710e690e (diff) |
Android: Add QML debugging support
Change-Id: I2fb2c75001569385e417ea44ae90d34e92a22449
Reviewed-by: BogDan Vatra <[email protected]>
Reviewed-by: Tobias Hunger <[email protected]>
Diffstat (limited to 'src/plugins/android/androidrunner.cpp')
-rw-r--r-- | src/plugins/android/androidrunner.cpp | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp index 1a153447053..40358e1e90a 100644 --- a/src/plugins/android/androidrunner.cpp +++ b/src/plugins/android/androidrunner.cpp @@ -46,11 +46,13 @@ namespace Android { namespace Internal { -AndroidRunner::AndroidRunner(QObject *parent, - AndroidRunConfiguration *runConfig, bool debugging) +AndroidRunner::AndroidRunner(QObject *parent, AndroidRunConfiguration *runConfig, bool debuggingMode) : QThread(parent) { - m_remoteChannel = runConfig->remoteChannel(); + m_useCppDebugger = debuggingMode && runConfig->debuggerAspect()->useCppDebugger(); + m_useQmlDebugger = debuggingMode && runConfig->debuggerAspect()->useQmlDebugger(); + m_remoteGdbChannel = runConfig->remoteChannel(); + m_qmlPort = runConfig->debuggerAspect()->qmlDebugServerPort(); ProjectExplorer::Target *target = runConfig->target(); AndroidDeployStep *ds = runConfig->deployStep(); if ((m_useLocalQtLibs = ds->useLocalQtLibs())) { @@ -58,7 +60,6 @@ AndroidRunner::AndroidRunner(QObject *parent, m_localJars = AndroidManager::loadLocalJars(target, ds->deviceAPILevel()); } m_intentName = AndroidManager::intentName(target); - m_debugingMode = debugging; m_packageName = m_intentName.left(m_intentName.indexOf(QLatin1Char('/'))); m_deviceSerialNumber = ds->deviceSerialNumber(); m_processPID = -1; @@ -101,9 +102,9 @@ void AndroidRunner::checkPID() return; } m_processPID = pid; - if (!m_debugingMode) - return; + if (!m_useCppDebugger) + return; m_gdbserverPID = -1; foreach (const QByteArray &proc, procs) { if (proc.trimmed().endsWith("gdbserver")) { @@ -145,22 +146,39 @@ void AndroidRunner::asyncStart() killPID(); // kill any process with this name QString extraParams; QProcess adbStarProc; - if (m_debugingMode) { + if (m_useCppDebugger) { QStringList arguments; arguments << QLatin1String("-s") << m_deviceSerialNumber - << QLatin1String("forward") << QString::fromLatin1("tcp%1").arg(m_remoteChannel) + << QLatin1String("forward") << QString::fromLatin1("tcp%1").arg(m_remoteGdbChannel) << QString::fromLatin1("localfilesystem:/data/data/%1/debug-socket").arg(m_packageName); adbStarProc.start(AndroidConfigurations::instance().adbToolPath().toString(), arguments); if (!adbStarProc.waitForStarted()) { - emit remoteProcessFinished(tr("Failed to forward debugging ports. Reason: $1").arg(adbStarProc.errorString())); + emit remoteProcessFinished(tr("Failed to forward C++ debugging ports. Reason: %1").arg(adbStarProc.errorString())); return; } if (!adbStarProc.waitForFinished(-1)) { - emit remoteProcessFinished(tr("Failed to forward debugging ports")); + emit remoteProcessFinished(tr("Failed to forward C++ debugging ports")); return; } extraParams = QLatin1String("-e native_debug true -e gdbserver_socket +debug-socket"); } + if (m_useQmlDebugger) { + QStringList arguments; + QString port = QString::fromLatin1("tcp:%1").arg(m_qmlPort); + arguments << QLatin1String("-s") << m_deviceSerialNumber + << QLatin1String("forward") << port << port; // currently forward to same port on device and host + adbStarProc.start(AndroidConfigurations::instance().adbToolPath().toString(), arguments); + if (!adbStarProc.waitForStarted()) { + emit remoteProcessFinished(tr("Failed to forward QML debugging ports. Reason: %1").arg(adbStarProc.errorString())); + return; + } + if (!adbStarProc.waitForFinished(-1)) { + emit remoteProcessFinished(tr("Failed to forward QML debugging ports")); + return; + } + extraParams+=QString::fromLatin1(" -e qml_debug true -e qmljsdebugger port:%1") + .arg(m_qmlPort); + } if (m_useLocalQtLibs) { extraParams += QLatin1String(" -e use_local_qt_libs true"); @@ -197,7 +215,7 @@ void AndroidRunner::asyncStart() return; } - if (m_debugingMode) { + if (m_useCppDebugger) { startTime = QTime::currentTime(); while (m_gdbserverPID == -1 && startTime.secsTo(QTime::currentTime()) < 25) { // wait up to 25 seconds to connect checkPID(); @@ -247,6 +265,9 @@ void AndroidRunner::logcatReadStandardOutput() foreach (line, m_logcat.split('\n')) { if (!line.contains(pid)) continue; + if (line.endsWith('\r')) + line.chop(1); + line.append('\n'); if (line.startsWith("E/")) emit remoteErrorOutput(line); else |