diff --git a/share/qtcreator/gdbmacros/gdbmacros.cpp b/share/qtcreator/gdbmacros/gdbmacros.cpp index d1bf4126336a7305761707429e8bfbe9cd73ef88..665231f4fa7314a2c3c8e01eb18cb1409e98a8b6 100644 --- a/share/qtcreator/gdbmacros/gdbmacros.cpp +++ b/share/qtcreator/gdbmacros/gdbmacros.cpp @@ -490,8 +490,10 @@ struct QDumper void beginItem(const char *name); // start of named item, ready to accept value void endItem(); // end of named item, used after value output is complete - // convienience for putting "<n items>" + // convenience for putting "<n items>" void putItemCount(const char *name, int count); + // convenience for putting "<>n items>" (more than X items) + void putTruncatedItemCount(const char *name, int count); void putCommaIfNeeded(); // convienience function for writing the last item of an abbreviated list void putEllipsis(); @@ -753,6 +755,11 @@ void QDumper::putItemCount(const char *name, int count) put(name).put("=\"<").put(count).put(" items>\""); } +void QDumper::putTruncatedItemCount(const char *name, int count) +{ + putCommaIfNeeded(); + put(name).put("=\"<>").put(count).put(" items>\""); +} // // Some helpers to keep the dumper code short @@ -3148,16 +3155,18 @@ static void qDumpStdList(QDumper &d) p = deref(addOffset(p, sizeof(void*))); qCheckAccess(p); #endif - int nn = 0; + std::list<int>::size_type nn = 0; + const std::list<int>::size_type maxItems = 100; std::list<int>::const_iterator it = list.begin(); const std::list<int>::const_iterator cend = list.end(); - for (; nn < 101 && it != cend; ++nn, ++it) + for (; nn < maxItems && it != cend; ++nn, ++it) qCheckAccess(it.operator->()); - if (nn > 100) - d.putItem("value", "<more than 100 items>"); - else + if (it != cend) { + d.putTruncatedItemCount("value", nn); + } else { d.putItemCount("value", nn); + } d.putItem("numchild", nn); d.putItem("valueeditable", "false"); @@ -3167,7 +3176,7 @@ static void qDumpStdList(QDumper &d) isPointerType(d.innerType) ? strippedInnerType.data() : 0; d.beginChildren(d.innerType); it = list.begin(); - for (int i = 0; i < 1000 && it != cend; ++i, ++it) { + for (std::list<int>::size_type i = 0; i < maxItems && it != cend; ++i, ++it) { d.beginHash(); qDumpInnerValueOrPointer(d, d.innerType, stripped, it.operator->()); d.endHash(); @@ -3250,7 +3259,6 @@ static void qDumpStdMapHelper(QDumper &d) for (int i = 0; i < nn && i < 10 && it != cend; ++i, ++it) qCheckAccess(it.operator->()); - const QByteArray strippedInnerType = stripPointerType(d.innerType); d.putItem("numchild", nn); d.putItemCount("value", nn); d.putItem("valueeditable", "false"); @@ -3399,7 +3407,7 @@ static void qDumpStdSet(QDumper &d) #ifdef Q_CC_MSVC // As the set implementation inherits from a base class // depending on the key, use something equivalent to iterate it. - const int innerSize = d.extraInt[0]; + const size_t innerSize = d.extraInt[0]; if (innerSize == sizeof(int)) { qDumpStdSetHelper<int>(d); return; diff --git a/src/plugins/debugger/watchhandler.cpp b/src/plugins/debugger/watchhandler.cpp index 488de4223dc5865eb7848311fd5e05db413e8e5b..484b3a2a9032fc60b819d664d9554e908f5e85fe 100644 --- a/src/plugins/debugger/watchhandler.cpp +++ b/src/plugins/debugger/watchhandler.cpp @@ -481,8 +481,15 @@ static inline QString formattedValue(const WatchData &data, int format) else if (result == QLatin1String("<not accessible>")) result = WatchHandler::tr("<not accessible>"); else if (result.endsWith(" items>")) { - const int size = result.mid(1, result.indexOf(' ') - 1).toInt(); - result = WatchHandler::tr("<%n items>", 0, size); + // '<10 items>' or '<>10 items>' (more than) + bool ok; + const bool moreThan = result.at(1) == QLatin1Char('>'); + const int numberPos = moreThan ? 2 : 1; + const int size = result.mid(numberPos, result.indexOf(' ') - numberPos).toInt(&ok); + QTC_ASSERT(ok, qWarning("WatchHandler: Invalid item count '%s'", qPrintable(result)) ; ) + result = moreThan ? + WatchHandler::tr("<more than %n items>", 0, size) : + WatchHandler::tr("<%n items>", 0, size); } } return result;