forked from qt-creator/qt-creator
Android: Fix debugger startup by trying harder to find the pid.
Task-number: QTBUG-36201 Change-Id: I8b4e1bd7615e4fda1184b0d3d443afcdc5e0e898 Reviewed-by: jian liang <jianliang79@gmail.com> Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user