Debugger: Make GDBMI parser more robust

Task-number: QTCREATORBUG-25745
Change-Id: I1a4f89fc72433548d44461c3c7c02bd53708d12d
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2021-05-18 07:24:41 +02:00
parent 9156c25c9b
commit 1d9f535c8a
2 changed files with 12 additions and 7 deletions

View File

@@ -66,20 +66,20 @@ DebuggerOutputParser::DebuggerOutputParser(const QString &output)
void DebuggerOutputParser::skipCommas()
{
while (from != to && *from == ',')
while (from < to && *from == ',')
++from;
}
void DebuggerOutputParser::skipSpaces()
{
while (from != to && isspace(from->unicode()))
while (from < to && isspace(from->unicode()))
++from;
}
QString DebuggerOutputParser::readString(const std::function<bool(char)> &isValidChar)
{
QString res;
while (from != to && isValidChar(from->unicode()))
while (from < to && isValidChar(from->unicode()))
res += *from++;
return res;
}
@@ -87,7 +87,7 @@ QString DebuggerOutputParser::readString(const std::function<bool(char)> &isVali
int DebuggerOutputParser::readInt()
{
int res = 0;
while (from != to && *from >= '0' && *from <= '9') {
while (from < to && *from >= '0' && *from <= '9') {
res *= 10;
res += (*from++).unicode() - '0';
}
@@ -108,6 +108,9 @@ void GdbMi::parseResultOrValue(DebuggerOutputParser &parser)
{
parser.skipSpaces();
if (parser.isAtEnd())
return;
//qDebug() << "parseResultOrValue: " << parser.buffer();
parseValue(parser);
parser.skipSpaces();
@@ -303,9 +306,11 @@ void GdbMi::parseList(DebuggerOutputParser &parser)
if (child.isValid()) {
m_children.push_back(child);
parser.skipCommas();
} else {
parser.advance();
continue;
}
QTC_ASSERT(!parser.isAtEnd(), break);
parser.advance();
}
}