From 41df1fb2d3983ccd1ef9bdd2810c3b394a62d028 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 21 Jun 2011 16:45:23 +0200 Subject: debugger: rewrite parser for cli sub-breakpoint notifications Change-Id: I971a2af2534bc650e8c604a5c2dc2e1846dbb045 Reviewed-on: http://codereview.qt.nokia.com/592 Reviewed-by: hjk --- src/plugins/debugger/breakpoint.cpp | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/plugins/debugger/breakpoint.cpp') diff --git a/src/plugins/debugger/breakpoint.cpp b/src/plugins/debugger/breakpoint.cpp index 6b48be34c4..64995dabab 100644 --- a/src/plugins/debugger/breakpoint.cpp +++ b/src/plugins/debugger/breakpoint.cpp @@ -46,12 +46,36 @@ namespace Internal { // ////////////////////////////////////////////////////////////////// +BreakpointId::BreakpointId(const QByteArray &ba) +{ + int pos = ba.indexOf('.'); + if (pos == -1) { + m_majorPart = ba.toInt(); + m_minorPart = 0; + } else { + m_majorPart = ba.left(pos).toInt(); + m_minorPart = ba.mid(pos + 1).toInt(); + } +} + QDebug operator<<(QDebug d, const BreakpointId &id) { d << qPrintable(id.toString()); return d; } +QByteArray BreakpointId::toByteArray() const +{ + if (!isValid()) + return ""; + QByteArray ba = QByteArray::number(m_majorPart); + if (isMinor()) { + ba.append('.'); + ba.append(QByteArray::number(m_minorPart)); + } + return ba; +} + QString BreakpointId::toString() const { if (!isValid()) @@ -199,9 +223,8 @@ QString BreakpointParameters::toString() const BreakpointResponse::BreakpointResponse() { - number = 0; - subNumber = 0; pending = true; + hitCount = 0; multiple = false; correctedLineNumber = 0; } @@ -210,9 +233,7 @@ QString BreakpointResponse::toString() const { QString result = BreakpointParameters::toString(); QTextStream ts(&result); - ts << " Number: " << number; - if (subNumber) - ts << "." << subNumber; + ts << " Number: " << id.toString(); if (pending) ts << " [pending]"; if (!fullName.isEmpty()) @@ -225,6 +246,7 @@ QString BreakpointResponse::toString() const ts << " Extra: " << extra; if (correctedLineNumber) ts << " CorrectedLineNumber: " << correctedLineNumber; + ts << " Hit: " << hitCount << " times"; ts << ' '; return result + BreakpointParameters::toString(); } @@ -232,12 +254,12 @@ QString BreakpointResponse::toString() const void BreakpointResponse::fromParameters(const BreakpointParameters &p) { BreakpointParameters::operator=(p); - number = 0; - subNumber = 0; + id = BreakpointId(); fullName.clear(); multiple = false; extra.clear(); correctedLineNumber = 0; + hitCount = 0; } } // namespace Internal -- cgit v1.2.1