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)
|
ProjectExplorer::RunMode runMode)
|
||||||
: QThread(parent)
|
: QThread(parent)
|
||||||
{
|
{
|
||||||
m_wasStarted = false;
|
m_tries = 0;
|
||||||
Debugger::DebuggerRunConfigurationAspect *aspect
|
Debugger::DebuggerRunConfigurationAspect *aspect
|
||||||
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
|
= runConfig->extraAspect<Debugger::DebuggerRunConfigurationAspect>();
|
||||||
const bool debuggingMode = runMode == ProjectExplorer::DebugRunMode;
|
const bool debuggingMode = runMode == ProjectExplorer::DebugRunMode;
|
||||||
@@ -153,13 +153,36 @@ QByteArray AndroidRunner::runPs()
|
|||||||
|
|
||||||
void AndroidRunner::checkPID()
|
void AndroidRunner::checkPID()
|
||||||
{
|
{
|
||||||
if (!m_wasStarted)
|
|
||||||
return;
|
|
||||||
QByteArray psOut = runPs();
|
QByteArray psOut = runPs();
|
||||||
m_processPID = extractPid(m_packageName, psOut);
|
m_processPID = extractPid(m_packageName, psOut);
|
||||||
|
|
||||||
if (m_processPID == -1) {
|
if (m_processPID == -1) {
|
||||||
m_checkPIDTimer.stop();
|
if (m_wasStarted) {
|
||||||
emit remoteProcessFinished(tr("\n\n'%1' died.").arg(m_packageName));
|
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()
|
void AndroidRunner::start()
|
||||||
{
|
{
|
||||||
m_adbLogcatProcess.start(m_adb, selector() << _("logcat"));
|
m_adbLogcatProcess.start(m_adb, selector() << _("logcat"));
|
||||||
m_wasStarted = false;
|
|
||||||
QtConcurrent::run(this, &AndroidRunner::asyncStart);
|
QtConcurrent::run(this, &AndroidRunner::asyncStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,33 +316,9 @@ void AndroidRunner::asyncStart()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray psOut = runPs();
|
m_tries = 0;
|
||||||
m_processPID = extractPid(m_packageName, psOut);
|
m_wasStarted = false;
|
||||||
|
|
||||||
if (m_processPID == -1) {
|
|
||||||
emit remoteProcessFinished(tr("Unable to start '%1'.").arg(m_packageName));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMetaObject::invokeMethod(&m_checkPIDTimer, "start");
|
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()
|
void AndroidRunner::handleRemoteDebuggerRunning()
|
||||||
@@ -342,6 +340,7 @@ void AndroidRunner::stop()
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&m_mutex);
|
QMutexLocker locker(&m_mutex);
|
||||||
m_checkPIDTimer.stop();
|
m_checkPIDTimer.stop();
|
||||||
|
m_tries = 0;
|
||||||
if (m_processPID != -1) {
|
if (m_processPID != -1) {
|
||||||
forceStop();
|
forceStop();
|
||||||
emit remoteProcessFinished(tr("\n\n'%1' terminated.").arg(m_packageName));
|
emit remoteProcessFinished(tr("\n\n'%1' terminated.").arg(m_packageName));
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ private:
|
|||||||
QProcess m_adbLogcatProcess;
|
QProcess m_adbLogcatProcess;
|
||||||
QTimer m_checkPIDTimer;
|
QTimer m_checkPIDTimer;
|
||||||
bool m_wasStarted;
|
bool m_wasStarted;
|
||||||
|
int m_tries;
|
||||||
|
|
||||||
QByteArray m_logcat;
|
QByteArray m_logcat;
|
||||||
QString m_intentName;
|
QString m_intentName;
|
||||||
|
|||||||
Reference in New Issue
Block a user