Commit ca5ebc33 authored by hjk's avatar hjk
Browse files

Debugger: Make struct field access backend specific



Change-Id: I9ad0a299e3483bebafba6bb1e5c623d9ee2b6c00
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 70fc0397
......@@ -135,6 +135,33 @@ try:
# gdb.execute("set logging redirect off")
return gdb.history(0)
def extractFields(value):
type = stripTypedefs(value.type)
return type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
##fields = type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=11777:
##fields = defsype).fields()
## This seems to work.
##warn("TYPE 0: %s" % type)
#type = stripTypedefs(type)
#fields = type.fields()
#if len(fields):
# return fields
##warn("TYPE 1: %s" % type)
## This fails for arrays. See comment in lookupType.
#type0 = lookupType(str(type))
#if not type0 is None:
# type = type0
#if type.code == FunctionCode:
# return []
##warn("TYPE 2: %s" % type)
#fields = type.fields()
##warn("FIELDS: %s" % fields)
#return fields
def fieldCount(type):
return len(type.fields())
def listOfLocals(varList):
frame = gdb.selected_frame()
......@@ -358,29 +385,6 @@ try:
base += 1
return s
def extractFields(type):
return type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
##fields = type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=11777:
##fields = defsype).fields()
## This seems to work.
##warn("TYPE 0: %s" % type)
#type = stripTypedefs(type)
#fields = type.fields()
#if len(fields):
# return fields
##warn("TYPE 1: %s" % type)
## This fails for arrays. See comment in lookupType.
#type0 = lookupType(str(type))
#if not type0 is None:
# type = type0
#if type.code == FunctionCode:
# return []
##warn("TYPE 2: %s" % type)
#fields = type.fields()
##warn("FIELDS: %s" % fields)
#return fields
#######################################################################
#
......@@ -532,6 +536,9 @@ try:
#except:
# return "<illegal type>"
def fieldCount(self):
return self.raw.num_children
def unqualified(self):
return self
......@@ -541,10 +548,14 @@ try:
self.is_optimized_out = False
self.address = var.addr
self.type = Type(var)
self.name = var.name
def __str__(self):
return str(self.raw.value)
def fields(self):
return [Value(self.raw.GetChildAtIndex(i)) for i in range(self.raw.num_children)]
currentThread = None
currentFrame = None
......@@ -563,8 +574,11 @@ try:
items.append(item)
return items
def extractFields(type):
return type.fields()
def extractFields(value):
return value.fields()
def fieldCount(type):
return type.fieldCount();
except:
#warn("LOADING LLDB FAILED")
......
......@@ -802,29 +802,6 @@ def stripTypedefs(type):
type = type.strip_typedefs().unqualified()
return type
def extractFields(type):
return type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
##fields = type.fields()
## Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=11777:
##fields = defsype).fields()
## This seems to work.
##warn("TYPE 0: %s" % type)
#type = stripTypedefs(type)
#fields = type.fields()
#if len(fields):
# return fields
##warn("TYPE 1: %s" % type)
## This fails for arrays. See comment in lookupType.
#type0 = lookupType(str(type))
#if not type0 is None:
# type = type0
#if type.code == FunctionCode:
# return []
##warn("TYPE 2: %s" % type)
#fields = type.fields()
##warn("FIELDS: %s" % fields)
#return fields
#######################################################################
#
......@@ -1769,11 +1746,10 @@ class Dumper:
#warn("INAME: %s " % self.currentIName)
#warn("INAMES: %s " % self.expandedINames)
#warn("EXPANDED: %s " % (self.currentIName in self.expandedINames))
numfields = len(extractFields(type))
self.tryPutObjectNameValue(value) # Is this too expensive?
self.putType(typeName)
self.putEmptyValue()
self.putNumChild(numfields)
self.putNumChild(fieldCount(type))
if self.currentIName in self.expandedINames:
innerType = None
......@@ -1811,10 +1787,18 @@ class Dumper:
pass
def putFields(self, value, dumpBase = True):
type = stripTypedefs(value.type)
# Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
#fields = type.fields()
fields = extractFields(type)
fields = extractFields(value)
# FIXME: Merge into this function.
if gdbLoaded:
self.putFieldsGdb(fields, value, dumpBase)
return
for field in fields:
with SubItem(self, field.name):
self.putItem(field)
def putFieldsGdb(self, fields, value, dumpBase):
#warn("TYPE: %s" % type)
#warn("FIELDS: %s" % fields)
baseNumber = 0
......@@ -1822,9 +1806,6 @@ class Dumper:
#warn("FIELD: %s" % field)
#warn(" BITSIZE: %s" % field.bitsize)
#warn(" ARTIFICIAL: %s" % field.artificial)
bitpos = getattr(field, "bitpos", None)
if bitpos is None: # FIXME: Is check correct?
continue # A static class member(?).
if field.name is None:
innerType = type.target()
......@@ -1877,8 +1858,7 @@ class Dumper:
with SubItem(self, field.name):
#bitsize = getattr(field, "bitsize", None)
#if not bitsize is None:
# self.put("bitsize=\"%s\",bitpos=\"%s\","
# % (bitsize, bitpos))
# self.put("bitsize=\"%s\"" % bitsize)
self.putItem(downcast(value[field.name]))
......
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