libstdc++: Fix num_children of the map pretty-printers
StdMapPrinter and Tr1UnorderedMapPrinter yield a separate child for the
key and for the value of every element, as their 'map' display hint
requires, but their num_children methods return the number of elements,
i.e. half of what children() produces.
GDB counts the children itself where it does not use num_children, so
the two disagree about the same map. For a std::map with 2 elements:
(gdb) interpreter-exec mi "-enable-pretty-printing"
(gdb) interpreter-exec mi "-var-create v * m"
(gdb) interpreter-exec mi "-var-list-children v"
^done,numchild="4",displayhint="map",children=[...]
while num_children() returns 2. The DAP code in gdb treats the two as
interchangeable: gdb/python/lib/gdb/dap/varref.py calls num_children()
when the printer has one, and falls back to len(list(children())) when
it does not, so a DAP client sees half the children of a std::map,
std::multimap or std::unordered_map.
StdSetPrinter and the sequence container printers yield one child per
element, so they are correct as they are.
libstdc++-v3/ChangeLog
* python/libstdcxx/v6/printers.py (StdMapPrinter.num_children):
Count two children per element.
(Tr1UnorderedMapPrinter.num_children): Likewise.
Signed-off-by: David Faure <david.faure@kdab.com>
Reviewed-by: Tom Tromey <tromey@adacore.com>
1 file changed