Have DAP handle non-Value results from 'children'

A pretty-printer's 'children' method may return values other than a
gdb.Value -- it may return any value that can be converted to a
gdb.Value.

I noticed that this case did not work for DAP.  This patch fixes the
problem.
This commit is contained in:
Tom Tromey
2023-10-06 07:42:00 -06:00
parent ee81567c7c
commit 41ab08f84b
3 changed files with 166 additions and 2 deletions

View File

@@ -199,9 +199,14 @@ class VariableReference(BaseReference):
if isinstance(self.printer, gdb.ValuePrinter) and hasattr(
self.printer, "child"
):
return self.printer.child(idx)
(name, val) = self.printer.child(idx)
else:
return self.cache_children()[idx]
(name, val) = self.cache_children()[idx]
# A pretty-printer can return something other than a
# gdb.Value, but it must be convertible.
if not isinstance(val, gdb.Value):
val = gdb.Value(val)
return (name, val)
@in_gdb_thread