Commit cc80da53 authored by hjk's avatar hjk

Debugger: Move basic C-style array handling to dumper base class

Just cosmetics. Function was oddly named, in an odd place.

Change-Id: I8bfb33f7f41f01309f4b2be8a802d4093ae25e41
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 9b868248
......@@ -474,6 +474,40 @@ class DumperBase:
self.putNumChild(0)
self.currentValue = None
def putCStyleArray(self, value):
type = value.type.unqualified()
targetType = value[0].type
#self.putAddress(value.address)
self.putType(type)
self.putNumChild(1)
format = self.currentItemFormat()
isDefault = format == None and str(targetType.unqualified()) == "char"
if isDefault or format == 0 or format == 1 or format == 2:
blob = self.readMemory(self.addressOf(value), type.sizeof)
if isDefault:
# Use Latin1 as default for char [].
self.putValue(blob, Hex2EncodedLatin1)
elif format == 0:
# Explicitly requested Latin1 formatting.
self.putValue(blob, Hex2EncodedLatin1)
elif format == 1:
# Explicitly requested UTF-8 formatting.
self.putValue(blob, Hex2EncodedUtf8)
elif format == 2:
# Explicitly requested Local 8-bit formatting.
self.putValue(blob, Hex2EncodedLocal8Bit)
else:
self.putValue("@0x%x" % self.pointerValue(value.cast(targetType.pointer())))
if self.currentIName in self.expandedINames:
p = self.addressOf(value)
ts = targetType.sizeof
if not self.tryPutArrayContents(targetType, p, int(type.sizeof / ts)):
with Children(self, childType=targetType,
addrBase=p, addrStep=ts):
self.putFields(value)
def putFormattedPointer(self, value):
#warn("POINTER: %s" % value)
if self.isNull(value):
......
......@@ -1346,7 +1346,7 @@ class Dumper(DumperBase):
return
if type.code == ArrayCode:
qdump____c_style_array__(self, value)
self.putCStyleArray(value)
return
if type.code == PointerCode:
......
......@@ -912,12 +912,12 @@ class Dumper(DumperBase):
# Arrays
if typeClass == lldb.eTypeClassArray:
qdump____c_style_array__(self, value)
self.putCStyleArray(value)
return
# Vectors like char __attribute__ ((vector_size (8)))
if typeClass == lldb.eTypeClassVector:
qdump____c_style_array__(self, value)
self.putCStyleArray(value)
return
# References
......
......@@ -29,41 +29,6 @@
from dumper import *
def qdump____c_style_array__(d, value):
type = value.type.unqualified()
targetType = value[0].type
#d.putAddress(value.address)
d.putType(type)
d.putNumChild(1)
format = d.currentItemFormat()
isDefault = format == None and str(targetType.unqualified()) == "char"
if isDefault or format == 0 or format == 1 or format == 2:
blob = d.readMemory(d.addressOf(value), type.sizeof)
if isDefault:
# Use Latin1 as default for char [].
d.putValue(blob, Hex2EncodedLatin1)
elif format == 0:
# Explicitly requested Latin1 formatting.
d.putValue(blob, Hex2EncodedLatin1)
elif format == 1:
# Explicitly requested UTF-8 formatting.
d.putValue(blob, Hex2EncodedUtf8)
elif format == 2:
# Explicitly requested Local 8-bit formatting.
d.putValue(blob, Hex2EncodedLocal8Bit)
else:
d.putValue("@0x%x" % d.pointerValue(value.cast(targetType.pointer())))
if d.currentIName in d.expandedINames:
p = d.addressOf(value)
ts = targetType.sizeof
if not d.tryPutArrayContents(targetType, p, int(type.sizeof / ts)):
with Children(d, childType=targetType,
addrBase=p, addrStep=ts):
d.putFields(value)
def qdump__std__array(d, value):
size = d.numericTemplateArgument(value.type, 1)
d.putItemCount(size)
......
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