forked from qt-creator/qt-creator
Make pretty-printing GDB's LazyString work
Qt Creator failed to properly display GDB's LazyString. The problem was that GDB's 'PlainDumper::__call__' passed a 'gdb.Type', while 'DumperBase::putCharArrayHelper' called methods that are only defined for the custom and more abstract 'Type' type defined in 'dumper.py'. As described at [1], GDB's 'LazyString.type' "holds the type that is represented by the lazy string’s type. For a lazy string this is a pointer or array type. To resolve this to the lazy string’s character type, use the type’s target method." In addition, 'gdb.Type' does not have a 'size()' method, just a 'sizeof' member, s. [2]. Since all other uses of 'DumperBase::putCharArrayHelper' are passed a "proper" type, extract the code common to the GDB case and all others into a separate method and directly call this one for the GDB LazyString case. [1] https://sourceware.org/gdb/onlinedocs/gdb/Lazy-Strings-In-Python.html#Lazy-Strings-In-Python [2] https://sourceware.org/gdb/onlinedocs/gdb/Types-In-Python.html#Types-In-Python Task-number: QTCREATORBUG-20939 Change-Id: I16608668c9403b6d8e509dab17eb1788586f453e Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -145,7 +145,8 @@ class PlainDumper:
|
||||
elif sys.version_info[0] <= 2 and isinstance(val, unicode):
|
||||
d.putValue(val)
|
||||
else: # Assuming LazyString
|
||||
d.putCharArrayHelper(val.address, val.length, val.type)
|
||||
d.putCharArrayValue(val.address, val.length,
|
||||
val.type.target().sizeof)
|
||||
|
||||
d.putNumChild(len(children))
|
||||
if d.isExpanded():
|
||||
|
||||
Reference in New Issue
Block a user