forked from qt-creator/qt-creator
Debugger: Robustify lldb line parser
The original version might have missed to recognize a @\r\n combination or multi-byte UTF-8 code units when they were split across to readyRead() handlers. Change-Id: Ib543fa0070b63d25b44be429a3759964d65e878e Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -841,18 +841,23 @@ void LldbEngine::readLldbStandardError()
|
|||||||
|
|
||||||
void LldbEngine::readLldbStandardOutput()
|
void LldbEngine::readLldbStandardOutput()
|
||||||
{
|
{
|
||||||
QByteArray outba = m_lldbProc.readAllRawStandardOutput();
|
const QByteArray out = m_lldbProc.readAllRawStandardOutput();
|
||||||
outba.replace("\r\n", "\n");
|
showMessage(QString::fromUtf8(out), LogOutput);
|
||||||
QString out = QString::fromUtf8(outba);
|
|
||||||
showMessage(out, LogOutput);
|
|
||||||
m_inbuffer.append(out);
|
m_inbuffer.append(out);
|
||||||
while (true) {
|
while (true) {
|
||||||
int pos = m_inbuffer.indexOf("@\n");
|
if (int pos = m_inbuffer.indexOf("@\n"); pos >= 0) {
|
||||||
if (pos == -1)
|
const QByteArray response = m_inbuffer.left(pos).trimmed();
|
||||||
break;
|
m_inbuffer = m_inbuffer.mid(pos + 2);
|
||||||
QString response = m_inbuffer.left(pos).trimmed();
|
emit outputReady(QString::fromUtf8(response));
|
||||||
m_inbuffer = m_inbuffer.mid(pos + 2);
|
continue;
|
||||||
emit outputReady(response);
|
}
|
||||||
|
if (int pos = m_inbuffer.indexOf("@\r\n"); pos >= 0) {
|
||||||
|
const QByteArray response = m_inbuffer.left(pos).trimmed();
|
||||||
|
m_inbuffer = m_inbuffer.mid(pos + 3);
|
||||||
|
emit outputReady(QString::fromUtf8(response));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ private:
|
|||||||
private:
|
private:
|
||||||
DebuggerCommand m_lastDebuggableCommand;
|
DebuggerCommand m_lastDebuggableCommand;
|
||||||
|
|
||||||
QString m_inbuffer;
|
QByteArray m_inbuffer;
|
||||||
QString m_scriptFileName;
|
QString m_scriptFileName;
|
||||||
Utils::Process m_lldbProc;
|
Utils::Process m_lldbProc;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user