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