forked from qt-creator/qt-creator
Debugger: Add display of captures to QRegExp dumper
Change-Id: I345c72091002fad16af4549332bb7d8a1fb88155 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -2867,16 +2867,14 @@ class DumperBase:
|
||||
return val
|
||||
error("BAD DATA TO DEREFERENCE: %s %s" % (self.type, type(self)))
|
||||
|
||||
def cast(self, typeobj):
|
||||
if not isinstance(typeobj, self.dumper.Type):
|
||||
error("BAD TYPE IN CAST: %s" % typeobj)
|
||||
def cast(self, typish):
|
||||
self.check()
|
||||
typeobj = self.dumper.createType(typish)
|
||||
if self.nativeValue is not None and typeobj.nativeType is not None:
|
||||
res = self.dumper.nativeValueCast(self.nativeValue, typeobj.nativeType)
|
||||
if res is not None:
|
||||
return res
|
||||
#error("BAD NATIVE DATA TO CAST: %s %s" % (self.type, typeobj))
|
||||
#if self.laddress is not None:
|
||||
val = self.dumper.Value(self.dumper)
|
||||
val.laddress = self.laddress
|
||||
val.ldata = self.ldata
|
||||
@@ -3295,7 +3293,7 @@ class DumperBase:
|
||||
return typish
|
||||
if isinstance(typish, str):
|
||||
if typish[0] == 'Q':
|
||||
if typish in ("QByteArray", "QString"):
|
||||
if typish in ("QByteArray", "QString", "QList", "QStringList"):
|
||||
typish = self.qtNamespace() + typish
|
||||
size = self.ptrSize()
|
||||
elif typish == "QImage":
|
||||
@@ -3334,7 +3332,7 @@ class DumperBase:
|
||||
error("NEED TYPE, NOT %s" % type(typish))
|
||||
|
||||
def createValue(self, datish, typish):
|
||||
if self.isInt(datish):
|
||||
if self.isInt(datish): # Used as address.
|
||||
#warn("CREATING %s AT 0x%x" % (typish, address))
|
||||
val = self.Value(self)
|
||||
val.laddress = datish
|
||||
|
||||
@@ -1115,34 +1115,15 @@ def qdump__QRectF(d, value):
|
||||
def qdump__QRegExp(d, value):
|
||||
# value.priv.engineKey.pattern
|
||||
privAddress = d.extractPointer(value)
|
||||
engineKeyAddress = privAddress + d.ptrSize()
|
||||
patternAddress = engineKeyAddress
|
||||
d.putStringValue(patternAddress)
|
||||
d.putNumChild(1)
|
||||
(eng, pattern) = d.split("p{QString}", privAddress)
|
||||
d.putStringValue(pattern)
|
||||
if d.isExpanded():
|
||||
with Children(d):
|
||||
# QRegExpPrivate:
|
||||
# - QRegExpEngine *eng (+0)
|
||||
# - QRegExpEngineKey: (+1ptr)
|
||||
# - QString pattern; (+1ptr)
|
||||
# - QRegExp::PatternSyntax patternSyntax; (+2ptr)
|
||||
# - Qt::CaseSensitivity cs; (+2ptr +1enum +pad?)
|
||||
# - bool minimal (+2ptr +2enum +2pad?)
|
||||
# - QString t (+2ptr +2enum +1bool +3pad?)
|
||||
# - QStringList captures (+3ptr +2enum +1bool +3pad?)
|
||||
# FIXME: Remove need to call. Needed to warm up cache.
|
||||
d.call("void", value, "capturedTexts") # create cache
|
||||
ns = d.qtNamespace()
|
||||
with SubItem(d, "syntax"):
|
||||
# value["priv"]["engineKey"["capturedCache"]
|
||||
address = engineKeyAddress + d.ptrSize()
|
||||
typ = d.lookupType(ns + "QRegExp::PatternSyntax")
|
||||
d.putItem(d.createValue(address, typ))
|
||||
with SubItem(d, "captures"):
|
||||
# value["priv"]["capturedCache"]
|
||||
address = privAddress + 3 * d.ptrSize() + 12
|
||||
typ = d.lookupType(ns + "QStringList")
|
||||
d.putItem(d.createValue(address, typ))
|
||||
d.call("void", value, "capturedTexts") # Warm up internal cache.
|
||||
(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"))
|
||||
d.putSubItem("captures", captures)
|
||||
|
||||
|
||||
def qdump__QRegion(d, value):
|
||||
|
||||
@@ -2629,12 +2629,13 @@ void tst_Dumpers::dumper_data()
|
||||
"QRegExp re(QString(\"a(.*)b(.*)c\"));\n"
|
||||
"QString str1 = \"a1121b344c\";\n"
|
||||
"QString str2 = \"Xa1121b344c\";\n"
|
||||
"int pos2 = re.indexIn(str2);\n"
|
||||
"int pos1 = re.indexIn(str1);\n"
|
||||
"unused(&pos1, &pos2);\n")
|
||||
"int pos1 = re.indexIn(str1); unused(&pos1);\n"
|
||||
"int pos2 = re.indexIn(str2); unused(&pos2);\n")
|
||||
+ CoreProfile()
|
||||
+ Check("re", "\"a(.*)b(.*)c\"", "@QRegExp")
|
||||
+ Check("str1", "\"a1121b344c\"", "@QString")
|
||||
+ Check("re.captures.0", "[0]", "\"a1121b344c\"", "@QString")
|
||||
+ Check("re.captures.1", "[1]", "\"1121\"", "@QString")
|
||||
+ Check("re.captures.2", "[2]", "\"344\"", "@QString")
|
||||
+ Check("str2", "\"Xa1121b344c\"", "@QString")
|
||||
+ Check("pos1", "0", "int")
|
||||
+ Check("pos2", "1", "int");
|
||||
|
||||
Reference in New Issue
Block a user