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()
|
||||
{
|
||||
QByteArray outba = m_lldbProc.readAllRawStandardOutput();
|
||||
outba.replace("\r\n", "\n");
|
||||
QString out = QString::fromUtf8(outba);
|
||||
showMessage(out, LogOutput);
|
||||
const QByteArray out = m_lldbProc.readAllRawStandardOutput();
|
||||
showMessage(QString::fromUtf8(out), LogOutput);
|
||||
m_inbuffer.append(out);
|
||||
while (true) {
|
||||
int pos = m_inbuffer.indexOf("@\n");
|
||||
if (pos == -1)
|
||||
break;
|
||||
QString response = m_inbuffer.left(pos).trimmed();
|
||||
if (int pos = m_inbuffer.indexOf("@\n"); pos >= 0) {
|
||||
const QByteArray response = m_inbuffer.left(pos).trimmed();
|
||||
m_inbuffer = m_inbuffer.mid(pos + 2);
|
||||
emit outputReady(response);
|
||||
emit outputReady(QString::fromUtf8(response));
|
||||
continue;
|
||||
}
|
||||
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:
|
||||
DebuggerCommand m_lastDebuggableCommand;
|
||||
|
||||
QString m_inbuffer;
|
||||
QByteArray m_inbuffer;
|
||||
QString m_scriptFileName;
|
||||
Utils::Process m_lldbProc;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user