Debugger: Fix QObject detection on Windows

Change-Id: I054161dfde0c03167a6d57861b069c403330e746
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2017-03-14 07:36:33 +01:00
parent ae63f89f35
commit 33e8f2e099
2 changed files with 38 additions and 23 deletions
-22
View File
@@ -318,28 +318,6 @@ class Dumper(DumperBase):
% (self.qtCoreModuleName(), namespace))
return namespace
def couldBeQObjectVTable(self, vtablePtr):
try:
customEventFunc = self.extractPointer(vtablePtr + 8 * self.ptrSize())
except:
self.bump('nostruct-3')
return False
if customEventFunc in (self.qtCustomEventFunc, self.qtCustomEventPltFunc):
return True
try:
delta = int.from_bytes(self.readRawMemory(customEventFunc + 1, 4), byteorder='little')
if (customEventFunc + 5 + delta) in (self.qtCustomEventFunc, self.qtCustomEventPltFunc):
return True
except:
pass
try:
return 'QObject::customEvent' in cdbext.getNameByAddress(customEventFunc)
except:
return False
def qtVersion(self):
qtVersion = self.findValueByExpression('((void**)&%s)[2]' % self.qtHookDataSymbolName())
if qtVersion is None and self.qtCoreModuleName() is not None:
+38 -1
View File
@@ -1494,12 +1494,49 @@ class DumperBase:
return self.couldBeQObjectVTable(vtablePtr)
def couldBeQObjectVTable(self, vtablePtr):
def getJumpAddress_x86(dumper, address):
relativeJumpCode = 0xe9
jumpCode = 0xff
data = dumper.readRawMemory(address, 6)
primaryOpcode = data[0]
if primaryOpcode == relativeJumpCode:
# relative jump on 32 and 64 bit with a 32bit offset
offset = int.from_bytes(data[1:5], byteorder='little')
return address + 5 + offset
if primaryOpcode == jumpCode:
if data[1] != 0x25: # check for known extended opcode
return 0
# 0xff25 is a relative jump on 64bit and an absolute jump on 32 bit
if self.ptrSize() == 8:
offset = int.from_bytes(data[2:6], byteorder='little')
return address + 6 + offset
else:
return int.from_bytes(data[2:6], byteorder='little')
return 0
# Do not try to extract a function pointer if there are no values to compare with
if self.qtCustomEventFunc == 0 and self.qtCustomEventPltFunc == 0:
return False
try:
customEventFunc = self.extractPointer(vtablePtr + 9 * self.ptrSize())
customEventOffset = 8 if self.isMsvcTarget() else 9
customEventFunc = self.extractPointer(vtablePtr + customEventOffset * self.ptrSize())
except:
self.bump('nostruct-3')
return False
if self.isWindowsTarget():
if customEventFunc in (self.qtCustomEventFunc, self.qtCustomEventPltFunc):
return True
# The vtable may point to a function that is just calling the customEvent function
customEventFunc = getJumpAddress_x86(self, customEventFunc)
if customEventFunc in (self.qtCustomEventFunc, self.qtCustomEventPltFunc):
return True
customEventFunc = self.extractPointer(customEventFunc)
if customEventFunc in (self.qtCustomEventFunc, self.qtCustomEventPltFunc):
return True
# If the object is defined in another module there may be another level of indirection
customEventFunc = getJumpAddress_x86(self, customEventFunc)
return customEventFunc in (self.qtCustomEventFunc, self.qtCustomEventPltFunc)
# def extractQObjectProperty(objectPtr):