forked from qt-creator/qt-creator
Debugger: Allow QObject property extraction without debug info
Task-number: QTCREATORBUG-16908 Change-Id: I1e1e9d91a6317808610f39868383b67e5c80a9a4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -254,6 +254,7 @@ class DumperBase:
|
||||
self.typesToReport = {}
|
||||
self.qtNamespaceToReport = None
|
||||
self.qtCustomEventFunc = 0
|
||||
self.qtPropertyFunc = 0
|
||||
self.passExceptions = False
|
||||
self.isTesting = False
|
||||
|
||||
@@ -1473,6 +1474,21 @@ class DumperBase:
|
||||
|
||||
return self.qtCustomEventFunc == customEventFunc
|
||||
|
||||
def extractQObjectProperty(objectPtr):
|
||||
vtablePtr = self.extractPointer(objectPtr)
|
||||
metaObjectFunc = self.extractPointer(vtablePtr)
|
||||
cmd = '((void*(*)(void*))0x%x)((void*)0x%x)' % (metaObjectFunc, objectPtr)
|
||||
try:
|
||||
#warn('MO CMD: %s' % cmd)
|
||||
res = self.parseAndEvaluate(cmd)
|
||||
#warn('MO RES: %s' % res)
|
||||
self.bump('successfulMetaObjectCall')
|
||||
return res.pointer()
|
||||
except:
|
||||
self.bump('failedMetaObjectCall')
|
||||
#warn('COULD NOT EXECUTE: %s' % cmd)
|
||||
return 0
|
||||
|
||||
def extractMetaObjectPtr(self, objectPtr, typeobj):
|
||||
""" objectPtr - address of *potential* instance of QObject derived class
|
||||
typeobj - type of *objectPtr if known, None otherwise. """
|
||||
@@ -1845,8 +1861,21 @@ class DumperBase:
|
||||
if qobject:
|
||||
# LLDB doesn't like calling it on a derived class, possibly
|
||||
# due to type information living in a different shared object.
|
||||
base = self.createValue(qobjectPtr, '@QObject')
|
||||
self.putCallItem(name, '@QVariant', base, 'property', '"' + name + '"')
|
||||
#base = self.createValue(qobjectPtr, '@QObject')
|
||||
#warn("CALL FUNC: 0x%x" % self.qtPropertyFunc)
|
||||
cmd = '((QVariant(*)(void*,char*))0x%x)((void*)0x%x,"%s")' \
|
||||
% (self.qtPropertyFunc, qobjectPtr, name)
|
||||
try:
|
||||
#warn('PROP CMD: %s' % cmd)
|
||||
res = self.parseAndEvaluate(cmd)
|
||||
#warn('PROP RES: %s' % res)
|
||||
except:
|
||||
self.bump('failedMetaObjectCall')
|
||||
putt(name, ' ')
|
||||
continue
|
||||
#warn('COULD NOT EXECUTE: %s' % cmd)
|
||||
#self.putCallItem(name, '@QVariant', base, 'property', '"' + name + '"')
|
||||
self.putSubItem(name, res)
|
||||
else:
|
||||
putt(name, ' ')
|
||||
|
||||
|
@@ -1010,6 +1010,12 @@ class Dumper(DumperBase):
|
||||
self.ping('qtNamespace')
|
||||
return res
|
||||
|
||||
def findSymbol(self, symbolName):
|
||||
try:
|
||||
return toInteger(gdb.parse_and_eval('(size_t)&%s' % symbolName))
|
||||
except:
|
||||
return 0
|
||||
|
||||
def qtNamespaceX(self):
|
||||
if not self.currentQtNamespaceGuess is None:
|
||||
return self.currentQtNamespaceGuess
|
||||
@@ -1039,16 +1045,17 @@ class Dumper(DumperBase):
|
||||
except:
|
||||
pass
|
||||
|
||||
try:
|
||||
lenns = len(ns)
|
||||
if lenns:
|
||||
sym = '_ZN%d%s7QObject11customEventEPNS_6QEventE' % \
|
||||
(lenns - 2, ns[:lenns - 2])
|
||||
else:
|
||||
sym = '_ZN7QObject11customEventEP6QEvent'
|
||||
self.qtCustomEventFunc = toInteger(gdb.parse_and_eval('(size_t)&%s' % sym))
|
||||
except:
|
||||
pass
|
||||
lenns = len(ns)
|
||||
strns = ('%d%s' % (lenns - 2, ns[:lenns - 2])) if lenns else ''
|
||||
|
||||
if lenns:
|
||||
sym = '_ZN%s7QObject11customEventEPNS_6QEventE' % strns
|
||||
else:
|
||||
sym = '_ZN7QObject11customEventEP6QEvent'
|
||||
self.qtCustomEventFunc = self.findSymbol(sym)
|
||||
|
||||
sym = '_ZNK7%sQObject8propertyEPKc' % strns
|
||||
self.qtPropertyFunc = self.findSymbol(sym)
|
||||
|
||||
# This might be wrong, but we can't do better: We found
|
||||
# a libQt5Core and could not extract a namespace.
|
||||
|
@@ -684,6 +684,10 @@ class Dumper(DumperBase):
|
||||
symbol = funcs[0].GetSymbol()
|
||||
self.qtCustomEventFunc = symbol.GetStartAddress().GetLoadAddress(self.target)
|
||||
|
||||
funcs = self.target.FindFunctions('QObject::property')
|
||||
if len(funcs):
|
||||
symbol = funcs[0].GetSymbol()
|
||||
self.qtPropertyFunc = symbol.GetStartAddress().GetLoadAddress(self.target)
|
||||
return (qtNamespace, qtVersion)
|
||||
|
||||
return ('', 0x50200)
|
||||
|
Reference in New Issue
Block a user