forked from qt-creator/qt-creator
Debugger: Fix custom GDB pretty printers
A GDB pretty printer's to_string method can return a plain string as well as a Value object. We did not account for the latter. Fixes: QTCREATORBUG-32480 Change-Id: I3429c30a022a1c810e677a567e2d2aba59c22a79 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -135,9 +135,12 @@ class PlainDumper():
|
||||
if isinstance(val, str):
|
||||
# encode and avoid extra quotes ('"') at beginning and end
|
||||
d.putValue(d.hexencode(val), 'utf8:1:0')
|
||||
elif val is not None: # Assuming LazyString
|
||||
d.putCharArrayValue(val.address, val.length,
|
||||
val.type.target().sizeof)
|
||||
# It might as well be just another gdb.Value, see
|
||||
# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Pretty-Printing-API.html#:~:text=Function%3A%20pretty_printer.to_string%20(self)
|
||||
elif isinstance(val, gdb.Value):
|
||||
d.putItem(d.fromNativeValue(val))
|
||||
else:
|
||||
return
|
||||
|
||||
lister = getattr(printer, 'children', None)
|
||||
if lister is None:
|
||||
@@ -1041,7 +1044,8 @@ class Dumper(DumperBase):
|
||||
for printer in printers.subprinters:
|
||||
self.importPlainDumper(printer)
|
||||
else:
|
||||
self.warn('Loading a printer without the subprinters attribute not supported.')
|
||||
self.warn("Failed to load printer '{}': loading printers without "
|
||||
"the subprinters attribute not supported.".format(printers.name))
|
||||
|
||||
def importPlainDumpers(self):
|
||||
for obj in gdb.objfiles():
|
||||
|
Reference in New Issue
Block a user