forked from qt-creator/qt-creator
Android M: Support new logcat output
Change-Id: I64ae6493b45b3f1cac82e7f5e1ae77ec3b910bc9 Task-number: QTCREATORBUG-14534 Reviewed-by: BogDan Vatra <bogdan@kde.org> Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -105,15 +105,13 @@ AndroidAnalyzeSupport::AndroidAnalyzeSupport(AndroidRunConfiguration *runConfig,
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(runner, &AndroidRunner::remoteErrorOutput,
|
connect(runner, &AndroidRunner::remoteErrorOutput,
|
||||||
[this, runControl](const QByteArray &output) {
|
[this, runControl](const QString &msg) {
|
||||||
const QString msg = QString::fromUtf8(output);
|
|
||||||
runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
|
runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
|
||||||
m_outputParser.processOutput(msg);
|
m_outputParser.processOutput(msg);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(runner, &AndroidRunner::remoteOutput,
|
connect(runner, &AndroidRunner::remoteOutput,
|
||||||
[this, runControl](const QByteArray &output) {
|
[this, runControl](const QString &msg) {
|
||||||
const QString msg = QString::fromUtf8(output);
|
|
||||||
runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
|
runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
|
||||||
m_outputParser.processOutput(msg);
|
m_outputParser.processOutput(msg);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -171,15 +171,15 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
|
|||||||
});
|
});
|
||||||
|
|
||||||
connect(m_runner, &AndroidRunner::remoteErrorOutput,
|
connect(m_runner, &AndroidRunner::remoteErrorOutput,
|
||||||
[this](const QByteArray &output) {
|
[this](const QString &output) {
|
||||||
QTC_ASSERT(m_runControl, return);
|
QTC_ASSERT(m_runControl, return);
|
||||||
m_runControl->showMessage(QString::fromUtf8(output), AppError);
|
m_runControl->showMessage(output, AppError);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_runner, &AndroidRunner::remoteOutput,
|
connect(m_runner, &AndroidRunner::remoteOutput,
|
||||||
[this](const QByteArray &output) {
|
[this](const QString &output) {
|
||||||
QTC_ASSERT(m_runControl, return);
|
QTC_ASSERT(m_runControl, return);
|
||||||
m_runControl->showMessage(QString::fromUtf8(output), AppOutput);
|
m_runControl->showMessage(output, AppOutput);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ void AndroidRunControl::start()
|
|||||||
emit started();
|
emit started();
|
||||||
disconnect(m_runner, 0, this, 0);
|
disconnect(m_runner, 0, this, 0);
|
||||||
|
|
||||||
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
|
connect(m_runner, SIGNAL(remoteErrorOutput(QString)),
|
||||||
SLOT(handleRemoteErrorOutput(QByteArray)));
|
SLOT(handleRemoteErrorOutput(QString)));
|
||||||
connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
|
connect(m_runner, SIGNAL(remoteOutput(QString)),
|
||||||
SLOT(handleRemoteOutput(QByteArray)));
|
SLOT(handleRemoteOutput(QString)));
|
||||||
connect(m_runner, SIGNAL(remoteProcessFinished(QString)),
|
connect(m_runner, SIGNAL(remoteProcessFinished(QString)),
|
||||||
SLOT(handleRemoteProcessFinished(QString)));
|
SLOT(handleRemoteProcessFinished(QString)));
|
||||||
appendMessage(tr("Starting remote process."), Utils::NormalMessageFormat);
|
appendMessage(tr("Starting remote process."), Utils::NormalMessageFormat);
|
||||||
@@ -84,14 +84,14 @@ void AndroidRunControl::handleRemoteProcessFinished(const QString &error)
|
|||||||
emit finished();
|
emit finished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidRunControl::handleRemoteOutput(const QByteArray &output)
|
void AndroidRunControl::handleRemoteOutput(const QString &output)
|
||||||
{
|
{
|
||||||
appendMessage(QString::fromUtf8(output), Utils::StdOutFormatSameLine);
|
appendMessage(output, Utils::StdOutFormatSameLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidRunControl::handleRemoteErrorOutput(const QByteArray &output)
|
void AndroidRunControl::handleRemoteErrorOutput(const QString &output)
|
||||||
{
|
{
|
||||||
appendMessage(QString::fromUtf8(output), Utils::StdErrFormatSameLine);
|
appendMessage(output, Utils::StdErrFormatSameLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AndroidRunControl::isRunning() const
|
bool AndroidRunControl::isRunning() const
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void handleRemoteProcessFinished(const QString &error);
|
void handleRemoteProcessFinished(const QString &error);
|
||||||
void handleRemoteOutput(const QByteArray &output);
|
void handleRemoteOutput(const QString &output);
|
||||||
void handleRemoteErrorOutput(const QByteArray &output);
|
void handleRemoteErrorOutput(const QString &output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -209,6 +209,21 @@ AndroidRunner::AndroidRunner(QObject *parent,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_logCatRegExp = QRegExp(QLatin1String("[0-9\\-]*" // date
|
||||||
|
"\\s+"
|
||||||
|
"[0-9\\-:.]*"// time
|
||||||
|
"\\s*"
|
||||||
|
"(\\d*)" // pid 1. capture
|
||||||
|
"\\s+"
|
||||||
|
"\\d*" // unknown
|
||||||
|
"\\s+"
|
||||||
|
"(\\w)" // message type 2. capture
|
||||||
|
"\\s+"
|
||||||
|
"(.*): " // source 3. capture
|
||||||
|
"(.*)" // message 4. capture
|
||||||
|
"[\\n\\r]*"
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidRunner::~AndroidRunner()
|
AndroidRunner::~AndroidRunner()
|
||||||
@@ -526,21 +541,35 @@ void AndroidRunner::logcatProcess(const QByteArray &text, QByteArray &buffer, bo
|
|||||||
buffer.clear();
|
buffer.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray pid(QString::fromLatin1("%1):").arg(m_processPID).toLatin1());
|
QString pidString = QString::number(m_processPID);
|
||||||
foreach (QByteArray line, lines) {
|
foreach (const QByteArray &msg, lines) {
|
||||||
if (!line.contains(pid))
|
const QString line = QString::fromUtf8(msg).trimmed();
|
||||||
|
if (!line.contains(pidString))
|
||||||
continue;
|
continue;
|
||||||
if (line.endsWith('\r'))
|
if (m_logCatRegExp.exactMatch(line)) {
|
||||||
line.chop(1);
|
// Android M
|
||||||
line.append('\n');
|
if (m_logCatRegExp.cap(1) == pidString) {
|
||||||
if (onlyError || line.startsWith("F/")
|
const QString &messagetype = m_logCatRegExp.cap(2);
|
||||||
|| line.startsWith("E/")
|
QString output = line.mid(m_logCatRegExp.pos(2));
|
||||||
|| line.startsWith("D/Qt")
|
|
||||||
|| line.startsWith("W/"))
|
|
||||||
emit remoteErrorOutput(line);
|
|
||||||
else
|
|
||||||
emit remoteOutput(line);
|
|
||||||
|
|
||||||
|
if (onlyError
|
||||||
|
|| messagetype == QLatin1String("F")
|
||||||
|
|| messagetype == QLatin1String("E")
|
||||||
|
|| messagetype == QLatin1String("W")
|
||||||
|
|| messagetype == QLatin1String("D"))
|
||||||
|
emit remoteErrorOutput(output);
|
||||||
|
else
|
||||||
|
emit remoteOutput(output);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (onlyError || line.startsWith(_("F/"))
|
||||||
|
|| line.startsWith(_("E/"))
|
||||||
|
|| line.startsWith(_("D/Qt"))
|
||||||
|
|| line.startsWith(_("W/")))
|
||||||
|
emit remoteErrorOutput(line);
|
||||||
|
else
|
||||||
|
emit remoteOutput(line);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,8 +73,8 @@ signals:
|
|||||||
void remoteProcessStarted(int gdbServerPort, int qmlPort);
|
void remoteProcessStarted(int gdbServerPort, int qmlPort);
|
||||||
void remoteProcessFinished(const QString &errString = QString());
|
void remoteProcessFinished(const QString &errString = QString());
|
||||||
|
|
||||||
void remoteOutput(const QByteArray &output);
|
void remoteOutput(const QString &output);
|
||||||
void remoteErrorOutput(const QByteArray &output);
|
void remoteErrorOutput(const QString &output);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void checkPID();
|
void checkPID();
|
||||||
@@ -120,6 +120,7 @@ private:
|
|||||||
bool m_isBusyBox;
|
bool m_isBusyBox;
|
||||||
QStringList m_selector;
|
QStringList m_selector;
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
|
QRegExp m_logCatRegExp;
|
||||||
DebugHandShakeType m_handShakeMethod;
|
DebugHandShakeType m_handShakeMethod;
|
||||||
QTcpSocket *m_socket;
|
QTcpSocket *m_socket;
|
||||||
bool m_customPort;
|
bool m_customPort;
|
||||||
|
|||||||
Reference in New Issue
Block a user