diff --git a/share/qtcreator/dumper/bridge.py b/share/qtcreator/dumper/bridge.py index c80ae5a8160..208c96686d5 100644 --- a/share/qtcreator/dumper/bridge.py +++ b/share/qtcreator/dumper/bridge.py @@ -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 "" + 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") diff --git a/share/qtcreator/dumper/dumper.py b/share/qtcreator/dumper/dumper.py index 774650a09b6..59200f5d116 100644 --- a/share/qtcreator/dumper/dumper.py +++ b/share/qtcreator/dumper/dumper.py @@ -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]))