From e9f0f370702c90faaaacaebcd7e64c35dc2ead2c Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 22 Nov 2016 16:44:50 +0100 Subject: [PATCH] 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 --- share/qtcreator/debugger/qttypes.py | 6 +++++- tests/auto/debugger/tst_dumpers.cpp | 9 ++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/share/qtcreator/debugger/qttypes.py b/share/qtcreator/debugger/qttypes.py index 25faf326a31..2eb3055e8a0 100644 --- a/share/qtcreator/debugger/qttypes.py +++ b/share/qtcreator/debugger/qttypes.py @@ -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')) diff --git a/tests/auto/debugger/tst_dumpers.cpp b/tests/auto/debugger/tst_dumpers.cpp index bcac63df91e..f2b540239de 100644 --- a/tests/auto/debugger/tst_dumpers.cpp +++ b/tests/auto/debugger/tst_dumpers.cpp @@ -2748,12 +2748,14 @@ void tst_Dumpers::dumper_data() QTest::newRow("QRegExp") - << Data("#include \n", + << Data("#include \n" + "#include \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")