summaryrefslogtreecommitdiff
path: root/src/plugins/android/androidrunnerworker.cpp
diff options
context:
space:
mode:
authorCristian Adam <cristian.adam@qt.io>2023-03-07 17:47:33 +0100
committerCristian Adam <cristian.adam@qt.io>2023-03-10 17:36:44 +0000
commitd154388f27c0e0fe2176a8f4a2517f2dd409d493 (patch)
tree3ac0aad44361da665fe6188528d511b3a70c9eeb /src/plugins/android/androidrunnerworker.cpp
parent03d3bf9f21100184e6e229a27fd4d7c1f7c63b14 (diff)
downloadqt-creator-d154388f27c0e0fe2176a8f4a2517f2dd409d493.tar.gz
Android: add "threads" command for jdb settelment
By issuing "threads" the jdb will output the names of the running threads. This makes sure that jdb has "settled" and is in a running state. Task-number: QTCREATORBUG-26592 Task-number: QTCREATORBUG-26709 Task-number: QTCREATORBUG-28141 Task-number: QTCREATORBUG-28428 Task-number: QTCREATORBUG-28851 Change-Id: Ib371e333eb9fc4d93a6b797bf7be68793f887fcd Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
Diffstat (limited to 'src/plugins/android/androidrunnerworker.cpp')
-rw-r--r--src/plugins/android/androidrunnerworker.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/plugins/android/androidrunnerworker.cpp b/src/plugins/android/androidrunnerworker.cpp
index 53721cebdb..e702d487b0 100644
--- a/src/plugins/android/androidrunnerworker.cpp
+++ b/src/plugins/android/androidrunnerworker.cpp
@@ -735,10 +735,10 @@ void AndroidRunnerWorker::handleJdbSettled()
{
qCDebug(androidRunWorkerLog) << "Handle JDB settled";
auto waitForCommand = [this] {
- for (int i= 0; i < 5 && m_jdbProcess->state() == QProcess::Running; ++i) {
+ for (int i = 0; i < 120 && m_jdbProcess->state() == QProcess::Running; ++i) {
m_jdbProcess->waitForReadyRead(500);
QByteArray lines = m_jdbProcess->readAll();
- const auto linesList = lines.split('\n');
+ const auto linesList = lines.split('\n');
for (const auto &line : linesList) {
auto msg = line.trimmed();
if (msg.startsWith(">"))
@@ -747,24 +747,29 @@ void AndroidRunnerWorker::handleJdbSettled()
}
return false;
};
- if (waitForCommand()) {
- m_jdbProcess->write("cont\n");
- if (m_jdbProcess->waitForBytesWritten(5000) && waitForCommand()) {
- m_jdbProcess->write("exit\n");
- m_jdbProcess->waitForBytesWritten(5000);
- if (!m_jdbProcess->waitForFinished(5000)) {
- m_jdbProcess->terminate();
- if (!m_jdbProcess->waitForFinished(5000)) {
- qCDebug(androidRunWorkerLog) << "Killing JDB process";
- m_jdbProcess->kill();
- m_jdbProcess->waitForFinished();
- }
- } else if (m_jdbProcess->exitStatus() == QProcess::NormalExit && m_jdbProcess->exitCode() == 0) {
- qCDebug(androidRunWorkerLog) << "JDB settled";
- return;
- }
+
+ const QStringList commands{"threads", "cont", "exit"};
+ const int jdbTimeout = 5000;
+
+ for (const QString &command : commands) {
+ if (waitForCommand()) {
+ m_jdbProcess->write(QString("%1\n").arg(command).toLatin1());
+ m_jdbProcess->waitForBytesWritten(jdbTimeout);
}
}
+
+ if (!m_jdbProcess->waitForFinished(jdbTimeout)) {
+ m_jdbProcess->terminate();
+ if (!m_jdbProcess->waitForFinished(jdbTimeout)) {
+ qCDebug(androidRunWorkerLog) << "Killing JDB process";
+ m_jdbProcess->kill();
+ m_jdbProcess->waitForFinished();
+ }
+ } else if (m_jdbProcess->exitStatus() == QProcess::NormalExit && m_jdbProcess->exitCode() == 0) {
+ qCDebug(androidRunWorkerLog) << "JDB settled";
+ return;
+ }
+
emit remoteProcessFinished(Tr::tr("Cannot attach JDB to the running application."));
}