Commit d573195b authored by hjk's avatar hjk

Debugger: Improve handling of imported system dumpers

At least for a few cases (std::string, vector, ...) this can succeed.

Change-Id: Idfa4ced4cb20295472d001181a83373acd89883a
Reviewed-by: default avatarChristian Stenger <christian.stenger@theqtcompany.com>
parent 34765467
......@@ -489,6 +489,31 @@ class DumperBase:
elided, shown = self.computeLimit(size, limit)
return elided, self.readMemory(data, shown)
def putStdStringHelper(self, data, size, charSize):
bytelen = size * charSize
elided, shown = self.computeLimit(bytelen, self.displayStringLimit)
mem = self.readMemory(data, shown)
if charSize == 1:
encodingType = Hex2EncodedLatin1
displayType = DisplayLatin1String
elif charSize == 2:
encodingType = Hex4EncodedLittleEndian
displayType = DisplayUtf16String
else:
encodingType = Hex8EncodedLittleEndian
displayType = DisplayUtf16String
self.putNumChild(0)
self.putValue(mem, encodingType, elided=elided)
format = self.currentItemFormat()
if format == 1:
self.putDisplay(StopDisplay)
elif format == 2:
self.putField("editformat", displayType)
elided, shown = self.computeLimit(bytelen, 100000)
self.putField("editvalue", self.readMemory(data, shown))
def readMemory(self, addr, size):
data = self.extractBlob(addr, size).toBytes()
return self.hexencode(data)
......
......@@ -171,9 +171,12 @@ class PlainDumper:
lister = getattr(printer, "children", None)
children = [] if lister is None else list(lister())
d.putType(self.printer.name)
val = printer.to_string().encode("hex")
d.putValue(val, Hex2EncodedLatin1)
d.putValue(printer.to_string())
val = printer.to_string()
if isinstance(val, str):
d.putValue(val)
else: # Assuming LazyString
d.putStdStringHelper(val.address, val.length, val.type.sizeof)
d.putNumChild(len(children))
if d.isExpanded():
with Children(d):
......
......@@ -418,7 +418,7 @@ def qdump__std__stringHelper1(d, value, charSize):
refcount = int(sizePtr[-1]) & 0xffffffff
d.check(refcount >= -1) # Can be -1 accoring to docs.
d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
qdump_stringHelper(d, sizePtr, size * charSize, charSize)
d.putStdStringHelper(sizePtr, size, charSize)
def qdump__std__stringHelper1__QNX(d, value, charSize):
size = value['_Mysize']
......@@ -432,31 +432,7 @@ def qdump__std__stringHelper1__QNX(d, value, charSize):
refcount = int(sizePtr[-1])
d.check(refcount >= -1) # Can be -1 accoring to docs.
d.check(0 <= size and size <= alloc and alloc <= 100*1000*1000)
qdump_stringHelper(d, sizePtr, size * charSize, charSize)
def qdump_stringHelper(d, data, size, charSize):
elided, shown = d.computeLimit(size, d.displayStringLimit)
mem = d.readMemory(data, shown)
if charSize == 1:
encodingType = Hex2EncodedLatin1
displayType = DisplayLatin1String
elif charSize == 2:
encodingType = Hex4EncodedLittleEndian
displayType = DisplayUtf16String
else:
encodingType = Hex8EncodedLittleEndian
displayType = DisplayUtf16String
d.putNumChild(0)
d.putValue(mem, encodingType, elided=elided)
format = d.currentItemFormat()
if format == 1:
d.putDisplay(StopDisplay)
elif format == 2:
d.putField("editformat", displayType)
elided, shown = d.computeLimit(size, 100000)
d.putField("editvalue", d.readMemory(data, shown))
d.putStdStringHelper(sizePtr, size, charSize)
def qdump__std____1__string(d, value):
......@@ -470,7 +446,7 @@ def qdump__std____1__string(d, value):
# Short/internal.
size = firstByte / 2
data = base + 1
qdump_stringHelper(d, data, size, 1)
d.putStdStringHelper(data, size, 1)
d.putType("std::string")
......@@ -485,7 +461,7 @@ def qdump__std____1__wstring(d, value):
# Short/internal.
size = firstByte / 2
data = base + 4
qdump_stringHelper(d, data, size * 4, 4)
d.putStdStringHelper(data, size, 4)
d.putType("std::xxwstring")
......
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