Commit 484bacdd authored by hjk's avatar hjk

Debugger: Robustify QMetaObject extraction.

LLDB manages to extract a QAction metaobject from any
plain int and classes without any bases.

Change-Id: I22cdd8e5c73d21d837772be83087dc065698db30
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent d1b412ce
...@@ -925,23 +925,35 @@ class DumperBase: ...@@ -925,23 +925,35 @@ class DumperBase:
pass pass
def extractStaticMetaObjectHelper(self, typeName): def extractStaticMetaObjectHelper(self, typeobj):
""" """
Checks whether type has a Q_OBJECT macro. Checks whether type has a Q_OBJECT macro.
Returns the staticMetaObject, or 0. Returns the staticMetaObject, or 0.
""" """
# No templates for now.
if typeName.find('<') >= 0: if self.isSimpleType(typeobj):
return 0 return 0
typeName = str(typeobj)
isQObjectProper = typeName == self.qtNamespace() + "QObject"
if not isQObjectProper:
if self.directBaseClass(typeobj, 0) is None:
return 0
# No templates for now.
if typeName.find('<') >= 0:
return 0
staticMetaObjectName = typeName + "::staticMetaObject" staticMetaObjectName = typeName + "::staticMetaObject"
result = self.findSymbol(staticMetaObjectName) result = self.findSymbol(staticMetaObjectName)
# We need to distinguish Q_OBJECT from Q_GADGET: # 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_OBJECT SMO has a non-null superdata (unless it's QObject itself),
# a Q_GADGET SMO has a null superdata (hopefully) # a Q_GADGET SMO has a null superdata (hopefully)
if result and typeName != self.qtNamespace() + "QObject": if result and not isQObjectProper:
if not self.extractPointer(result): superdata = self.extractPointer(result)
if toInteger(superdata) == 0:
# This looks like a Q_GADGET # This looks like a Q_GADGET
result = 0 result = 0
...@@ -951,12 +963,15 @@ class DumperBase: ...@@ -951,12 +963,15 @@ class DumperBase:
""" """
Checks recursively whether a type derives from QObject. Checks recursively whether a type derives from QObject.
""" """
if not self.useFancy:
return 0
typeName = str(typeobj) typeName = str(typeobj)
result = self.knownStaticMetaObjects.get(typeName, None) result = self.knownStaticMetaObjects.get(typeName, None)
if result is not None: # Is 0 or the static metaobject. if result is not None: # Is 0 or the static metaobject.
return result return result
result = self.extractStaticMetaObjectHelper(typeName) result = self.extractStaticMetaObjectHelper(typeobj)
if not result: if not result:
base = self.directBaseClass(typeobj, 0) base = self.directBaseClass(typeobj, 0)
if base: if base:
......
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