Commit 964d1212 authored by hjk's avatar hjk

Debugger: Make more dumper work without debug info

QRegExp, QHostInfo, QDir, QTextCursor

Change-Id: I2a368f8d294a235076491e4c50fc79039a2c9cff
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent afa66ab9
...@@ -1555,6 +1555,9 @@ class Dumper: ...@@ -1555,6 +1555,9 @@ class Dumper:
def ptrSize(self): def ptrSize(self):
return self.lookupType('void*').sizeof return self.lookupType('void*').sizeof
def is32bit(self):
return self.lookupType('void*').sizeof == 4
def createValue(self, address, referencedType): def createValue(self, address, referencedType):
return gdb.Value(address).cast(referencedType.pointer()).dereference() return gdb.Value(address).cast(referencedType.pointer()).dereference()
...@@ -1576,9 +1579,9 @@ class Dumper: ...@@ -1576,9 +1579,9 @@ class Dumper:
#if True: #if True:
vtable = self.dereference(long(value.address)) # + ptrSize vtable = self.dereference(long(value.address)) # + ptrSize
metaObjectEntry = self.dereference(vtable) # It's the first entry. metaObjectEntry = self.dereference(vtable) # It's the first entry.
warn("MO: 0x%x " % metaObjectEntry) #warn("MO: 0x%x " % metaObjectEntry)
s = gdb.execute("info symbol 0x%x" % metaObjectEntry, to_string=True) s = gdb.execute("info symbol 0x%x" % metaObjectEntry, to_string=True)
warn("S: %s " % s) #warn("S: %s " % s)
#return s.find("::metaObject() const") > 0 #return s.find("::metaObject() const") > 0
return s.find("::metaObject() const") > 0 or s.find("10metaObjectEv") > 0 return s.find("::metaObject() const") > 0 or s.find("10metaObjectEv") > 0
#return str(metaObjectEntry).find("::metaObject() const") > 0 #return str(metaObjectEntry).find("::metaObject() const") > 0
......
...@@ -398,7 +398,7 @@ def qdump__QTime(d, value): ...@@ -398,7 +398,7 @@ def qdump__QTime(d, value):
# This relies on the Qt4/Qt5 internal structure layout: # This relies on the Qt4/Qt5 internal structure layout:
# {sharedref(4), date(8), time(4+x)} # {sharedref(4), date(8), time(4+x)}
def qdump__QDateTime(d, value): def qdump__QDateTime(d, value):
base = d.dereferenceValue(value) base = d.dereference(d.addressOf(value))
# QDateTimePrivate: # QDateTimePrivate:
# - QAtomicInt ref; # - QAtomicInt ref;
# - [QDate date;] (+4) # - [QDate date;] (+4)
...@@ -434,31 +434,55 @@ def qdump__QDateTime(d, value): ...@@ -434,31 +434,55 @@ def qdump__QDateTime(d, value):
def qdump__QDir(d, value): def qdump__QDir(d, value):
d.putNumChild(1) d.putNumChild(1)
data = value["d_ptr"]["d"].dereference() privAddress = d.dereference(d.addressOf(value))
try: bit32 = d.is32bit()
# Up to Qt 4.7 qt5 = d.qtVersion() >= 0x050000
d.putStringValue(data["path"]) offset = (32 if bit32 else 40) if qt5 else 36
except: filePathAddress = privAddress + offset
# Qt 4.8 and later. #try:
d.putStringValue(data["dirEntry"]["m_filePath"]) # # Up to Qt 4.7
# d.putStringValue(data["path"])
#except:
# # Qt 4.8 and later.
# d.putStringValue(data["dirEntry"]["m_filePath"])
d.putStringValue(d.dereference(filePathAddress))
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
qdir = d.ns + "QDir::" call(value, "count") # Fill cache.
d.putCallItem("absolutePath", value, "absolutePath") #data = value["d_ptr"]["d"].dereference()
d.putCallItem("canonicalPath", value, "canonicalPath") #qdir = d.ns + "QDir::"
d.putSubItem("entryList", data["files"]) #d.putCallItem("absolutePath", value, "absolutePath")
d.putSubItem("entryInfoList", data["fileInfos"]) #d.putCallItem("canonicalPath", value, "canonicalPath")
with SubItem(d, "absolutePath"):
# d_ptr.d.priv.absoluteDirEntry.m_filePath
offset = (48 if bit32 else 60) if qt5 else 36
typ = d.lookupType(d.ns + "QString")
d.putItem(d.createValue(privAddress + offset, typ))
with SubItem(d, "entryInfoList"):
# d_ptr.d.priv.fileInfos
offset = (28 if bit32 else 32) if qt5 else 32
typ = d.lookupType(d.ns + "QFileInfoList")
d.putItem(d.createValue(privAddress + offset, typ))
with SubItem(d, "entryList"):
# d.ptr.d.priv.files
offset = 24 if qt5 else 28
typ = d.lookupType(d.ns + "QStringList")
d.putItem(d.createValue(privAddress + offset, typ))
#d.putSubItem("entryList", data["files"])
#d.putSubItem("entryInfoList", data["fileInfos"])
def qdump__QFile(d, value): def qdump__QFile(d, value):
try: try:
ptype = d.lookupType(d.ns + "QFilePrivate").pointer() ptype = d.lookupType(d.ns + "QFilePrivate").pointer()
d_ptr = value["d_ptr"]["d"] d_ptr = value["d_ptr"]["d"]
d.putStringValue(d_ptr.cast(ptype).dereference()["fileName"]) fileNameAddress = d.addressOf(d_ptr.cast(ptype).dereference()["fileName"])
d.putNumChild(1)
except: except:
d.putPlainChildren(value) privAddress = d.dereference(d.addressOf(value) + d.ptrSize())
return fileNameAddress = privAddress + 176 # Qt 5, 32 bit
d.putNumChild(1) d.putNumChild(0)
d.putStringValue(d.dereference(fileNameAddress))
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
base = fieldAt(value.type, 0).type base = fieldAt(value.type, 0).type
...@@ -467,11 +491,16 @@ def qdump__QFile(d, value): ...@@ -467,11 +491,16 @@ def qdump__QFile(d, value):
def qdump__QFileInfo(d, value): def qdump__QFileInfo(d, value):
try: privAddress = d.dereference(d.addressOf(value))
d.putStringValue(value["d_ptr"]["d"].dereference()["fileNames"][3]) #bit32 = d.is32bit()
except: #qt5 = d.qtVersion() >= 0x050000
d.putPlainChildren(value) #try:
return # d.putStringValue(value["d_ptr"]["d"].dereference()["fileNames"][3])
#except:
# d.putPlainChildren(value)
# return
filePathAddress = privAddress + d.ptrSize()
d.putStringValue(d.dereference(filePathAddress))
d.putNumChild(1) d.putNumChild(1)
if d.isExpanded(): if d.isExpanded():
with Children(d, childType=d.lookupType(d.ns + "QString")): with Children(d, childType=d.lookupType(d.ns + "QString")):
...@@ -696,11 +725,16 @@ def qdump__QHash__iterator(d, value): ...@@ -696,11 +725,16 @@ def qdump__QHash__iterator(d, value):
def qdump__QHostAddress(d, value): def qdump__QHostAddress(d, value):
data = value["d"]["d"].dereference() privAddress = d.dereference(d.addressOf(value))
if int(data["ipString"]["d"]["size"]): isQt5 = d.qtVersion() >= 0x050000
d.putStringValue(data["ipString"]) ipStringAddress = privAddress + (0 if isQt5 else 24)
# value["d"]["d"].dereference()["ipString"]
ipString = d.encodeString(d.dereference(ipStringAddress))
if len(ipString) > 0:
d.putValue(ipString, Hex4EncodedLittleEndian)
else: else:
a = int(data["a"]) # value["d"]["d"].dereference()["a"]
a = d.extractInt(privAddress + (2 * d.ptrSize() if isQt5 else 0))
a, n4 = divmod(a, 256) a, n4 = divmod(a, 256)
a, n3 = divmod(a, 256) a, n3 = divmod(a, 256)
a, n2 = divmod(a, 256) a, n2 = divmod(a, 256)
...@@ -709,7 +743,7 @@ def qdump__QHostAddress(d, value): ...@@ -709,7 +743,7 @@ def qdump__QHostAddress(d, value):
d.putNumChild(1) d.putNumChild(1)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
d.putFields(data) d.putFields(value["d"]["d"].dereference())
def qdump__QList(d, value): def qdump__QList(d, value):
dptr = childAt(value, 0)["d"] dptr = childAt(value, 0)["d"]
...@@ -1510,16 +1544,35 @@ def qdump__QRectF(d, value): ...@@ -1510,16 +1544,35 @@ def qdump__QRectF(d, value):
def qdump__QRegExp(d, value): def qdump__QRegExp(d, value):
d.putStringValue(value["priv"]["engineKey"]["pattern"]) # value["priv"]["engineKey"]["pattern"]
privAddress = d.dereference(d.addressOf(value))
engineKeyAddress = privAddress + d.ptrSize()
patternAddress = engineKeyAddress
d.putStringValue(d.dereference(patternAddress))
d.putNumChild(1) d.putNumChild(1)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
# FIXME: Remove need to call # QRegExpPrivate:
# - QRegExpEngine *eng (+0)
# - QRegExpEngineKey: (+1ptr)
# - QString pattern; (+1ptr)
# - QRegExp::PatternSyntax patternSyntax; (+2ptr)
# - Qt::CaseSensitivity cs; (+2ptr +1enum +pad?)
# - bool minimal (+2ptr +2enum +2pad?)
# - QString t (+2ptr +2enum +1bool +3pad?)
# - QStringList captures (+3ptr +2enum +1bool +3pad?)
# FIXME: Remove need to call. Needed to warm up cache.
call(value, "capturedTexts") # create cache call(value, "capturedTexts") # create cache
with SubItem(d, "syntax"): with SubItem(d, "syntax"):
d.putItem(value["priv"]["engineKey"]["patternSyntax"]) # value["priv"]["engineKey"["capturedCache"]
address = engineKeyAddress + d.ptrSize()
typ = d.lookupType(d.ns + "QRegExp::PatternSyntax")
d.putItem(d.createValue(address, typ))
with SubItem(d, "captures"): with SubItem(d, "captures"):
d.putItem(value["priv"]["capturedCache"]) # value["priv"]["capturedCache"]
address = privAddress + 3 * d.ptrSize() + 12
typ = d.lookupType(d.ns + "QStringList")
d.putItem(d.createValue(address, typ))
def qdump__QRegion(d, value): def qdump__QRegion(d, value):
...@@ -1724,23 +1777,20 @@ def qdump__QTextCodec(d, value): ...@@ -1724,23 +1777,20 @@ def qdump__QTextCodec(d, value):
def qdump__QTextCursor(d, value): def qdump__QTextCursor(d, value):
dd = value["d"]["d"] privAddress = d.dereference(d.addressOf(value))
if isNull(dd): if privAddress == 0:
d.putValue("(invalid)") d.putValue("(invalid)")
d.putNumChild(0) d.putNumChild(0)
else: else:
try: positionAddress = privAddress + 2 * d.ptrSize() + 8
p = dd.dereference() d.putValue(d.extractInt(positionAddress))
d.putValue(p["position"])
except:
d.putPlainChildren(value)
return
d.putNumChild(1) d.putNumChild(1)
if d.isExpanded(): if d.isExpanded():
with Children(d): with Children(d):
d.putIntItem("position", p["position"]) positionAddress = privAddress + 2 * d.ptrSize() + 8
d.putIntItem("anchor", p["anchor"]) d.putIntItem("position", d.extractInt(positionAddress))
d.putCallItem("selected", value, "selectedText") d.putIntItem("anchor", d.extractInt(positionAddress + intSize))
d.putCallItem("selected", value, "selectedText")
def qdump__QTextDocument(d, value): def qdump__QTextDocument(d, value):
...@@ -1770,7 +1820,7 @@ def qdump__QUrl(d, value): ...@@ -1770,7 +1820,7 @@ def qdump__QUrl(d, value):
# - QString path; # - QString path;
# - QString query; # - QString query;
# - QString fragment; # - QString fragment;
schemeAddr = d.dereferenceValue(value) + 2 * d.intSize() schemeAddr = d.dereference(d.addressOf(value)) + 2 * d.intSize()
scheme = d.dereference(schemeAddr) scheme = d.dereference(schemeAddr)
host = d.dereference(schemeAddr + 3 * d.ptrSize()) host = d.dereference(schemeAddr + 3 * d.ptrSize())
path = d.dereference(schemeAddr + 4 * d.ptrSize()) path = d.dereference(schemeAddr + 4 * d.ptrSize())
......
...@@ -1147,8 +1147,8 @@ void tst_Dumpers::dumper_data() ...@@ -1147,8 +1147,8 @@ void tst_Dumpers::dumper_data()
"unused(&dir, &s);\n") "unused(&dir, &s);\n")
% CoreProfile() % CoreProfile()
% Check("dir", tempDir, "@QDir") % Check("dir", tempDir, "@QDir")
% Check("dir.absolutePath", tempDir, "@QString") % Check("dir.absolutePath", tempDir, "@QString");
% Check("dir.canonicalPath", tempDir, "@QString"); // % Check("dir.canonicalPath", tempDir, "@QString");
QTest::newRow("QFileInfo") QTest::newRow("QFileInfo")
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
......
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