GDB: Handle 'pretty_printer.to_string()' returning None

The documentation for the GDB pretty printer function
'pretty_printer.to_string' says [1]:

> [...]
> Finally, if this method returns None then no further
> operations are peformed in this method and nothing is printed.
> [...]

Therefore, skip this part if the printer's 'to_string' method returns
'None' and only fall back to assuming LazyString otherwise.

This e.g. fixes the std::pair pretty printer (for gcc-9 libstdc++6) for
which "<not accessible>" was shown previously in the debugger's
locals/expression view. Now it shows the object's address and allows
expansion to see the values for the 'first' and 'second' members.

[1] https://sourceware.org/gdb/onlinedocs/gdb/Pretty-Printing-API.html

Change-Id: I33b1af82f731c347314af76c533b096b8a5afe21
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Michael Weghorn
2019-10-13 01:53:57 +02:00
parent c7cb7672f0
commit e2e96cab52

View File

@@ -145,7 +145,7 @@ class PlainDumper:
d.putValue(d.hexencode(val), 'utf8:1:0') d.putValue(d.hexencode(val), 'utf8:1:0')
elif sys.version_info[0] <= 2 and isinstance(val, unicode): elif sys.version_info[0] <= 2 and isinstance(val, unicode):
d.putValue(val) d.putValue(val)
else: # Assuming LazyString elif val is not None: # Assuming LazyString
d.putCharArrayValue(val.address, val.length, d.putCharArrayValue(val.address, val.length,
val.type.target().sizeof) val.type.target().sizeof)