I’m trying to figure out how to write a GDB pretty print plugin (similar to the ones KDE provides for standard Qt types like QString and QList/QMap/etc. [1]), but for debugging values found with coredumps (no access to “live” instances will be possible, so cannot try to dynamically evaluate anything) to try to figure out why the QML engine randomly crashed.
My to_string()
method (within a class based off the QStringPrinter) currently looks something like:
def to_string(self):
ret = ""
# Use m() instead of d(). See d_unchecked() in V4_MANAGED_ITSELF, which calls m()
# --> m() function in qv4value_p.h subsequently copies 8bit pointer value out of Value._val
# Err... does this result ina pointer read?
managedM = self.val['_val']
# XXX: Not sure if this is right, but am trying to access the "text" pointer (QStringData) that should live in QV4::Heap::StringOrSymbol, which this thing should be (???)
managedStringOrSymbol = managedM['text']
# TODO: need to find way to skip the arrays fixed size header
# Try to cast the QTypedArrayData / QArrayData to a char* array we can print
textDataAsCharPointer = managedStringOrSymbol.cast(gdb.lookup_type('char')).pointer()
# XXX: not sure if is utf16. Only know it uses ushort's per character?
ret = textDataAsCharPointer.string(encoding = 'UTF-16', length = size * 2)
return ret
[1] GDB pretty printers for Qt5