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):
|
if isinstance(val, str):
|
||||||
# encode and avoid extra quotes ('"') at beginning and end
|
# encode and avoid extra quotes ('"') at beginning and end
|
||||||
d.putValue(d.hexencode(val), 'utf8:1:0')
|
d.putValue(d.hexencode(val), 'utf8:1:0')
|
||||||
elif val is not None: # Assuming LazyString
|
# It might as well be just another gdb.Value, see
|
||||||
d.putCharArrayValue(val.address, val.length,
|
# https://sourceware.org/gdb/current/onlinedocs/gdb.html/Pretty-Printing-API.html#:~:text=Function%3A%20pretty_printer.to_string%20(self)
|
||||||
val.type.target().sizeof)
|
elif isinstance(val, gdb.Value):
|
||||||
|
d.putItem(d.fromNativeValue(val))
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
lister = getattr(printer, 'children', None)
|
lister = getattr(printer, 'children', None)
|
||||||
if lister is None:
|
if lister is None:
|
||||||
@@ -1041,7 +1044,8 @@ class Dumper(DumperBase):
|
|||||||
for printer in printers.subprinters:
|
for printer in printers.subprinters:
|
||||||
self.importPlainDumper(printer)
|
self.importPlainDumper(printer)
|
||||||
else:
|
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):
|
def importPlainDumpers(self):
|
||||||
for obj in gdb.objfiles():
|
for obj in gdb.objfiles():
|
||||||
|
Reference in New Issue
Block a user