aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/python
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2016-12-14 15:17:57 +0000
committerJonathan Wakely <redi@gcc.gnu.org>2016-12-14 15:17:57 +0000
commit3c760f4a79c221408122b3f265a8039b04ce697e (patch)
tree20800d1ea3a325b165b20be26c3762f54fabd9ee /libstdc++-v3/python
parent54601417cebb474d8b941ccf4e0502624500a11c (diff)
downloadgcc-3c760f4a79c221408122b3f265a8039b04ce697e.zip
gcc-3c760f4a79c221408122b3f265a8039b04ce697e.tar.gz
gcc-3c760f4a79c221408122b3f265a8039b04ce697e.tar.bz2
Make printers detect invalid debug mode iterators
PR libstdc++/59170 * python/libstdcxx/v6/printers.py (StdDebugIteratorPrinter): Use _M_sequence and _M_version to detect invalid iterators. * testsuite/libstdc++-prettyprinters/debug.cc: Test debug mode vector and test invalid iterators. * testsuite/libstdc++-prettyprinters/debug_cxx11.cc: New test. From-SVN: r243650
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index ff428e8..8ac4a37 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -501,6 +501,10 @@ class StdDebugIteratorPrinter:
# Just strip away the encapsulating __gnu_debug::_Safe_iterator
# and return the wrapped iterator value.
def to_string (self):
+ base_type = gdb.lookup_type('__gnu_debug::_Safe_iterator_base')
+ safe_seq = self.val.cast(base_type)['_M_sequence']
+ if not safe_seq or self.val['_M_version'] != safe_seq['_M_version']:
+ return "invalid iterator"
itype = self.val.type.template_argument(0)
return self.val.cast(itype)
@@ -1507,8 +1511,8 @@ def build_libstdcxx_dictionary ():
Tr1UnorderedSetPrinter)
# These are the C++11 printer registrations for -D_GLIBCXX_DEBUG cases.
- # The tr1 namespace printers do not seem to have any debug
- # equivalents, so do no register them.
+ # The tr1 namespace containers do not have any debug equivalents,
+ # so do not register printers for them.
libstdcxx_printer.add('std::__debug::unordered_map',
Tr1UnorderedMapPrinter)
libstdcxx_printer.add('std::__debug::unordered_set',