Debugger: Consolidate metaObject recognition

Same code can be used for LLDB and GDB...

Change-Id: I07aae10fec28f01425cc13285504f57aef3afd25
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hjk
2014-03-12 13:20:21 +01:00
parent 376f77952e
commit af43f684bd
4 changed files with 51 additions and 70 deletions
+6 -43
View File
@@ -657,8 +657,12 @@ class Dumper(DumperBase):
return str(value)
def directBaseClass(self, typeobj, index = 0):
# FIXME: Check it's really a base.
return typeobj.fields()[index]
for f in typeobj.fields():
if f.is_base_class:
if index == 0:
return f.type
index -= 1;
return None
def checkPointer(self, p, align = 1):
if not self.isNull(p):
@@ -861,47 +865,6 @@ class Dumper(DumperBase):
except:
return 0
def extractStaticMetaObjectHelper(self, typeName):
"""
Checks whether type has a Q_OBJECT macro.
Returns the staticMetaObject, or 0.
"""
# No templates for now.
if typeName.find('<') >= 0:
return 0
staticMetaObjectName = typeName + "::staticMetaObject"
result = self.findSymbol(staticMetaObjectName)
# We need to distinguish Q_OBJECT from Q_GADGET:
# a Q_OBJECT SMO has a non-null superdata (unless it's QObject itself),
# a Q_GADGET SMO has a null superdata (hopefully)
if result and typeName != self.qtNamespace() + "QObject":
if not self.extractPointer(result):
# This looks like a Q_GADGET
result = 0
return result
def extractStaticMetaObject(self, typeobj):
"""
Checks recursively whether a type derives from QObject.
"""
typeName = str(typeobj)
result = self.knownStaticMetaObjects.get(typeName, None)
if result is not None: # Is 0 or the static metaobject.
return result
result = self.extractStaticMetaObjectHelper(typeName)
if not result:
fields = typeobj.fields()
if len(fields) and fields[0].is_base_class:
result = self.extractStaticMetaObject(fields[0].type)
self.knownStaticMetaObjects[typeName] = result
return result
def put(self, value):
self.output.append(value)