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,
|
||||
[this, runControl](const QByteArray &output) {
|
||||
const QString msg = QString::fromUtf8(output);
|
||||
[this, runControl](const QString &msg) {
|
||||
runControl->logApplicationMessage(msg, Utils::StdErrFormatSameLine);
|
||||
m_outputParser.processOutput(msg);
|
||||
});
|
||||
|
||||
connect(runner, &AndroidRunner::remoteOutput,
|
||||
[this, runControl](const QByteArray &output) {
|
||||
const QString msg = QString::fromUtf8(output);
|
||||
[this, runControl](const QString &msg) {
|
||||
runControl->logApplicationMessage(msg, Utils::StdOutFormatSameLine);
|
||||
m_outputParser.processOutput(msg);
|
||||
});
|
||||
|
||||
@@ -171,15 +171,15 @@ AndroidDebugSupport::AndroidDebugSupport(AndroidRunConfiguration *runConfig,
|
||||
});
|
||||
|
||||
connect(m_runner, &AndroidRunner::remoteErrorOutput,
|
||||
[this](const QByteArray &output) {
|
||||
[this](const QString &output) {
|
||||
QTC_ASSERT(m_runControl, return);
|
||||
m_runControl->showMessage(QString::fromUtf8(output), AppError);
|
||||
m_runControl->showMessage(output, AppError);
|
||||
});
|
||||
|
||||
connect(m_runner, &AndroidRunner::remoteOutput,
|
||||
[this](const QByteArray &output) {
|
||||
[this](const QString &output) {
|
||||
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();
|
||||
disconnect(m_runner, 0, this, 0);
|
||||
|
||||
connect(m_runner, SIGNAL(remoteErrorOutput(QByteArray)),
|
||||
SLOT(handleRemoteErrorOutput(QByteArray)));
|
||||
connect(m_runner, SIGNAL(remoteOutput(QByteArray)),
|
||||
SLOT(handleRemoteOutput(QByteArray)));
|
||||
connect(m_runner, SIGNAL(remoteErrorOutput(QString)),
|
||||
SLOT(handleRemoteErrorOutput(QString)));
|
||||
connect(m_runner, SIGNAL(remoteOutput(QString)),
|
||||
SLOT(handleRemoteOutput(QString)));
|
||||
connect(m_runner, SIGNAL(remoteProcessFinished(QString)),
|
||||
SLOT(handleRemoteProcessFinished(QString)));
|
||||
appendMessage(tr("Starting remote process."), Utils::NormalMessageFormat);
|
||||
@@ -84,14 +84,14 @@ void AndroidRunControl::handleRemoteProcessFinished(const QString &error)
|
||||
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
|
||||
|
||||
@@ -54,8 +54,8 @@ public:
|
||||
|
||||
private slots:
|
||||
void handleRemoteProcessFinished(const QString &error);
|
||||
void handleRemoteOutput(const QByteArray &output);
|
||||
void handleRemoteErrorOutput(const QByteArray &output);
|
||||
void handleRemoteOutput(const QString &output);
|
||||
void handleRemoteErrorOutput(const QString &output);
|
||||
|
||||
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()
|
||||
@@ -526,21 +541,35 @@ void AndroidRunner::logcatProcess(const QByteArray &text, QByteArray &buffer, bo
|
||||
buffer.clear();
|
||||
}
|
||||
|
||||
QByteArray pid(QString::fromLatin1("%1):").arg(m_processPID).toLatin1());
|
||||
foreach (QByteArray line, lines) {
|
||||
if (!line.contains(pid))
|
||||
QString pidString = QString::number(m_processPID);
|
||||
foreach (const QByteArray &msg, lines) {
|
||||
const QString line = QString::fromUtf8(msg).trimmed();
|
||||
if (!line.contains(pidString))
|
||||
continue;
|
||||
if (line.endsWith('\r'))
|
||||
line.chop(1);
|
||||
line.append('\n');
|
||||
if (onlyError || line.startsWith("F/")
|
||||
|| line.startsWith("E/")
|
||||
|| line.startsWith("D/Qt")
|
||||
|| line.startsWith("W/"))
|
||||
if (m_logCatRegExp.exactMatch(line)) {
|
||||
// Android M
|
||||
if (m_logCatRegExp.cap(1) == pidString) {
|
||||
const QString &messagetype = m_logCatRegExp.cap(2);
|
||||
QString output = line.mid(m_logCatRegExp.pos(2));
|
||||
|
||||
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 remoteProcessFinished(const QString &errString = QString());
|
||||
|
||||
void remoteOutput(const QByteArray &output);
|
||||
void remoteErrorOutput(const QByteArray &output);
|
||||
void remoteOutput(const QString &output);
|
||||
void remoteErrorOutput(const QString &output);
|
||||
|
||||
private slots:
|
||||
void checkPID();
|
||||
@@ -120,6 +120,7 @@ private:
|
||||
bool m_isBusyBox;
|
||||
QStringList m_selector;
|
||||
QMutex m_mutex;
|
||||
QRegExp m_logCatRegExp;
|
||||
DebugHandShakeType m_handShakeMethod;
|
||||
QTcpSocket *m_socket;
|
||||
bool m_customPort;
|
||||
|
||||
Reference in New Issue
Block a user