Commit 103d0e64 authored by hjk's avatar hjk

Debugger: Add a more generic way to distinguish Qt 4 and 5 in dumpers

Change-Id: I1f020032984fb61554b75cc404784d39d9464890
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 7cb5e83d
......@@ -358,6 +358,9 @@ qqDumpers = {}
# This is a cache of all dumpers that support writing.
qqEditable = {}
# This is an approximation of the Qt Version found
qqVersion = None
def registerDumper(function):
global qqDumpers, qqFormats, qqEditable
try:
......@@ -1134,7 +1137,7 @@ def qtNamespace():
if not qqNs is None:
return qqNs
try:
str = catchCliOutput("ptype QString::Null")[0]
str = gdb.execute("ptype QString::Null", to_string=True)
# The result looks like:
# "type = const struct myns::QString::Null {"
# " <no data fields>"
......@@ -1559,6 +1562,18 @@ class Dumper:
return xrange(0, self.currentNumChild)
return xrange(min(self.currentMaxNumChild, self.currentNumChild))
def qtVersion(self):
global qqVersion
if not qqVersion is None:
return qqVersion
try:
# This will fail on Qt 5
gdb.execute("ptype QString::shared_empty", to_string=True)
qqVersion = 0x040800
except:
qqVersion = 0x050000
return qqVersion
# Convenience function.
def putItemCount(self, count, maximum = 1000000000):
# This needs to override the default value, so don't use 'put' directly.
......
......@@ -609,6 +609,9 @@ class Dumper:
inner = self.extractTemplateArgument(typeobj.GetName(), index)
return int(inner)
def qtVersion(self):
return 0x050000
def intType(self):
if self.intType_ is None:
self.intType_ = self.target.FindFirstType('int')
......
......@@ -713,7 +713,8 @@ def qform__QImage():
def qdump__QImage(d, value):
# This relies on current QImage layout
intPtrType = d.lookupType("int").pointer()
base = createReferenceValue(value, d.addressOf(value) + 3 * intPtrType.sizeof, intPtrType)
offset = (3 if d.qtVersion() >= 0x050000 else 2) * intPtrType.sizeof
base = createReferenceValue(value, d.addressOf(value) + offset, intPtrType)
width = int(base[1])
height = int(base[2])
d.putValue("(%dx%d)" % (width, height))
......
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