Commit 3ae6c097 authored by hjk's avatar hjk

Debugger: Regression cleanup

Sneaked in with 40052046.

Change-Id: I711c5b8e6869647a447a5f17f693de571b5f0337
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 0360017b
...@@ -77,11 +77,15 @@ class ReportItem: ...@@ -77,11 +77,15 @@ class ReportItem:
or a type scheduled to be reported. This might get overridden be or a type scheduled to be reported. This might get overridden be
subsequent better guesses during a putItem() run. subsequent better guesses during a putItem() run.
""" """
def __init__(self): def __init__(self, value = None, encoding = None, priority = -100, elided = None):
self.value = None self.value = value
self.priority = -100 self.priority = priority
self.encoding = None self.encoding = encoding
self.elided = 0 self.elided = elided
def __str__(self):
return "Item(value: %s, encoding: %s, priority: %s, elided: %s)" \
% (self.value, self.encoding, self.priority, self.elided)
class Blob(object): class Blob(object):
...@@ -391,6 +395,8 @@ class DumperBase: ...@@ -391,6 +395,8 @@ class DumperBase:
# Clamps size to limit. # Clamps size to limit.
def computeLimit(self, size, limit): def computeLimit(self, size, limit):
if limit == 0:
limit = self.displayStringLimit
if limit is None or size <= limit: if limit is None or size <= limit:
return 0, size return 0, size
return size, limit return size, limit
...@@ -461,17 +467,13 @@ class DumperBase: ...@@ -461,17 +467,13 @@ class DumperBase:
def byteArrayData(self, value): def byteArrayData(self, value):
return self.byteArrayDataHelper(self.extractPointer(value)) return self.byteArrayDataHelper(self.extractPointer(value))
def putByteArrayValue(self, value):
elided, data = self.encodeByteArrayHelper(self.extractPointer(value), self.displayStringLimit)
self.putValue(data, Hex2EncodedLatin1, elided=elided)
def putByteArrayValueByAddress(self, addr): def putByteArrayValueByAddress(self, addr):
elided, data = self.encodeByteArrayHelper(addr, self.displayStringLimit) elided, data = self.encodeByteArrayHelper(addr, self.displayStringLimit)
self.putValue(data, Hex2EncodedLatin1, elided=elided) self.putValue(data, Hex2EncodedLatin1, elided=elided)
def putStringValueByAddress(self, addr): def putByteArrayValue(self, value):
elided, data = self.encodeStringHelper(self.extractPointer(addr), self.displayStringLimit) elided, data = self.encodeByteArrayHelper(self.extractPointer(value), self.displayStringLimit)
self.putValue(data, Hex4EncodedLittleEndian, elided=elided) self.putValue(data, Hex2EncodedLatin1, elided=elided)
def encodeString(self, value, limit = 0): def encodeString(self, value, limit = 0):
elided, data = self.encodeStringHelper(self.extractPointer(value), limit) elided, data = self.encodeStringHelper(self.extractPointer(value), limit)
...@@ -508,6 +510,10 @@ class DumperBase: ...@@ -508,6 +510,10 @@ class DumperBase:
skipSpace = False skipSpace = False
return inner.strip() return inner.strip()
def putStringValueByAddress(self, addr):
elided, data = self.encodeStringHelper(addr, self.displayStringLimit)
self.putValue(data, Hex4EncodedLittleEndian, elided=elided)
def putStringValue(self, value): def putStringValue(self, value):
elided, data = self.encodeStringHelper(self.extractPointer(value), self.displayStringLimit) elided, data = self.encodeStringHelper(self.extractPointer(value), self.displayStringLimit)
self.putValue(data, Hex4EncodedLittleEndian, elided=elided) self.putValue(data, Hex4EncodedLittleEndian, elided=elided)
...@@ -663,23 +669,20 @@ class DumperBase: ...@@ -663,23 +669,20 @@ class DumperBase:
# elided = 0 indicates all data is available in value, # elided = 0 indicates all data is available in value,
# otherwise it's the true length. # otherwise it's the true length.
if priority >= self.currentValue.priority: if priority >= self.currentValue.priority:
self.currentValue.value = value self.currentValue = ReportItem(value, encoding, priority, elided)
self.currentValue.priority = priority
self.currentValue.encoding = encoding
self.currentValue.elided = elided
def putEmptyValue(self, priority = -10): def putEmptyValue(self, priority = -10):
if priority >= self.currentValue.priority: if priority >= self.currentValue.priority:
self.currentValue.value = "" self.currentValue = ReportItem("", None, priority, None)
self.currentValue.priority = priority
self.currentValue.encoding = None
self.currentValue.elided = None
def putName(self, name): def putName(self, name):
self.put('name="%s",' % name) self.put('name="%s",' % name)
def putBetterType(self, type): def putBetterType(self, type):
self.currentType.value = str(type) if isinstance(type, ReportItem):
self.currentType.value = str(type.value)
else:
self.currentType.value = str(type)
self.currentType.priority += 1 self.currentType.priority += 1
def putNoType(self): def putNoType(self):
...@@ -1158,7 +1161,7 @@ class DumperBase: ...@@ -1158,7 +1161,7 @@ class DumperBase:
self.putItem(v) self.putItem(v)
propertyCount += 1 propertyCount += 1
self.putValue('<%s items>' % propertyCount if propertyCount else '<>0 items>') self.putValue(str('<%s items>' % propertyCount if propertyCount else '<>0 items>'))
self.putNumChild(1) self.putNumChild(1)
with SubItem(self, "[methods]"): with SubItem(self, "[methods]"):
......
...@@ -532,23 +532,18 @@ class Dumper(DumperBase): ...@@ -532,23 +532,18 @@ class Dumper(DumperBase):
self.currentAddress = None self.currentAddress = None
def exitSubItem(self, item, exType, exValue, exTraceBack): def exitSubItem(self, item, exType, exValue, exTraceBack):
#warn("CURRENT VALUE: %s: %s %s %s %s" % ( #warn("CURRENT VALUE: %s: %s %s" % (self.currentIName, self.currentValue, self.currentType))
# self.currentIName,
# self.currentValue.value,
# self.currentValue.elided,
# self.currentValue.encoding,
# self.currentValue.priority))
if not exType is None: if not exType is None:
if self.passExceptions: if self.passExceptions:
showException("SUBITEM", exType, exValue, exTraceBack) showException("SUBITEM", exType, exValue, exTraceBack)
self.putNumChild(0) self.putNumChild(0)
self.putValue("<not accessible>") self.putValue("<not accessible>")
try: try:
#warn("CURRENT TYPE: %s" % self.currentType.value) if self.currentType.value:
typeName = stripClassTag(self.currentType.value) typeName = stripClassTag(self.currentType.value)
if len(typeName) > 0 and typeName != self.currentChildType:
self.put('type="%s",' % typeName) # str(type.unqualified()) ?
if len(typeName) > 0 and typeName != self.currentChildType:
self.put('type="%s",' % typeName) # str(type.unqualified()) ?
if self.currentValue.value is None: if self.currentValue.value is None:
self.put('value="<not accessible>",numchild="0",') self.put('value="<not accessible>",numchild="0",')
else: else:
...@@ -1045,7 +1040,7 @@ class Dumper(DumperBase): ...@@ -1045,7 +1040,7 @@ class Dumper(DumperBase):
# generic pointer." with MinGW's gcc 4.5 when it "identifies" # generic pointer." with MinGW's gcc 4.5 when it "identifies"
# a "QWidget &" as "void &" and with optimized out code. # a "QWidget &" as "void &" and with optimized out code.
self.putItem(value.cast(type.target().unqualified())) self.putItem(value.cast(type.target().unqualified()))
self.putBetterType("%s &" % self.currentType) self.putBetterType("%s &" % self.currentType.value)
return return
except RuntimeError: except RuntimeError:
self.putValue("<optimized out reference>") self.putValue("<optimized out reference>")
......
...@@ -319,9 +319,10 @@ class Dumper(DumperBase): ...@@ -319,9 +319,10 @@ class Dumper(DumperBase):
self.putNumChild(0) self.putNumChild(0)
self.putValue("<not accessible>") self.putValue("<not accessible>")
try: try:
typeName = self.currentType.value if self.currentType.value:
if len(typeName) > 0 and typeName != self.currentChildType: typeName = self.currentType.value
self.put('type="%s",' % typeName) # str(type.unqualified()) ? if len(typeName) > 0 and typeName != self.currentChildType:
self.put('type="%s",' % typeName) # str(type.unqualified()) ?
if self.currentValue.value is None: if self.currentValue.value is None:
self.put('value="<not accessible>",numchild="0",') self.put('value="<not accessible>",numchild="0",')
else: else:
......
...@@ -239,7 +239,7 @@ def qdump__QTimeZone(d, value): ...@@ -239,7 +239,7 @@ def qdump__QTimeZone(d, value):
d.putNumChild(0) d.putNumChild(0)
return return
idAddr = base + 2 * d.ptrSize() # [QSharedData] + [vptr] idAddr = base + 2 * d.ptrSize() # [QSharedData] + [vptr]
d.putByteArrayValueByAddress(idAddr) d.putByteArrayValue(idAddr)
d.putPlainChildren(value["d"]) d.putPlainChildren(value["d"])
...@@ -392,7 +392,7 @@ def qdump__QDir(d, value): ...@@ -392,7 +392,7 @@ def qdump__QDir(d, value):
dirEntryOffset = fileInfosOffset + d.ptrSize() dirEntryOffset = fileInfosOffset + d.ptrSize()
absoluteDirEntryOffset = dirEntryOffset + fileSystemEntrySize absoluteDirEntryOffset = dirEntryOffset + fileSystemEntrySize
d.putStringValueByAddress(privAddress + dirEntryOffset) d.putStringValue(privAddress + dirEntryOffset)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
ns = d.qtNamespace() ns = d.qtNamespace()
...@@ -429,7 +429,7 @@ def qdump__QFile(d, value): ...@@ -429,7 +429,7 @@ def qdump__QFile(d, value):
offset = 140 if is32bit else 232 offset = 140 if is32bit else 232
privAddress = d.extractPointer(d.addressOf(value) + d.ptrSize()) privAddress = d.extractPointer(d.addressOf(value) + d.ptrSize())
fileNameAddress = privAddress + offset fileNameAddress = privAddress + offset
d.putStringValueByAddress(fileNameAddress) d.putStringValue(fileNameAddress)
d.putNumChild(1) d.putNumChild(1)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
...@@ -447,7 +447,7 @@ def qdump__QFileInfo(d, value): ...@@ -447,7 +447,7 @@ def qdump__QFileInfo(d, value):
# d.putPlainChildren(value) # d.putPlainChildren(value)
# return # return
filePathAddress = privAddress + d.ptrSize() filePathAddress = privAddress + d.ptrSize()
d.putStringValueByAddress(filePathAddress) d.putStringValue(filePathAddress)
d.putNumChild(1) d.putNumChild(1)
if d.isExpanded(): if d.isExpanded():
ns = d.qtNamespace() ns = d.qtNamespace()
...@@ -705,7 +705,7 @@ def qdump__QHostAddress(d, value): ...@@ -705,7 +705,7 @@ def qdump__QHostAddress(d, value):
ipStringAddress = privAddress + (0 if isQt5 else 24) ipStringAddress = privAddress + (0 if isQt5 else 24)
isParsedAddress = privAddress + 24 + 2 * sizeofQString isParsedAddress = privAddress + 24 + 2 * sizeofQString
# value.d.d->ipString # value.d.d->ipString
ipString = d.encodeStringHelper(d.extractPointer(ipStringAddress), limit=100) ipString = d.encodeString(ipStringAddress, limit=100)
if d.extractByte(isParsedAddress) and len(ipString) > 0: if d.extractByte(isParsedAddress) and len(ipString) > 0:
d.putValue(ipString, Hex4EncodedLittleEndian) d.putValue(ipString, Hex4EncodedLittleEndian)
else: else:
...@@ -720,7 +720,7 @@ def qdump__QHostAddress(d, value): ...@@ -720,7 +720,7 @@ def qdump__QHostAddress(d, value):
data = d.readMemory(privAddress + a6Offset, 16) data = d.readMemory(privAddress + a6Offset, 16)
address = ':'.join("%x" % int(data[i:i+4], 16) for i in xrange(0, 32, 4)) address = ':'.join("%x" % int(data[i:i+4], 16) for i in xrange(0, 32, 4))
scopeId = privAddress + sizeofQString + (0 if isQt5 else 24) scopeId = privAddress + sizeofQString + (0 if isQt5 else 24)
scopeId = d.encodeStringHelper(d.extractPointer(scopeId), limit=100) scopeId = d.encodeString(scopeId, limit=100)
d.putValue("%s%%%s" % (address, scopeId), IPv6AddressAndHexScopeId) d.putValue("%s%%%s" % (address, scopeId), IPv6AddressAndHexScopeId)
elif proto == 0: elif proto == 0:
# value.d.d->a # value.d.d->a
...@@ -1531,7 +1531,7 @@ def qdump__QRegExp(d, value): ...@@ -1531,7 +1531,7 @@ def qdump__QRegExp(d, value):
privAddress = d.extractPointer(value) privAddress = d.extractPointer(value)
engineKeyAddress = privAddress + d.ptrSize() engineKeyAddress = privAddress + d.ptrSize()
patternAddress = engineKeyAddress patternAddress = engineKeyAddress
d.putStringValueByAddress(patternAddress) d.putStringValue(patternAddress)
d.putNumChild(1) d.putNumChild(1)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
...@@ -1843,13 +1843,13 @@ def qdump__QUrl(d, value): ...@@ -1843,13 +1843,13 @@ def qdump__QUrl(d, value):
d.putValue("<invalid>") d.putValue("<invalid>")
return return
schemeAddr = privAddress + 2 * d.intSize() schemeAddr = privAddress + 2 * d.intSize()
scheme = d.encodeStringHelper(d.extractPointer(schemeAddr), limit=1000) scheme = d.encodeString(schemeAddr, limit=1000)
userName = d.encodeStringHelper(d.extractPointer(schemeAddr + 1 * d.ptrSize()), limit=100) userName = d.encodeString(schemeAddr + 1 * d.ptrSize(), limit=100)
password = d.encodeStringHelper(d.extractPointer(schemeAddr + 2 * d.ptrSize()), limit=100) password = d.encodeString(schemeAddr + 2 * d.ptrSize(), limit=100)
host = d.encodeStringHelper(d.extractPointer(schemeAddr + 3 * d.ptrSize()), limit=100) host = d.encodeString(schemeAddr + 3 * d.ptrSize(), limit=100)
path = d.encodeStringHelper(d.extractPointer(schemeAddr + 4 * d.ptrSize()), limit=1000) path = d.encodeString(schemeAddr + 4 * d.ptrSize(), limit=1000)
query = d.encodeStringHelper(d.extractPointer(schemeAddr + 5 * d.ptrSize()), limit=10000) query = d.encodeString(schemeAddr + 5 * d.ptrSize(), limit=10000)
fragment = d.encodeStringHelper(d.extractPointer(schemeAddr + 6 * d.ptrSize()), limit=10000) fragment = d.encodeString(schemeAddr + 6 * d.ptrSize(), limit=10000)
port = d.extractInt(d.extractPointer(value) + d.intSize()) port = d.extractInt(d.extractPointer(value) + d.intSize())
url = scheme url = scheme
......
...@@ -1062,7 +1062,7 @@ void tst_Dumpers::dumper() ...@@ -1062,7 +1062,7 @@ void tst_Dumpers::dumper()
//qDebug() << "Starting qmake: " << cmd; //qDebug() << "Starting qmake: " << cmd;
QStringList options; QStringList options;
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
if (m_qtVersion < 0x050000) if (m_qtVersion && m_qtVersion < 0x050000)
options << QLatin1String("-spec") << QLatin1String("unsupported/macx-clang"); options << QLatin1String("-spec") << QLatin1String("unsupported/macx-clang");
#endif #endif
qmake.start(cmd, options); qmake.start(cmd, options);
...@@ -1424,8 +1424,8 @@ void tst_Dumpers::dumper_data() ...@@ -1424,8 +1424,8 @@ void tst_Dumpers::dumper_data()
+ Check("ba1.13", "[13]", "2", "char") + Check("ba1.13", "[13]", "2", "char")
+ CheckType("ba2", "@QByteArray") + CheckType("ba2", "@QByteArray")
+ Check("s", '"' + QByteArray(10000, 'x') + '"', "@QString") + Check("s", '"' + QByteArray(100, 'x') + '"', "@QString")
+ Check("ss", '"' + QByteArray(10000, 'c') + '"', "std::string") + Check("ss", '"' + QByteArray(100, 'c') + '"', "std::string")
+ Check("buf1", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray") + Check("buf1", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray")
+ Check("buf2", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray") + Check("buf2", "\"" + QByteArray(1, (char)0xee) + "\"", "@QByteArray")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment