Debugger: Robustify QRegExp dumper

The capturesTexts cache may or may not be warm, and
we may or may not be able to warm it. Make the dumper
work in as much cases as possible.

Change-Id: I9d9e0ec0c6a1bcf7288352c2834fedd42071d068
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2016-11-22 16:44:50 +01:00
parent 6190801bf0
commit e9f0f37070
2 changed files with 11 additions and 4 deletions

View File

@@ -1062,7 +1062,11 @@ def qdump__QRegExp(d, value):
d.putNumChild(1)
if d.isExpanded():
with Children(d):
d.call('void', value, 'capturedTexts') # Warm up internal cache.
try:
d.call('void', value, 'capturedTexts') # Warm up internal cache.
except:
# Might fail (LLDB, Core files, ...), still cache might be warm.
pass
(patternSyntax, caseSensitive, minimal, pad, t, captures) \
= d.split('{int}{int}B@{QString}{QStringList}', privAddress + 2 * d.ptrSize())
d.putSubItem('syntax', patternSyntax.cast(d.qtNamespace() + 'QRegExp::PatternSyntax'))

View File

@@ -2748,12 +2748,14 @@ void tst_Dumpers::dumper_data()
QTest::newRow("QRegExp")
<< Data("#include <QRegExp>\n",
<< Data("#include <QRegExp>\n"
"#include <QStringList>\n",
"QRegExp re(QString(\"a(.*)b(.*)c\"));\n"
"QString str1 = \"a1121b344c\";\n"
"QString str2 = \"Xa1121b344c\";\n"
"int pos1 = re.indexIn(str1); unused(&pos1);\n"
"int pos2 = re.indexIn(str2); unused(&pos2);\n")
"int pos2 = re.indexIn(str2); unused(&pos2);\n"
"QStringList caps = re.capturedTexts(); unused(&caps);\n")
+ CoreProfile()
+ UseDebugImage()
+ Check("re", "\"a(.*)b(.*)c\"", "@QRegExp")
@@ -2762,7 +2764,8 @@ void tst_Dumpers::dumper_data()
+ Check("re.captures.2", "[2]", "\"344\"", "@QString")
+ Check("str2", "\"Xa1121b344c\"", "@QString")
+ Check("pos1", "0", "int")
+ Check("pos2", "1", "int");
+ Check("pos2", "1", "int")
+ Check("caps", "<3 items>", "@QStringList");
QTest::newRow("QRect")