Debugger: Make struct field access backend specific

Change-Id: I9ad0a299e3483bebafba6bb1e5c623d9ee2b6c00
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2013-04-04 18:14:47 +02:00
parent 70fc039796
commit ca5ebc33fa
2 changed files with 53 additions and 59 deletions

View File

@@ -135,6 +135,33 @@ try:
# gdb.execute("set logging redirect off") # gdb.execute("set logging redirect off")
return gdb.history(0) 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): def listOfLocals(varList):
frame = gdb.selected_frame() frame = gdb.selected_frame()
@@ -358,29 +385,6 @@ try:
base += 1 base += 1
return s 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: #except:
# return "<illegal type>" # return "<illegal type>"
def fieldCount(self):
return self.raw.num_children
def unqualified(self): def unqualified(self):
return self return self
@@ -541,10 +548,14 @@ try:
self.is_optimized_out = False self.is_optimized_out = False
self.address = var.addr self.address = var.addr
self.type = Type(var) self.type = Type(var)
self.name = var.name
def __str__(self): def __str__(self):
return str(self.raw.value) return str(self.raw.value)
def fields(self):
return [Value(self.raw.GetChildAtIndex(i)) for i in range(self.raw.num_children)]
currentThread = None currentThread = None
currentFrame = None currentFrame = None
@@ -563,8 +574,11 @@ try:
items.append(item) items.append(item)
return items return items
def extractFields(type): def extractFields(value):
return type.fields() return value.fields()
def fieldCount(type):
return type.fieldCount();
except: except:
#warn("LOADING LLDB FAILED") #warn("LOADING LLDB FAILED")

View File

@@ -802,29 +802,6 @@ def stripTypedefs(type):
type = type.strip_typedefs().unqualified() type = type.strip_typedefs().unqualified()
return type 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("INAME: %s " % self.currentIName)
#warn("INAMES: %s " % self.expandedINames) #warn("INAMES: %s " % self.expandedINames)
#warn("EXPANDED: %s " % (self.currentIName in self.expandedINames)) #warn("EXPANDED: %s " % (self.currentIName in self.expandedINames))
numfields = len(extractFields(type))
self.tryPutObjectNameValue(value) # Is this too expensive? self.tryPutObjectNameValue(value) # Is this too expensive?
self.putType(typeName) self.putType(typeName)
self.putEmptyValue() self.putEmptyValue()
self.putNumChild(numfields) self.putNumChild(fieldCount(type))
if self.currentIName in self.expandedINames: if self.currentIName in self.expandedINames:
innerType = None innerType = None
@@ -1811,10 +1787,18 @@ class Dumper:
pass pass
def putFields(self, value, dumpBase = True): def putFields(self, value, dumpBase = True):
type = stripTypedefs(value.type) fields = extractFields(value)
# Insufficient, see http://sourceware.org/bugzilla/show_bug.cgi?id=10953:
#fields = type.fields() # FIXME: Merge into this function.
fields = extractFields(type) 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("TYPE: %s" % type)
#warn("FIELDS: %s" % fields) #warn("FIELDS: %s" % fields)
baseNumber = 0 baseNumber = 0
@@ -1822,9 +1806,6 @@ class Dumper:
#warn("FIELD: %s" % field) #warn("FIELD: %s" % field)
#warn(" BITSIZE: %s" % field.bitsize) #warn(" BITSIZE: %s" % field.bitsize)
#warn(" ARTIFICIAL: %s" % field.artificial) #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: if field.name is None:
innerType = type.target() innerType = type.target()
@@ -1877,8 +1858,7 @@ class Dumper:
with SubItem(self, field.name): with SubItem(self, field.name):
#bitsize = getattr(field, "bitsize", None) #bitsize = getattr(field, "bitsize", None)
#if not bitsize is None: #if not bitsize is None:
# self.put("bitsize=\"%s\",bitpos=\"%s\"," # self.put("bitsize=\"%s\"" % bitsize)
# % (bitsize, bitpos))
self.putItem(downcast(value[field.name])) self.putItem(downcast(value[field.name]))