Commit de124ff
committed
Add 'num_children' method to relevant pretty-printers
A user pointed out that, in DAP mode, gdb would hang while trying to
display a certain vector. See
https://sourceware.org/bugzilla/show_bug.cgi?id=33594
This is caused by a combination of things: the vector is
uninitialized, DAP requires a count of the number of children of a
variable, and libstdc++ printers don't implement the 'num_children'
method, so gdb tries to count children by iterating.
In this case, the vector has a nonsensical size:
(gdb) p myVector
$1 = std::vector of length -34979931, capacity -33992726
This patch adds a 'num_children' method to a subset of the
pretty-printers, in particular ones where I thought the length might
be arbitrarily large and susceptible to being garbage when the object
isn't initialized.
I've also specifically added a check to the vector printer for the
case where the length is negative.
These container printers could be further improved by adding the
'child' method, allowing random access to child objects. However I
haven't done that here.
libstdc++-v3/ChangeLog
* python/libstdcxx/v6/printers.py (StdVectorPrinter._bounds):
New method.
(StdVectorPrinter.to_string): Use it.
(StdVectorPrinter.num_children): New method.
(StdStackOrQueuePrinter.num_children): New method.
(StdMapPrinter.num_children): New method.
(StdSetPrinter.num_children): New method.
(StdDequePrinter._size): New method.
(StdDequePrinter.to_string): Use it.
(StdDequePrinter.num_children): New method.
(Tr1UnorderedSetPrinter.num_children): New method.
(Tr1UnorderedMapPrinter.num_children): New method.
(StdSpanPrinter.num_children): New method.1 parent f94a73e commit de124ff
1 file changed
+52
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
572 | 572 | | |
573 | 573 | | |
574 | 574 | | |
575 | | - | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
576 | 579 | | |
577 | 580 | | |
578 | 581 | | |
| |||
582 | 585 | | |
583 | 586 | | |
584 | 587 | | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
589 | 591 | | |
590 | | - | |
591 | | - | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
592 | 609 | | |
593 | 610 | | |
594 | 611 | | |
| |||
733 | 750 | | |
734 | 751 | | |
735 | 752 | | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
736 | 758 | | |
737 | 759 | | |
738 | 760 | | |
| |||
876 | 898 | | |
877 | 899 | | |
878 | 900 | | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
879 | 904 | | |
880 | 905 | | |
881 | 906 | | |
| |||
915 | 940 | | |
916 | 941 | | |
917 | 942 | | |
| 943 | + | |
| 944 | + | |
918 | 945 | | |
919 | 946 | | |
920 | 947 | | |
| |||
1006 | 1033 | | |
1007 | 1034 | | |
1008 | 1035 | | |
1009 | | - | |
| 1036 | + | |
| 1037 | + | |
1010 | 1038 | | |
1011 | 1039 | | |
1012 | 1040 | | |
1013 | 1041 | | |
1014 | 1042 | | |
1015 | 1043 | | |
1016 | 1044 | | |
1017 | | - | |
| 1045 | + | |
1018 | 1046 | | |
1019 | | - | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1020 | 1050 | | |
1021 | 1051 | | |
1022 | 1052 | | |
1023 | 1053 | | |
1024 | 1054 | | |
1025 | 1055 | | |
1026 | 1056 | | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1027 | 1060 | | |
1028 | 1061 | | |
1029 | 1062 | | |
| |||
1210 | 1243 | | |
1211 | 1244 | | |
1212 | 1245 | | |
| 1246 | + | |
| 1247 | + | |
| 1248 | + | |
1213 | 1249 | | |
1214 | 1250 | | |
1215 | 1251 | | |
| |||
1254 | 1290 | | |
1255 | 1291 | | |
1256 | 1292 | | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
1257 | 1296 | | |
1258 | 1297 | | |
1259 | 1298 | | |
| |||
1949 | 1988 | | |
1950 | 1989 | | |
1951 | 1990 | | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
1952 | 1994 | | |
1953 | 1995 | | |
1954 | 1996 | | |
| |||
0 commit comments