diff options
author | Daniel Teske <[email protected]> | 2014-02-12 12:24:56 +0100 |
---|---|---|
committer | Daniel Teske <[email protected]> | 2014-02-20 14:27:36 +0100 |
commit | aaedccf1161ab564d9353cb32076babb2ba717aa (patch) | |
tree | 87ea79d596fa222c2a2aa799cf370a6819031a35 /src/plugins/android/androidrunner.cpp | |
parent | f785402972cd509be5cd0710c624910f0f5da494 (diff) |
Android: Fix debugger startup by trying harder to find the pid.
Task-number: QTBUG-36201
Change-Id: I8b4e1bd7615e4fda1184b0d3d443afcdc5e0e898
Reviewed-by: jian liang <[email protected]>
Reviewed-by: hjk <[email protected]>
Diffstat (limited to 'src/plugins/android/androidrunner.cpp')
-rw-r--r-- | src/plugins/android/androidrunner.cpp | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/src/plugins/android/androidrunner.cpp b/src/plugins/android/androidrunner.cpp index 08f7be5bfd2..a2c642af230 100644 --- a/src/plugins/android/androidrunner.cpp +++ b/src/plugins/android/androidrunner.cpp @@ -55,7 +55,7 @@ AndroidRunner::AndroidRunner(QObject *parent, ProjectExplorer::RunMode runMode) : QThread(parent) { - m_wasStarted = false; + m_tries = 0; Debugger::DebuggerRunConfigurationAspect *aspect = runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>(); const bool debuggingMode = runMode == ProjectExplorer::DebugRunMode; @@ -153,13 +153,36 @@ QByteArray AndroidRunner::runPs() void AndroidRunner::checkPID() { - if (!m_wasStarted) - return; QByteArray psOut = runPs(); m_processPID = extractPid(m_packageName, psOut); + if (m_processPID == -1) { - m_checkPIDTimer.stop(); - emit remoteProcessFinished(tr("\n\n'%1' died.").arg(m_packageName)); + if (m_wasStarted) { + m_wasStarted = false; + m_checkPIDTimer.stop(); + emit remoteProcessFinished(tr("\n\n'%1' died.").arg(m_packageName)); + } else { + if (++m_tries > 3) + emit remoteProcessFinished(tr("\n\nUnable to start '%1'").arg(m_packageName)); + } + } else if (!m_wasStarted){ + if (m_useCppDebugger) { + // This will be funneled to the engine to actually start and attach + // gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below. + QByteArray serverChannel = ':' + QByteArray::number(m_localGdbServerPort); + emit remoteServerRunning(serverChannel, m_processPID); + } else if (m_useQmlDebugger) { + // This will be funneled to the engine to actually start and attach + // gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below. + QByteArray serverChannel = QByteArray::number(m_qmlPort); + emit remoteServerRunning(serverChannel, m_processPID); + } else if (m_useQmlProfiler) { + emit remoteProcessStarted(m_qmlPort); + } else { + // Start without debugging. + emit remoteProcessStarted(-1, -1); + } + m_wasStarted = true; } } @@ -189,7 +212,6 @@ void AndroidRunner::forceStop() void AndroidRunner::start() { m_adbLogcatProcess.start(m_adb, selector() << _("logcat")); - m_wasStarted = false; QtConcurrent::run(this, &AndroidRunner::asyncStart); } @@ -294,33 +316,9 @@ void AndroidRunner::asyncStart() } - QByteArray psOut = runPs(); - m_processPID = extractPid(m_packageName, psOut); - - if (m_processPID == -1) { - emit remoteProcessFinished(tr("Unable to start '%1'.").arg(m_packageName)); - return; - } - + m_tries = 0; + m_wasStarted = false; QMetaObject::invokeMethod(&m_checkPIDTimer, "start"); - - m_wasStarted = true; - if (m_useCppDebugger) { - // This will be funneled to the engine to actually start and attach - // gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below. - QByteArray serverChannel = ':' + QByteArray::number(m_localGdbServerPort); - emit remoteServerRunning(serverChannel, m_processPID); - } else if (m_useQmlDebugger) { - // This will be funneled to the engine to actually start and attach - // gdb. Afterwards this ends up in handleRemoteDebuggerRunning() below. - QByteArray serverChannel = QByteArray::number(m_qmlPort); - emit remoteServerRunning(serverChannel, m_processPID); - } else if (m_useQmlProfiler) { - emit remoteProcessStarted(m_qmlPort); - } else { - // Start without debugging. - emit remoteProcessStarted(-1, -1); - } } void AndroidRunner::handleRemoteDebuggerRunning() @@ -342,6 +340,7 @@ void AndroidRunner::stop() { QMutexLocker locker(&m_mutex); m_checkPIDTimer.stop(); + m_tries = 0; if (m_processPID != -1) { forceStop(); emit remoteProcessFinished(tr("\n\n'%1' terminated.").arg(m_packageName)); |