2014-07-11 13:43:07 +00:00
|
|
|
# Pretty-printers for libstdc++.
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2020-01-01 12:51:42 +01:00
|
|
|
# Copyright (C) 2008-2020 Free Software Foundation, Inc.
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2010-07-02 10:55:51 +00:00
|
|
|
import gdb
|
2009-05-28 17:14:18 +00:00
|
|
|
import itertools
|
|
|
|
import re
|
2014-07-11 13:43:07 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
### Python 2 + Python 3 compatibility code
|
|
|
|
|
|
|
|
# Resources about compatibility:
|
|
|
|
#
|
|
|
|
# * <http://pythonhosted.org/six/>: Documentation of the "six" module
|
|
|
|
|
|
|
|
# FIXME: The handling of e.g. std::basic_string (at least on char)
|
|
|
|
# probably needs updating to work with Python 3's new string rules.
|
|
|
|
#
|
|
|
|
# In particular, Python 3 has a separate type (called byte) for
|
|
|
|
# bytestrings, and a special b"" syntax for the byte literals; the old
|
|
|
|
# str() type has been redefined to always store Unicode text.
|
|
|
|
#
|
|
|
|
# We probably can't do much about this until this GDB PR is addressed:
|
|
|
|
# <https://sourceware.org/bugzilla/show_bug.cgi?id=17138>
|
|
|
|
|
|
|
|
if sys.version_info[0] > 2:
|
|
|
|
### Python 3 stuff
|
|
|
|
Iterator = object
|
|
|
|
# Python 3 folds these into the normal functions.
|
|
|
|
imap = map
|
|
|
|
izip = zip
|
|
|
|
# Also, int subsumes long
|
|
|
|
long = int
|
|
|
|
else:
|
|
|
|
### Python 2 stuff
|
|
|
|
class Iterator:
|
|
|
|
"""Compatibility mixin for iterators
|
|
|
|
|
|
|
|
Instead of writing next() methods for iterators, write
|
|
|
|
__next__() methods and use this mixin to make them work in
|
|
|
|
Python 2 as well as Python 3.
|
|
|
|
|
|
|
|
Idea stolen from the "six" documentation:
|
|
|
|
<http://pythonhosted.org/six/#six.Iterator>
|
|
|
|
"""
|
|
|
|
|
|
|
|
def next(self):
|
|
|
|
return self.__next__()
|
|
|
|
|
|
|
|
# In Python 2, we still need these from itertools
|
|
|
|
from itertools import imap, izip
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
# Try to use the new-style pretty-printing if available.
|
|
|
|
_use_gdb_pp = True
|
|
|
|
try:
|
|
|
|
import gdb.printing
|
|
|
|
except ImportError:
|
|
|
|
_use_gdb_pp = False
|
|
|
|
|
2012-11-16 18:17:25 +00:00
|
|
|
# Try to install type-printers.
|
|
|
|
_use_type_printing = False
|
|
|
|
try:
|
|
|
|
import gdb.types
|
|
|
|
if hasattr(gdb.types, 'TypePrinter'):
|
|
|
|
_use_type_printing = True
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
2012-01-30 16:25:11 +00:00
|
|
|
# Starting with the type ORIG, search for the member type NAME. This
|
|
|
|
# handles searching upward through superclasses. This is needed to
|
|
|
|
# work around http://sourceware.org/bugzilla/show_bug.cgi?id=13615.
|
|
|
|
def find_type(orig, name):
|
|
|
|
typ = orig.strip_typedefs()
|
|
|
|
while True:
|
2017-03-16 14:11:48 +00:00
|
|
|
# Strip cv-qualifiers. PR 67440.
|
|
|
|
search = '%s::%s' % (typ.unqualified(), name)
|
2012-01-30 16:25:11 +00:00
|
|
|
try:
|
|
|
|
return gdb.lookup_type(search)
|
|
|
|
except RuntimeError:
|
|
|
|
pass
|
|
|
|
# The type was not found, so try the superclass. We only need
|
|
|
|
# to check the first superclass, so we don't bother with
|
|
|
|
# anything fancier here.
|
2019-11-29 14:47:03 +00:00
|
|
|
fields = typ.fields()
|
|
|
|
if len(fields) and fields[0].is_base_class:
|
|
|
|
typ = fields[0].type
|
|
|
|
else:
|
2014-05-19 22:43:13 +01:00
|
|
|
raise ValueError("Cannot find type %s::%s" % (str(orig), name))
|
2012-01-30 16:25:11 +00:00
|
|
|
|
2017-05-10 20:40:28 +00:00
|
|
|
_versioned_namespace = '__8::'
|
2017-01-10 12:38:42 +00:00
|
|
|
|
2019-11-29 14:47:03 +00:00
|
|
|
def lookup_templ_spec(templ, *args):
|
|
|
|
"""
|
|
|
|
Lookup template specialization templ<args...>
|
|
|
|
"""
|
|
|
|
t = '{}<{}>'.format(templ, ', '.join([str(a) for a in args]))
|
|
|
|
try:
|
|
|
|
return gdb.lookup_type(t)
|
|
|
|
except gdb.error as e:
|
|
|
|
# Type not found, try again in versioned namespace.
|
|
|
|
global _versioned_namespace
|
|
|
|
if _versioned_namespace and _versioned_namespace not in templ:
|
|
|
|
t = t.replace('::', '::' + _versioned_namespace, 1)
|
|
|
|
try:
|
|
|
|
return gdb.lookup_type(t)
|
|
|
|
except gdb.error:
|
|
|
|
# If that also fails, rethrow the original exception
|
|
|
|
pass
|
|
|
|
raise e
|
|
|
|
|
|
|
|
# Use this to find container node types instead of find_type,
|
|
|
|
# see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91997 for details.
|
|
|
|
def lookup_node_type(nodename, containertype):
|
|
|
|
"""
|
|
|
|
Lookup specialization of template NODENAME corresponding to CONTAINERTYPE.
|
|
|
|
e.g. if NODENAME is '_List_node' and CONTAINERTYPE is std::list<int>
|
|
|
|
then return the type std::_List_node<int>.
|
|
|
|
Returns None if not found.
|
|
|
|
"""
|
|
|
|
# If nodename is unqualified, assume it's in namespace std.
|
|
|
|
if '::' not in nodename:
|
|
|
|
nodename = 'std::' + nodename
|
|
|
|
try:
|
|
|
|
valtype = find_type(containertype, 'value_type')
|
|
|
|
except:
|
|
|
|
valtype = containertype.template_argument(0)
|
|
|
|
valtype = valtype.strip_typedefs()
|
|
|
|
try:
|
|
|
|
return lookup_templ_spec(nodename, valtype)
|
|
|
|
except gdb.error as e:
|
|
|
|
# For debug mode containers the node is in std::__cxx1998.
|
|
|
|
if is_member_of_namespace(nodename, 'std'):
|
|
|
|
if is_member_of_namespace(containertype, 'std::__cxx1998',
|
|
|
|
'std::__debug', '__gnu_debug'):
|
|
|
|
nodename = nodename.replace('::', '::__cxx1998::', 1)
|
|
|
|
try:
|
|
|
|
return lookup_templ_spec(nodename, valtype)
|
|
|
|
except gdb.error:
|
|
|
|
pass
|
|
|
|
return None
|
|
|
|
|
|
|
|
def is_member_of_namespace(typ, *namespaces):
|
|
|
|
"""
|
|
|
|
Test whether a type is a member of one of the specified namespaces.
|
|
|
|
The type can be specified as a string or a gdb.Type object.
|
|
|
|
"""
|
|
|
|
if type(typ) is gdb.Type:
|
|
|
|
typ = str(typ)
|
|
|
|
typ = strip_versioned_namespace(typ)
|
|
|
|
for namespace in namespaces:
|
|
|
|
if typ.startswith(namespace + '::'):
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
PR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment
PR libstdc++/86963
* include/std/tuple (__tuple_base): New class template with deleted
copy assignment operator.
(tuple, tuple<_T1, _T2>): Derive from __tuple_base<tuple> so that
implicit copy/move assignment operator will be deleted/suppressed.
(tuple::__assignable, tuple<_T1, _T2>::__assignable): New helper
functions for SFINAE constraints on assignment operators.
(tuple::__nothrow_assignable, tuple<_T1, _T2>::__nothrow_assignable):
New helper functions for exception specifications.
(tuple::operator=(const tuple&), tuple::operator=(tuple&&))
(tuple<_T1, _T2>::operator=(const tuple&))
(tuple<_T1, _T2>::operator=(tuple&&)): Change parameter types to
__nonesuch_no_braces when the operator should be defined implicitly.
Use __nothrow_assignable for exception specifications.
(tuple::operator=(const tuple<_UElements...>&))
(tuple::operator=(tuple<_UElements...>&&))
(tuple<_T1, _T2>::operator=(const tuple<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(tuple<_U1, _U2>&&))
(tuple<_T1, _T2>::operator=(const pair<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(pair<_U1, _U2>&&)): Constrain using
__assignable and use __nothrow_assignable for exception
specifications.
* python/libstdcxx/v6/printers.py (is_specialization_of): Accept
gdb.Type as first argument, instead of a string.
(StdTuplePrinter._iterator._is_nonempty_tuple): New method to check
tuple for expected structure.
(StdTuplePrinter._iterator.__init__): Use _is_nonempty_tuple.
* testsuite/20_util/tuple/dr2729.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Change dg-error
to dg-prune-output.
From-SVN: r263625
2018-08-17 18:52:49 +01:00
|
|
|
def is_specialization_of(x, template_name):
|
2018-01-15 11:13:53 +00:00
|
|
|
"Test if a type is a given template instantiation."
|
2017-01-10 12:38:42 +00:00
|
|
|
global _versioned_namespace
|
PR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment
PR libstdc++/86963
* include/std/tuple (__tuple_base): New class template with deleted
copy assignment operator.
(tuple, tuple<_T1, _T2>): Derive from __tuple_base<tuple> so that
implicit copy/move assignment operator will be deleted/suppressed.
(tuple::__assignable, tuple<_T1, _T2>::__assignable): New helper
functions for SFINAE constraints on assignment operators.
(tuple::__nothrow_assignable, tuple<_T1, _T2>::__nothrow_assignable):
New helper functions for exception specifications.
(tuple::operator=(const tuple&), tuple::operator=(tuple&&))
(tuple<_T1, _T2>::operator=(const tuple&))
(tuple<_T1, _T2>::operator=(tuple&&)): Change parameter types to
__nonesuch_no_braces when the operator should be defined implicitly.
Use __nothrow_assignable for exception specifications.
(tuple::operator=(const tuple<_UElements...>&))
(tuple::operator=(tuple<_UElements...>&&))
(tuple<_T1, _T2>::operator=(const tuple<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(tuple<_U1, _U2>&&))
(tuple<_T1, _T2>::operator=(const pair<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(pair<_U1, _U2>&&)): Constrain using
__assignable and use __nothrow_assignable for exception
specifications.
* python/libstdcxx/v6/printers.py (is_specialization_of): Accept
gdb.Type as first argument, instead of a string.
(StdTuplePrinter._iterator._is_nonempty_tuple): New method to check
tuple for expected structure.
(StdTuplePrinter._iterator.__init__): Use _is_nonempty_tuple.
* testsuite/20_util/tuple/dr2729.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Change dg-error
to dg-prune-output.
From-SVN: r263625
2018-08-17 18:52:49 +01:00
|
|
|
if type(x) is gdb.Type:
|
|
|
|
x = x.tag
|
2017-01-10 12:38:42 +00:00
|
|
|
if _versioned_namespace:
|
PR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment
PR libstdc++/86963
* include/std/tuple (__tuple_base): New class template with deleted
copy assignment operator.
(tuple, tuple<_T1, _T2>): Derive from __tuple_base<tuple> so that
implicit copy/move assignment operator will be deleted/suppressed.
(tuple::__assignable, tuple<_T1, _T2>::__assignable): New helper
functions for SFINAE constraints on assignment operators.
(tuple::__nothrow_assignable, tuple<_T1, _T2>::__nothrow_assignable):
New helper functions for exception specifications.
(tuple::operator=(const tuple&), tuple::operator=(tuple&&))
(tuple<_T1, _T2>::operator=(const tuple&))
(tuple<_T1, _T2>::operator=(tuple&&)): Change parameter types to
__nonesuch_no_braces when the operator should be defined implicitly.
Use __nothrow_assignable for exception specifications.
(tuple::operator=(const tuple<_UElements...>&))
(tuple::operator=(tuple<_UElements...>&&))
(tuple<_T1, _T2>::operator=(const tuple<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(tuple<_U1, _U2>&&))
(tuple<_T1, _T2>::operator=(const pair<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(pair<_U1, _U2>&&)): Constrain using
__assignable and use __nothrow_assignable for exception
specifications.
* python/libstdcxx/v6/printers.py (is_specialization_of): Accept
gdb.Type as first argument, instead of a string.
(StdTuplePrinter._iterator._is_nonempty_tuple): New method to check
tuple for expected structure.
(StdTuplePrinter._iterator.__init__): Use _is_nonempty_tuple.
* testsuite/20_util/tuple/dr2729.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Change dg-error
to dg-prune-output.
From-SVN: r263625
2018-08-17 18:52:49 +01:00
|
|
|
return re.match('^std::(%s)?%s<.*>$' % (_versioned_namespace, template_name), x) is not None
|
|
|
|
return re.match('^std::%s<.*>$' % template_name, x) is not None
|
2017-01-10 12:38:42 +00:00
|
|
|
|
|
|
|
def strip_versioned_namespace(typename):
|
|
|
|
global _versioned_namespace
|
|
|
|
if _versioned_namespace:
|
|
|
|
return typename.replace(_versioned_namespace, '')
|
|
|
|
return typename
|
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
def strip_inline_namespaces(type_str):
|
|
|
|
"Remove known inline namespaces from the canonical name of a type."
|
|
|
|
type_str = strip_versioned_namespace(type_str)
|
|
|
|
type_str = type_str.replace('std::__cxx11::', 'std::')
|
|
|
|
expt_ns = 'std::experimental::'
|
|
|
|
for lfts_ns in ('fundamentals_v1', 'fundamentals_v2'):
|
|
|
|
type_str = type_str.replace(expt_ns+lfts_ns+'::', expt_ns)
|
|
|
|
fs_ns = expt_ns + 'filesystem::'
|
|
|
|
type_str = type_str.replace(fs_ns+'v1::', fs_ns)
|
|
|
|
return type_str
|
|
|
|
|
|
|
|
def get_template_arg_list(type_obj):
|
|
|
|
"Return a type's template arguments as a list"
|
|
|
|
n = 0
|
|
|
|
template_args = []
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
template_args.append(type_obj.template_argument(n))
|
|
|
|
except:
|
|
|
|
return template_args
|
|
|
|
n += 1
|
|
|
|
|
2018-01-09 18:49:57 +00:00
|
|
|
class SmartPtrIterator(Iterator):
|
|
|
|
"An iterator for smart pointer types with a single 'child' value"
|
|
|
|
|
|
|
|
def __init__(self, val):
|
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __next__(self):
|
|
|
|
if self.val is None:
|
|
|
|
raise StopIteration
|
|
|
|
self.val, val = None, self.val
|
|
|
|
return ('get()', val)
|
|
|
|
|
2012-02-05 19:10:15 +00:00
|
|
|
class SharedPointerPrinter:
|
|
|
|
"Print a shared_ptr or weak_ptr"
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
2018-01-09 18:49:57 +00:00
|
|
|
self.pointer = val['_M_ptr']
|
|
|
|
|
|
|
|
def children (self):
|
|
|
|
return SmartPtrIterator(self.pointer)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def to_string (self):
|
2012-02-05 19:10:15 +00:00
|
|
|
state = 'empty'
|
|
|
|
refcounts = self.val['_M_refcount']['_M_pi']
|
|
|
|
if refcounts != 0:
|
|
|
|
usecount = refcounts['_M_use_count']
|
|
|
|
weakcount = refcounts['_M_weak_count']
|
|
|
|
if usecount == 0:
|
2018-01-09 18:49:57 +00:00
|
|
|
state = 'expired, weak count %d' % weakcount
|
2012-02-05 19:10:15 +00:00
|
|
|
else:
|
2018-01-09 18:49:57 +00:00
|
|
|
state = 'use count %d, weak count %d' % (usecount, weakcount - 1)
|
2018-01-09 21:46:13 +00:00
|
|
|
return '%s<%s> (%s)' % (self.typename, str(self.val.type.template_argument(0)), state)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
class UniquePointerPrinter:
|
|
|
|
"Print a unique_ptr"
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__ (self, typename, val):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
2018-01-09 18:49:57 +00:00
|
|
|
impl_type = val.type.fields()[0].type.tag
|
LWG 2899 - Make is_move_constructible correct for unique_ptr
* include/bits/unique_ptr.h (__uniq_ptr_impl): Add move constructor,
move assignment operator.
(__uniq_ptr_impl::release(), __uniq_ptr_impl::reset(pointer)): Add.
(__uniq_ptr_data): New class template with conditionally deleted
special members.
(unique_ptr, unique_ptr<T[], D>): Change type of data member from
__uniq_ptr_impl<T, D> to __uniq_ptr_data<T, D>. Define move
constructor and move assignment operator as defaulted.
(unique_ptr::release(), unique_ptr<T[], D>::release()): Forward to
__uniq_ptr_impl::release().
(unique_ptr::reset(pointer), unique_ptr<T[], D>::reset<U>(U)): Forward
to __uniq_ptr_impl::reset(pointer).
* python/libstdcxx/v6/printers.py (UniquePointerPrinter.__init__):
Check for new __uniq_ptr_data type.
* testsuite/20_util/unique_ptr/dr2899.cc: New test.
From-SVN: r271158
2019-05-14 12:17:11 +01:00
|
|
|
# Check for new implementations first:
|
|
|
|
if is_specialization_of(impl_type, '__uniq_ptr_data') \
|
|
|
|
or is_specialization_of(impl_type, '__uniq_ptr_impl'):
|
2019-05-14 12:17:18 +01:00
|
|
|
tuple_member = val['_M_t']['_M_t']
|
2017-01-10 12:38:42 +00:00
|
|
|
elif is_specialization_of(impl_type, 'tuple'):
|
2019-05-14 12:17:18 +01:00
|
|
|
tuple_member = val['_M_t']
|
2016-10-19 10:34:57 +01:00
|
|
|
else:
|
2018-01-09 18:49:57 +00:00
|
|
|
raise ValueError("Unsupported implementation for unique_ptr: %s" % impl_type)
|
2019-05-14 12:17:18 +01:00
|
|
|
tuple_impl_type = tuple_member.type.fields()[0].type # _Tuple_impl
|
|
|
|
tuple_head_type = tuple_impl_type.fields()[1].type # _Head_base
|
|
|
|
head_field = tuple_head_type.fields()[0]
|
|
|
|
if head_field.name == '_M_head_impl':
|
|
|
|
self.pointer = tuple_member['_M_head_impl']
|
|
|
|
elif head_field.is_base_class:
|
|
|
|
self.pointer = tuple_member.cast(head_field.type)
|
2019-05-18 00:08:00 +01:00
|
|
|
else:
|
|
|
|
raise ValueError("Unsupported implementation for tuple in unique_ptr: %s" % impl_type)
|
2018-01-09 18:49:57 +00:00
|
|
|
|
|
|
|
def children (self):
|
|
|
|
return SmartPtrIterator(self.pointer)
|
|
|
|
|
|
|
|
def to_string (self):
|
2018-01-09 21:46:13 +00:00
|
|
|
return ('std::unique_ptr<%s>' % (str(self.val.type.template_argument(0))))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
Implement C++17 node extraction and insertion (P0083R5)
* doc/xml/manual/status_cxx2017.xml: Document status.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/node_handle.h and reorder.
* include/Makefile.in: Regenerate.
* include/bits/hashtable.h (_Hashtable::node_type)
(_Hashtable::insert_return_type, _Hashtable::_M_reinsert_node)
(_Hashtable::_M_reinsert_node_multi, _Hashtable::extract)
(_Hashtable::_M_merge_unique, _Hashtable::_M_merge_multi): Define.
(_Hash_merge_helper): Define primary template.
* include/bits/node_handle.h: New header.
* include/bits/stl_map.h (map): Declare _Rb_tree_merge_helper as
friend.
(map::node_type, map::insert_return_type, map::extract, map::merge)
(map::insert(node_type&&), map::insert(const_iterator, node_type&&)):
Define new members.
(_Rb_tree_merge_helper): Specialize for map.
* include/bits/stl_multimap.h (multimap): Declare _Rb_tree_merge_helper
as friend.
(multimap::node_type, multimap::extract, multimap::merge)
(multimap::insert(node_type&&))
(multimap::insert(const_iterator, node_type&&)): Define.
(_Rb_tree_merge_helper): Specialize for multimap.
* include/bits/stl_multiset.h (multiset): Declare _Rb_tree_merge_helper
as friend.
(multiset::node_type, multiset::extract, multiset::merge)
(multiset::insert(node_type&&))
(multiset::insert(const_iterator, node_type&&)): Define.
* include/bits/stl_set.h (set): Declare _Rb_tree_merge_helper as
friend.
(set::node_type, set::insert_return_type, set::extract, set::merge)
(set::insert(node_type&&), set::insert(const_iterator, node_type&&)):
Define.
(_Rb_tree_merge_helper): Specialize for set.
* include/bits/stl_tree.h (_Rb_tree): Declare _Rb_tree<> as friend.
(_Rb_tree::node_type, _Rb_tree::insert_return_type)
(_Rb_tree::_M_reinsert_node_unique, _Rb_tree::_M_reinsert_node_equal)
(_Rb_tree::_M_reinsert_node_hint_unique)
(_Rb_tree::_M_reinsert_node_hint_equal, _Rb_tree::extract)
(_Rb_tree::_M_merge_unique, _Rb_tree::_M_merge_equal): Define.
(_Rb_tree_merge_helper): Specialize for multiset.
* include/bits/unordered_map.h (unordered_map): Declare
unordered_map<> and unordered_multimap<> as friends.
(unordered_map::node_type, unordered_map::insert_return_type)
(unordered_map::extract, unordered_map::merge)
(unordered_map::insert(node_type&&))
(unordered_map::insert(const_iterator, node_type&&))
(unordered_multimap): Declare _Hash_merge_helper as friend.
(unordered_multimap::node_type, unordered_multimap::extract)
(unordered_multimap::merge, unordered_multimap::insert(node_type&&))
(unordered_multimap::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered maps and multimaps.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Declare _Hash_merge_helper as friend.
(unordered_set::node_type, unordered_set::insert_return_type)
(unordered_set::extract, unordered_set::merge)
(unordered_set::insert(node_type&&))
(unordered_set::insert(const_iterator, node_type&&)): Define.
(unordered_multiset::node_type, unordered_multiset::extract)
(unordered_multiset::merge, unordered_multiset::insert(node_type&&))
(unordered_multiset::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered sets and multisets.
* include/debug/map.h (map): Add using declarations or forwarding
functions for new members.
* include/debug/map.h (multimap): Likewise.
* include/debug/map.h (multiset): Likewise.
* include/debug/map.h (set): Likewise.
* include/debug/unordered_map (unordered_map, unordered_multimap):
Likewise.
* include/debug/unordered_set( unordered_set, unordered_multiset):
Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_aligned_membuf): New
helper function.
(get_value_from_list_node, get_value_from_Rb_tree_node): Use helper.
(StdNodeHandlePrinter): Define printer for node handles.
(build_libstdcxx_dictionary): Register StdNodeHandlePrinter.
* testsuite/23_containers/map/modifiers/extract.cc: New.
* testsuite/23_containers/map/modifiers/merge.cc: New.
* testsuite/23_containers/multimap/modifiers/extract.cc: New.
* testsuite/23_containers/multimap/modifiers/merge.cc: New.
* testsuite/23_containers/multiset/modifiers/extract.cc: New.
* testsuite/23_containers/multiset/modifiers/merge.cc: New.
* testsuite/23_containers/set/modifiers/extract.cc: New.
* testsuite/23_containers/set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_map/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_map/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multimap/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multiset/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
dg-error lineno.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test node handles.
From-SVN: r240363
2016-09-22 14:58:49 +01:00
|
|
|
def get_value_from_aligned_membuf(buf, valtype):
|
|
|
|
"""Returns the value held in a __gnu_cxx::__aligned_membuf."""
|
|
|
|
return buf['_M_storage'].address.cast(valtype.pointer()).dereference()
|
|
|
|
|
C++11 allocator support for std::list.
PR libstdc++/55409
* include/bits/list.tcc (_List_base::_M_clear()): Use allocator traits.
(list::list(const list&)): Use allocator propagation trait. Use
_M_assign_dispatch to copy elements.
* include/bits/stl_list.h (_List_node): Use __aligned_membuf in C++11.
(_List_node::_M_valptr()): Add accessor for stored value.
(_List_iterator, _List_const_iterator, _List_base): Use _M_valptr().
(_List_base, list): Use allocator traits.
(_List_base::_M_get_Tp_allocator, _List_base::get_allocator): Remove.
(_List_base::_M_move_nodes): New function.
(_List_base(_List_base&&)): Use _M_move_nodes.
(_List_base(_List_base&&, _Node_alloc_type&&)): New constructor.
(list::_M_create_node, list::_M_erase, list::max_size): Use allocator
traits.
(list(size_type)): Add allocator parameter.
(list(const list&)): Use allocator propagation trait.
(list(const list&, const allocator_type&)): New constructor.
(list(list&&, const allocator_type&)): Likewise.
(list::operator=(list&&), list::swap(list&)): Use allocator
propagation traits.
(list::_M_move_assign): New functions.
* include/debug/list: Add allocator-extended constructors.
* include/profile/list: Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_list_node): New
function to get value from _List_node.
(StdListPrinter): Use get_value_from_list_node.
* testsuite/23_containers/list/allocator/copy.cc: New.
* testsuite/23_containers/list/allocator/copy_assign.cc: New.
* testsuite/23_containers/list/allocator/minimal.cc: New.
* testsuite/23_containers/list/allocator/move.cc: New.
* testsuite/23_containers/list/allocator/move_assign.cc: New.
* testsuite/23_containers/list/allocator/noexcept.cc: New.
* testsuite/23_containers/list/allocator/swap.cc: New.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-prune-output line number.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r224580
2015-06-17 21:36:42 +01:00
|
|
|
def get_value_from_list_node(node):
|
|
|
|
"""Returns the value held in an _List_node<_Val>"""
|
|
|
|
try:
|
|
|
|
member = node.type.fields()[1].name
|
|
|
|
if member == '_M_data':
|
|
|
|
# C++03 implementation, node contains the value as a member
|
|
|
|
return node['_M_data']
|
|
|
|
elif member == '_M_storage':
|
|
|
|
# C++11 implementation, node stores value in __aligned_membuf
|
Implement C++17 node extraction and insertion (P0083R5)
* doc/xml/manual/status_cxx2017.xml: Document status.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/node_handle.h and reorder.
* include/Makefile.in: Regenerate.
* include/bits/hashtable.h (_Hashtable::node_type)
(_Hashtable::insert_return_type, _Hashtable::_M_reinsert_node)
(_Hashtable::_M_reinsert_node_multi, _Hashtable::extract)
(_Hashtable::_M_merge_unique, _Hashtable::_M_merge_multi): Define.
(_Hash_merge_helper): Define primary template.
* include/bits/node_handle.h: New header.
* include/bits/stl_map.h (map): Declare _Rb_tree_merge_helper as
friend.
(map::node_type, map::insert_return_type, map::extract, map::merge)
(map::insert(node_type&&), map::insert(const_iterator, node_type&&)):
Define new members.
(_Rb_tree_merge_helper): Specialize for map.
* include/bits/stl_multimap.h (multimap): Declare _Rb_tree_merge_helper
as friend.
(multimap::node_type, multimap::extract, multimap::merge)
(multimap::insert(node_type&&))
(multimap::insert(const_iterator, node_type&&)): Define.
(_Rb_tree_merge_helper): Specialize for multimap.
* include/bits/stl_multiset.h (multiset): Declare _Rb_tree_merge_helper
as friend.
(multiset::node_type, multiset::extract, multiset::merge)
(multiset::insert(node_type&&))
(multiset::insert(const_iterator, node_type&&)): Define.
* include/bits/stl_set.h (set): Declare _Rb_tree_merge_helper as
friend.
(set::node_type, set::insert_return_type, set::extract, set::merge)
(set::insert(node_type&&), set::insert(const_iterator, node_type&&)):
Define.
(_Rb_tree_merge_helper): Specialize for set.
* include/bits/stl_tree.h (_Rb_tree): Declare _Rb_tree<> as friend.
(_Rb_tree::node_type, _Rb_tree::insert_return_type)
(_Rb_tree::_M_reinsert_node_unique, _Rb_tree::_M_reinsert_node_equal)
(_Rb_tree::_M_reinsert_node_hint_unique)
(_Rb_tree::_M_reinsert_node_hint_equal, _Rb_tree::extract)
(_Rb_tree::_M_merge_unique, _Rb_tree::_M_merge_equal): Define.
(_Rb_tree_merge_helper): Specialize for multiset.
* include/bits/unordered_map.h (unordered_map): Declare
unordered_map<> and unordered_multimap<> as friends.
(unordered_map::node_type, unordered_map::insert_return_type)
(unordered_map::extract, unordered_map::merge)
(unordered_map::insert(node_type&&))
(unordered_map::insert(const_iterator, node_type&&))
(unordered_multimap): Declare _Hash_merge_helper as friend.
(unordered_multimap::node_type, unordered_multimap::extract)
(unordered_multimap::merge, unordered_multimap::insert(node_type&&))
(unordered_multimap::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered maps and multimaps.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Declare _Hash_merge_helper as friend.
(unordered_set::node_type, unordered_set::insert_return_type)
(unordered_set::extract, unordered_set::merge)
(unordered_set::insert(node_type&&))
(unordered_set::insert(const_iterator, node_type&&)): Define.
(unordered_multiset::node_type, unordered_multiset::extract)
(unordered_multiset::merge, unordered_multiset::insert(node_type&&))
(unordered_multiset::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered sets and multisets.
* include/debug/map.h (map): Add using declarations or forwarding
functions for new members.
* include/debug/map.h (multimap): Likewise.
* include/debug/map.h (multiset): Likewise.
* include/debug/map.h (set): Likewise.
* include/debug/unordered_map (unordered_map, unordered_multimap):
Likewise.
* include/debug/unordered_set( unordered_set, unordered_multiset):
Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_aligned_membuf): New
helper function.
(get_value_from_list_node, get_value_from_Rb_tree_node): Use helper.
(StdNodeHandlePrinter): Define printer for node handles.
(build_libstdcxx_dictionary): Register StdNodeHandlePrinter.
* testsuite/23_containers/map/modifiers/extract.cc: New.
* testsuite/23_containers/map/modifiers/merge.cc: New.
* testsuite/23_containers/multimap/modifiers/extract.cc: New.
* testsuite/23_containers/multimap/modifiers/merge.cc: New.
* testsuite/23_containers/multiset/modifiers/extract.cc: New.
* testsuite/23_containers/multiset/modifiers/merge.cc: New.
* testsuite/23_containers/set/modifiers/extract.cc: New.
* testsuite/23_containers/set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_map/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_map/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multimap/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multiset/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
dg-error lineno.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test node handles.
From-SVN: r240363
2016-09-22 14:58:49 +01:00
|
|
|
valtype = node.type.template_argument(0)
|
|
|
|
return get_value_from_aligned_membuf(node['_M_storage'], valtype)
|
C++11 allocator support for std::list.
PR libstdc++/55409
* include/bits/list.tcc (_List_base::_M_clear()): Use allocator traits.
(list::list(const list&)): Use allocator propagation trait. Use
_M_assign_dispatch to copy elements.
* include/bits/stl_list.h (_List_node): Use __aligned_membuf in C++11.
(_List_node::_M_valptr()): Add accessor for stored value.
(_List_iterator, _List_const_iterator, _List_base): Use _M_valptr().
(_List_base, list): Use allocator traits.
(_List_base::_M_get_Tp_allocator, _List_base::get_allocator): Remove.
(_List_base::_M_move_nodes): New function.
(_List_base(_List_base&&)): Use _M_move_nodes.
(_List_base(_List_base&&, _Node_alloc_type&&)): New constructor.
(list::_M_create_node, list::_M_erase, list::max_size): Use allocator
traits.
(list(size_type)): Add allocator parameter.
(list(const list&)): Use allocator propagation trait.
(list(const list&, const allocator_type&)): New constructor.
(list(list&&, const allocator_type&)): Likewise.
(list::operator=(list&&), list::swap(list&)): Use allocator
propagation traits.
(list::_M_move_assign): New functions.
* include/debug/list: Add allocator-extended constructors.
* include/profile/list: Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_list_node): New
function to get value from _List_node.
(StdListPrinter): Use get_value_from_list_node.
* testsuite/23_containers/list/allocator/copy.cc: New.
* testsuite/23_containers/list/allocator/copy_assign.cc: New.
* testsuite/23_containers/list/allocator/minimal.cc: New.
* testsuite/23_containers/list/allocator/move.cc: New.
* testsuite/23_containers/list/allocator/move_assign.cc: New.
* testsuite/23_containers/list/allocator/noexcept.cc: New.
* testsuite/23_containers/list/allocator/swap.cc: New.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-prune-output line number.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r224580
2015-06-17 21:36:42 +01:00
|
|
|
except:
|
|
|
|
pass
|
|
|
|
raise ValueError("Unsupported implementation for %s" % str(node.type))
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
class StdListPrinter:
|
|
|
|
"Print a std::list"
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iterator(Iterator):
|
2009-05-28 17:14:18 +00:00
|
|
|
def __init__(self, nodetype, head):
|
|
|
|
self.nodetype = nodetype
|
|
|
|
self.base = head['_M_next']
|
|
|
|
self.head = head.address
|
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2009-05-28 17:14:18 +00:00
|
|
|
if self.base == self.head:
|
|
|
|
raise StopIteration
|
|
|
|
elt = self.base.cast(self.nodetype).dereference()
|
|
|
|
self.base = elt['_M_next']
|
|
|
|
count = self.count
|
|
|
|
self.count = self.count + 1
|
C++11 allocator support for std::list.
PR libstdc++/55409
* include/bits/list.tcc (_List_base::_M_clear()): Use allocator traits.
(list::list(const list&)): Use allocator propagation trait. Use
_M_assign_dispatch to copy elements.
* include/bits/stl_list.h (_List_node): Use __aligned_membuf in C++11.
(_List_node::_M_valptr()): Add accessor for stored value.
(_List_iterator, _List_const_iterator, _List_base): Use _M_valptr().
(_List_base, list): Use allocator traits.
(_List_base::_M_get_Tp_allocator, _List_base::get_allocator): Remove.
(_List_base::_M_move_nodes): New function.
(_List_base(_List_base&&)): Use _M_move_nodes.
(_List_base(_List_base&&, _Node_alloc_type&&)): New constructor.
(list::_M_create_node, list::_M_erase, list::max_size): Use allocator
traits.
(list(size_type)): Add allocator parameter.
(list(const list&)): Use allocator propagation trait.
(list(const list&, const allocator_type&)): New constructor.
(list(list&&, const allocator_type&)): Likewise.
(list::operator=(list&&), list::swap(list&)): Use allocator
propagation traits.
(list::_M_move_assign): New functions.
* include/debug/list: Add allocator-extended constructors.
* include/profile/list: Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_list_node): New
function to get value from _List_node.
(StdListPrinter): Use get_value_from_list_node.
* testsuite/23_containers/list/allocator/copy.cc: New.
* testsuite/23_containers/list/allocator/copy_assign.cc: New.
* testsuite/23_containers/list/allocator/minimal.cc: New.
* testsuite/23_containers/list/allocator/move.cc: New.
* testsuite/23_containers/list/allocator/move_assign.cc: New.
* testsuite/23_containers/list/allocator/noexcept.cc: New.
* testsuite/23_containers/list/allocator/swap.cc: New.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-prune-output line number.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r224580
2015-06-17 21:36:42 +01:00
|
|
|
val = get_value_from_list_node(elt)
|
|
|
|
return ('[%d]' % count, val)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2009-10-01 20:43:13 +00:00
|
|
|
def __init__(self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def children(self):
|
2019-11-29 14:47:03 +00:00
|
|
|
nodetype = lookup_node_type('_List_node', self.val.type).pointer()
|
2009-05-28 17:14:18 +00:00
|
|
|
return self._iterator(nodetype, self.val['_M_impl']['_M_node'])
|
|
|
|
|
|
|
|
def to_string(self):
|
2019-11-29 14:47:03 +00:00
|
|
|
headnode = self.val['_M_impl']['_M_node']
|
|
|
|
if headnode['_M_next'] == headnode.address:
|
2009-10-01 20:43:13 +00:00
|
|
|
return 'empty %s' % (self.typename)
|
|
|
|
return '%s' % (self.typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2018-03-08 06:26:15 +00:00
|
|
|
class NodeIteratorPrinter:
|
2019-11-29 14:47:03 +00:00
|
|
|
def __init__(self, typename, val, contname, nodename):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
2009-10-01 20:43:13 +00:00
|
|
|
self.typename = typename
|
2018-03-08 06:26:15 +00:00
|
|
|
self.contname = contname
|
2019-11-29 14:47:03 +00:00
|
|
|
self.nodetype = lookup_node_type(nodename, val.type)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def to_string(self):
|
2016-12-15 14:13:36 +00:00
|
|
|
if not self.val['_M_node']:
|
2018-03-08 06:26:15 +00:00
|
|
|
return 'non-dereferenceable iterator for std::%s' % (self.contname)
|
2019-11-29 14:47:03 +00:00
|
|
|
node = self.val['_M_node'].cast(self.nodetype.pointer()).dereference()
|
2016-12-15 13:25:22 +00:00
|
|
|
return str(get_value_from_list_node(node))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2018-03-08 06:26:15 +00:00
|
|
|
class StdListIteratorPrinter(NodeIteratorPrinter):
|
|
|
|
"Print std::list::iterator"
|
|
|
|
|
|
|
|
def __init__(self, typename, val):
|
2019-11-29 14:47:03 +00:00
|
|
|
NodeIteratorPrinter.__init__(self, typename, val, 'list', '_List_node')
|
2018-03-08 06:26:15 +00:00
|
|
|
|
|
|
|
class StdFwdListIteratorPrinter(NodeIteratorPrinter):
|
|
|
|
"Print std::forward_list::iterator"
|
|
|
|
|
|
|
|
def __init__(self, typename, val):
|
2019-11-29 14:47:03 +00:00
|
|
|
NodeIteratorPrinter.__init__(self, typename, val, 'forward_list',
|
|
|
|
'_Fwd_list_node')
|
2018-03-08 06:26:15 +00:00
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
class StdSlistPrinter:
|
|
|
|
"Print a __gnu_cxx::slist"
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iterator(Iterator):
|
2009-05-28 17:14:18 +00:00
|
|
|
def __init__(self, nodetype, head):
|
|
|
|
self.nodetype = nodetype
|
|
|
|
self.base = head['_M_head']['_M_next']
|
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2009-05-28 17:14:18 +00:00
|
|
|
if self.base == 0:
|
|
|
|
raise StopIteration
|
|
|
|
elt = self.base.cast(self.nodetype).dereference()
|
|
|
|
self.base = elt['_M_next']
|
|
|
|
count = self.count
|
|
|
|
self.count = self.count + 1
|
|
|
|
return ('[%d]' % count, elt['_M_data'])
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__(self, typename, val):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def children(self):
|
2019-11-29 14:47:03 +00:00
|
|
|
nodetype = lookup_node_type('__gnu_cxx::_Slist_node', self.val.type)
|
|
|
|
return self._iterator(nodetype.pointer(), self.val)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def to_string(self):
|
|
|
|
if self.val['_M_head']['_M_next'] == 0:
|
|
|
|
return 'empty __gnu_cxx::slist'
|
|
|
|
return '__gnu_cxx::slist'
|
|
|
|
|
|
|
|
class StdSlistIteratorPrinter:
|
|
|
|
"Print __gnu_cxx::slist::iterator"
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__(self, typename, val):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def to_string(self):
|
2016-12-15 14:13:36 +00:00
|
|
|
if not self.val['_M_node']:
|
|
|
|
return 'non-dereferenceable iterator for __gnu_cxx::slist'
|
2019-11-29 14:47:03 +00:00
|
|
|
nodetype = lookup_node_type('__gnu_cxx::_Slist_node', self.val.type).pointer()
|
2016-12-15 13:25:22 +00:00
|
|
|
return str(self.val['_M_node'].cast(nodetype).dereference()['_M_data'])
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
class StdVectorPrinter:
|
|
|
|
"Print a std::vector"
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iterator(Iterator):
|
2010-08-16 18:48:27 +00:00
|
|
|
def __init__ (self, start, finish, bitvec):
|
|
|
|
self.bitvec = bitvec
|
|
|
|
if bitvec:
|
|
|
|
self.item = start['_M_p']
|
libstdc++: Fix and improve std::vector<bool> implementation.
Do not consider allocator noexcept qualification for vector<bool> move
constructor.
Improve swap performance using TBAA like in main vector implementation. Bypass
_M_initialize_dispatch/_M_assign_dispatch in post-c++11 modes.
libstdc++-v3/ChangeLog:
* include/bits/stl_bvector.h
[_GLIBCXX_INLINE_VERSION](_Bvector_impl_data::_M_start): Define as
_Bit_type*.
(_Bvector_impl_data(const _Bvector_impl_data&)): Default.
(_Bvector_impl_data(_Bvector_impl_data&&)): Delegate to latter.
(_Bvector_impl_data::operator=(const _Bvector_impl_data&)): Default.
(_Bvector_impl_data::_M_move_data(_Bvector_impl_data&&)): Use latter.
(_Bvector_impl_data::_M_reset()): Likewise.
(_Bvector_impl_data::_M_swap_data): New.
(_Bvector_impl::_Bvector_impl(_Bvector_impl&&)): Implement explicitely.
(_Bvector_impl::_Bvector_impl(_Bit_alloc_type&&, _Bvector_impl&&)): New.
(_Bvector_base::_Bvector_base(_Bvector_base&&, const allocator_type&)):
New, use latter.
(vector::vector(vector&&, const allocator_type&, true_type)): New, use
latter.
(vector::vector(vector&&, const allocator_type&, false_type)): New.
(vector::vector(vector&&, const allocator_type&)): Use latters.
(vector::vector(const vector&, const allocator_type&)): Adapt.
[__cplusplus >= 201103](vector::vector(_InputIt, _InputIt,
const allocator_type&)): Use _M_initialize_range.
(vector::operator[](size_type)): Use iterator operator[].
(vector::operator[](size_type) const): Use const_iterator operator[].
(vector::swap(vector&)): Add assertions on allocators. Use _M_swap_data.
[__cplusplus >= 201103](vector::insert(const_iterator, _InputIt,
_InputIt)): Use _M_insert_range.
(vector::_M_initialize(size_type)): Adapt.
[__cplusplus >= 201103](vector::_M_initialize_dispatch): Remove.
[__cplusplus >= 201103](vector::_M_insert_dispatch): Remove.
* python/libstdcxx/v6/printers.py (StdVectorPrinter._iterator): Stop
using start _M_offset.
(StdVectorPrinter.to_string): Likewise.
* testsuite/23_containers/vector/bool/allocator/swap.cc: Adapt.
* testsuite/23_containers/vector/bool/cons/noexcept_move_construct.cc:
Add check.
2020-01-21 07:18:08 +01:00
|
|
|
self.so = 0
|
2010-08-16 18:48:27 +00:00
|
|
|
self.finish = finish['_M_p']
|
|
|
|
self.fo = finish['_M_offset']
|
|
|
|
itype = self.item.dereference().type
|
|
|
|
self.isize = 8 * itype.sizeof
|
|
|
|
else:
|
|
|
|
self.item = start
|
|
|
|
self.finish = finish
|
2009-05-28 17:14:18 +00:00
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2009-05-28 17:14:18 +00:00
|
|
|
count = self.count
|
|
|
|
self.count = self.count + 1
|
2010-08-16 18:48:27 +00:00
|
|
|
if self.bitvec:
|
|
|
|
if self.item == self.finish and self.so >= self.fo:
|
|
|
|
raise StopIteration
|
2019-06-19 22:57:06 +00:00
|
|
|
elt = bool(self.item.dereference() & (1 << self.so))
|
2010-08-16 18:48:27 +00:00
|
|
|
self.so = self.so + 1
|
|
|
|
if self.so >= self.isize:
|
|
|
|
self.item = self.item + 1
|
|
|
|
self.so = 0
|
2019-06-19 22:57:06 +00:00
|
|
|
return ('[%d]' % count, elt)
|
2010-08-16 18:48:27 +00:00
|
|
|
else:
|
|
|
|
if self.item == self.finish:
|
|
|
|
raise StopIteration
|
|
|
|
elt = self.item.dereference()
|
|
|
|
self.item = self.item + 1
|
|
|
|
return ('[%d]' % count, elt)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2009-10-01 20:43:13 +00:00
|
|
|
def __init__(self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
2019-06-19 22:57:06 +00:00
|
|
|
self.is_bool = val.type.template_argument(0).code == gdb.TYPE_CODE_BOOL
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def children(self):
|
|
|
|
return self._iterator(self.val['_M_impl']['_M_start'],
|
2010-08-16 18:48:27 +00:00
|
|
|
self.val['_M_impl']['_M_finish'],
|
|
|
|
self.is_bool)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def to_string(self):
|
|
|
|
start = self.val['_M_impl']['_M_start']
|
|
|
|
finish = self.val['_M_impl']['_M_finish']
|
|
|
|
end = self.val['_M_impl']['_M_end_of_storage']
|
2010-08-16 18:48:27 +00:00
|
|
|
if self.is_bool:
|
|
|
|
start = self.val['_M_impl']['_M_start']['_M_p']
|
|
|
|
finish = self.val['_M_impl']['_M_finish']['_M_p']
|
|
|
|
fo = self.val['_M_impl']['_M_finish']['_M_offset']
|
|
|
|
itype = start.dereference().type
|
|
|
|
bl = 8 * itype.sizeof
|
libstdc++: Fix and improve std::vector<bool> implementation.
Do not consider allocator noexcept qualification for vector<bool> move
constructor.
Improve swap performance using TBAA like in main vector implementation. Bypass
_M_initialize_dispatch/_M_assign_dispatch in post-c++11 modes.
libstdc++-v3/ChangeLog:
* include/bits/stl_bvector.h
[_GLIBCXX_INLINE_VERSION](_Bvector_impl_data::_M_start): Define as
_Bit_type*.
(_Bvector_impl_data(const _Bvector_impl_data&)): Default.
(_Bvector_impl_data(_Bvector_impl_data&&)): Delegate to latter.
(_Bvector_impl_data::operator=(const _Bvector_impl_data&)): Default.
(_Bvector_impl_data::_M_move_data(_Bvector_impl_data&&)): Use latter.
(_Bvector_impl_data::_M_reset()): Likewise.
(_Bvector_impl_data::_M_swap_data): New.
(_Bvector_impl::_Bvector_impl(_Bvector_impl&&)): Implement explicitely.
(_Bvector_impl::_Bvector_impl(_Bit_alloc_type&&, _Bvector_impl&&)): New.
(_Bvector_base::_Bvector_base(_Bvector_base&&, const allocator_type&)):
New, use latter.
(vector::vector(vector&&, const allocator_type&, true_type)): New, use
latter.
(vector::vector(vector&&, const allocator_type&, false_type)): New.
(vector::vector(vector&&, const allocator_type&)): Use latters.
(vector::vector(const vector&, const allocator_type&)): Adapt.
[__cplusplus >= 201103](vector::vector(_InputIt, _InputIt,
const allocator_type&)): Use _M_initialize_range.
(vector::operator[](size_type)): Use iterator operator[].
(vector::operator[](size_type) const): Use const_iterator operator[].
(vector::swap(vector&)): Add assertions on allocators. Use _M_swap_data.
[__cplusplus >= 201103](vector::insert(const_iterator, _InputIt,
_InputIt)): Use _M_insert_range.
(vector::_M_initialize(size_type)): Adapt.
[__cplusplus >= 201103](vector::_M_initialize_dispatch): Remove.
[__cplusplus >= 201103](vector::_M_insert_dispatch): Remove.
* python/libstdcxx/v6/printers.py (StdVectorPrinter._iterator): Stop
using start _M_offset.
(StdVectorPrinter.to_string): Likewise.
* testsuite/23_containers/vector/bool/allocator/swap.cc: Adapt.
* testsuite/23_containers/vector/bool/cons/noexcept_move_construct.cc:
Add check.
2020-01-21 07:18:08 +01:00
|
|
|
length = bl * (finish - start) + fo
|
2010-08-16 18:48:27 +00:00
|
|
|
capacity = bl * (end - start)
|
|
|
|
return ('%s<bool> of length %d, capacity %d'
|
|
|
|
% (self.typename, int (length), int (capacity)))
|
|
|
|
else:
|
|
|
|
return ('%s of length %d, capacity %d'
|
|
|
|
% (self.typename, int (finish - start), int (end - start)))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def display_hint(self):
|
|
|
|
return 'array'
|
|
|
|
|
|
|
|
class StdVectorIteratorPrinter:
|
|
|
|
"Print std::vector::iterator"
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__(self, typename, val):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def to_string(self):
|
2016-12-15 14:13:36 +00:00
|
|
|
if not self.val['_M_current']:
|
|
|
|
return 'non-dereferenceable iterator for std::vector'
|
2016-12-15 13:25:22 +00:00
|
|
|
return str(self.val['_M_current'].dereference())
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2019-06-19 22:57:06 +00:00
|
|
|
# TODO add printer for vector<bool>'s _Bit_iterator and _Bit_const_iterator
|
|
|
|
|
2009-10-20 13:52:34 +00:00
|
|
|
class StdTuplePrinter:
|
|
|
|
"Print a std::tuple"
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iterator(Iterator):
|
PR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment
PR libstdc++/86963
* include/std/tuple (__tuple_base): New class template with deleted
copy assignment operator.
(tuple, tuple<_T1, _T2>): Derive from __tuple_base<tuple> so that
implicit copy/move assignment operator will be deleted/suppressed.
(tuple::__assignable, tuple<_T1, _T2>::__assignable): New helper
functions for SFINAE constraints on assignment operators.
(tuple::__nothrow_assignable, tuple<_T1, _T2>::__nothrow_assignable):
New helper functions for exception specifications.
(tuple::operator=(const tuple&), tuple::operator=(tuple&&))
(tuple<_T1, _T2>::operator=(const tuple&))
(tuple<_T1, _T2>::operator=(tuple&&)): Change parameter types to
__nonesuch_no_braces when the operator should be defined implicitly.
Use __nothrow_assignable for exception specifications.
(tuple::operator=(const tuple<_UElements...>&))
(tuple::operator=(tuple<_UElements...>&&))
(tuple<_T1, _T2>::operator=(const tuple<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(tuple<_U1, _U2>&&))
(tuple<_T1, _T2>::operator=(const pair<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(pair<_U1, _U2>&&)): Constrain using
__assignable and use __nothrow_assignable for exception
specifications.
* python/libstdcxx/v6/printers.py (is_specialization_of): Accept
gdb.Type as first argument, instead of a string.
(StdTuplePrinter._iterator._is_nonempty_tuple): New method to check
tuple for expected structure.
(StdTuplePrinter._iterator.__init__): Use _is_nonempty_tuple.
* testsuite/20_util/tuple/dr2729.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Change dg-error
to dg-prune-output.
From-SVN: r263625
2018-08-17 18:52:49 +01:00
|
|
|
@staticmethod
|
|
|
|
def _is_nonempty_tuple (nodes):
|
|
|
|
if len (nodes) == 2:
|
|
|
|
if is_specialization_of (nodes[1].type, '__tuple_base'):
|
|
|
|
return True
|
|
|
|
elif len (nodes) == 1:
|
|
|
|
return True
|
|
|
|
elif len (nodes) == 0:
|
|
|
|
return False
|
|
|
|
raise ValueError("Top of tuple tree does not consist of a single node.")
|
|
|
|
|
2009-10-20 13:52:34 +00:00
|
|
|
def __init__ (self, head):
|
|
|
|
self.head = head
|
|
|
|
|
|
|
|
# Set the base class as the initial head of the
|
|
|
|
# tuple.
|
|
|
|
nodes = self.head.type.fields ()
|
PR libstdc++/86963 Implement LWG 2729 constraints on tuple assignment
PR libstdc++/86963
* include/std/tuple (__tuple_base): New class template with deleted
copy assignment operator.
(tuple, tuple<_T1, _T2>): Derive from __tuple_base<tuple> so that
implicit copy/move assignment operator will be deleted/suppressed.
(tuple::__assignable, tuple<_T1, _T2>::__assignable): New helper
functions for SFINAE constraints on assignment operators.
(tuple::__nothrow_assignable, tuple<_T1, _T2>::__nothrow_assignable):
New helper functions for exception specifications.
(tuple::operator=(const tuple&), tuple::operator=(tuple&&))
(tuple<_T1, _T2>::operator=(const tuple&))
(tuple<_T1, _T2>::operator=(tuple&&)): Change parameter types to
__nonesuch_no_braces when the operator should be defined implicitly.
Use __nothrow_assignable for exception specifications.
(tuple::operator=(const tuple<_UElements...>&))
(tuple::operator=(tuple<_UElements...>&&))
(tuple<_T1, _T2>::operator=(const tuple<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(tuple<_U1, _U2>&&))
(tuple<_T1, _T2>::operator=(const pair<_U1, _U2>&))
(tuple<_T1, _T2>::operator=(pair<_U1, _U2>&&)): Constrain using
__assignable and use __nothrow_assignable for exception
specifications.
* python/libstdcxx/v6/printers.py (is_specialization_of): Accept
gdb.Type as first argument, instead of a string.
(StdTuplePrinter._iterator._is_nonempty_tuple): New method to check
tuple for expected structure.
(StdTuplePrinter._iterator.__init__): Use _is_nonempty_tuple.
* testsuite/20_util/tuple/dr2729.cc: New test.
* testsuite/20_util/tuple/element_access/get_neg.cc: Change dg-error
to dg-prune-output.
From-SVN: r263625
2018-08-17 18:52:49 +01:00
|
|
|
if self._is_nonempty_tuple (nodes):
|
2011-12-22 12:33:15 +00:00
|
|
|
# Set the actual head to the first pair.
|
|
|
|
self.head = self.head.cast (nodes[0].type)
|
2009-10-20 13:52:34 +00:00
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__ (self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__ (self):
|
2009-10-20 13:52:34 +00:00
|
|
|
# Check for further recursions in the inheritance tree.
|
2015-02-20 14:40:00 +00:00
|
|
|
# For a GCC 5+ tuple self.head is None after visiting all nodes:
|
|
|
|
if not self.head:
|
|
|
|
raise StopIteration
|
|
|
|
nodes = self.head.type.fields ()
|
|
|
|
# For a GCC 4.x tuple there is a final node with no fields:
|
2009-10-20 13:52:34 +00:00
|
|
|
if len (nodes) == 0:
|
|
|
|
raise StopIteration
|
|
|
|
# Check that this iteration has an expected structure.
|
2015-02-20 14:40:00 +00:00
|
|
|
if len (nodes) > 2:
|
2014-05-19 22:43:13 +01:00
|
|
|
raise ValueError("Cannot parse more than 2 nodes in a tuple tree.")
|
2009-10-20 13:52:34 +00:00
|
|
|
|
2015-02-20 14:40:00 +00:00
|
|
|
if len (nodes) == 1:
|
|
|
|
# This is the last node of a GCC 5+ std::tuple.
|
|
|
|
impl = self.head.cast (nodes[0].type)
|
|
|
|
self.head = None
|
|
|
|
else:
|
|
|
|
# Either a node before the last node, or the last node of
|
|
|
|
# a GCC 4.x tuple (which has an empty parent).
|
|
|
|
|
|
|
|
# - Left node is the next recursion parent.
|
|
|
|
# - Right node is the actual class contained in the tuple.
|
2009-10-20 13:52:34 +00:00
|
|
|
|
2015-02-20 14:40:00 +00:00
|
|
|
# Process right node.
|
|
|
|
impl = self.head.cast (nodes[1].type)
|
|
|
|
|
|
|
|
# Process left node and set it as head.
|
|
|
|
self.head = self.head.cast (nodes[0].type)
|
2009-10-20 13:52:34 +00:00
|
|
|
|
|
|
|
self.count = self.count + 1
|
|
|
|
|
|
|
|
# Finally, check the implementation. If it is
|
|
|
|
# wrapped in _M_head_impl return that, otherwise return
|
|
|
|
# the value "as is".
|
|
|
|
fields = impl.type.fields ()
|
|
|
|
if len (fields) < 1 or fields[0].name != "_M_head_impl":
|
|
|
|
return ('[%d]' % self.count, impl)
|
|
|
|
else:
|
|
|
|
return ('[%d]' % self.count, impl['_M_head_impl'])
|
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-10-20 13:52:34 +00:00
|
|
|
self.val = val;
|
|
|
|
|
|
|
|
def children (self):
|
|
|
|
return self._iterator (self.val)
|
|
|
|
|
|
|
|
def to_string (self):
|
2011-12-22 12:33:15 +00:00
|
|
|
if len (self.val.type.fields ()) == 0:
|
|
|
|
return 'empty %s' % (self.typename)
|
2009-10-20 13:52:34 +00:00
|
|
|
return '%s containing' % (self.typename)
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
class StdStackOrQueuePrinter:
|
|
|
|
"Print a std::stack or std::queue"
|
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.visualizer = gdb.default_visualizer(val['c'])
|
|
|
|
|
|
|
|
def children (self):
|
|
|
|
return self.visualizer.children()
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
return '%s wrapping: %s' % (self.typename,
|
|
|
|
self.visualizer.to_string())
|
|
|
|
|
|
|
|
def display_hint (self):
|
|
|
|
if hasattr (self.visualizer, 'display_hint'):
|
|
|
|
return self.visualizer.display_hint ()
|
|
|
|
return None
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class RbtreeIterator(Iterator):
|
2016-12-15 12:45:47 +00:00
|
|
|
"""
|
|
|
|
Turn an RB-tree-based container (std::map, std::set etc.) into
|
|
|
|
a Python iterable object.
|
|
|
|
"""
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
def __init__(self, rbtree):
|
|
|
|
self.size = rbtree['_M_t']['_M_impl']['_M_node_count']
|
|
|
|
self.node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left']
|
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __len__(self):
|
|
|
|
return int (self.size)
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2009-05-28 17:14:18 +00:00
|
|
|
if self.count == self.size:
|
|
|
|
raise StopIteration
|
|
|
|
result = self.node
|
|
|
|
self.count = self.count + 1
|
|
|
|
if self.count < self.size:
|
|
|
|
# Compute the next node.
|
|
|
|
node = self.node
|
|
|
|
if node.dereference()['_M_right']:
|
|
|
|
node = node.dereference()['_M_right']
|
|
|
|
while node.dereference()['_M_left']:
|
|
|
|
node = node.dereference()['_M_left']
|
|
|
|
else:
|
|
|
|
parent = node.dereference()['_M_parent']
|
|
|
|
while node == parent.dereference()['_M_right']:
|
|
|
|
node = parent
|
|
|
|
parent = parent.dereference()['_M_parent']
|
|
|
|
if node.dereference()['_M_right'] != parent:
|
|
|
|
node = parent
|
|
|
|
self.node = node
|
|
|
|
return result
|
|
|
|
|
2014-05-02 17:01:30 +01:00
|
|
|
def get_value_from_Rb_tree_node(node):
|
|
|
|
"""Returns the value held in an _Rb_tree_node<_Val>"""
|
|
|
|
try:
|
|
|
|
member = node.type.fields()[1].name
|
|
|
|
if member == '_M_value_field':
|
|
|
|
# C++03 implementation, node contains the value as a member
|
|
|
|
return node['_M_value_field']
|
|
|
|
elif member == '_M_storage':
|
C++11 allocator support for std::list.
PR libstdc++/55409
* include/bits/list.tcc (_List_base::_M_clear()): Use allocator traits.
(list::list(const list&)): Use allocator propagation trait. Use
_M_assign_dispatch to copy elements.
* include/bits/stl_list.h (_List_node): Use __aligned_membuf in C++11.
(_List_node::_M_valptr()): Add accessor for stored value.
(_List_iterator, _List_const_iterator, _List_base): Use _M_valptr().
(_List_base, list): Use allocator traits.
(_List_base::_M_get_Tp_allocator, _List_base::get_allocator): Remove.
(_List_base::_M_move_nodes): New function.
(_List_base(_List_base&&)): Use _M_move_nodes.
(_List_base(_List_base&&, _Node_alloc_type&&)): New constructor.
(list::_M_create_node, list::_M_erase, list::max_size): Use allocator
traits.
(list(size_type)): Add allocator parameter.
(list(const list&)): Use allocator propagation trait.
(list(const list&, const allocator_type&)): New constructor.
(list(list&&, const allocator_type&)): Likewise.
(list::operator=(list&&), list::swap(list&)): Use allocator
propagation traits.
(list::_M_move_assign): New functions.
* include/debug/list: Add allocator-extended constructors.
* include/profile/list: Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_list_node): New
function to get value from _List_node.
(StdListPrinter): Use get_value_from_list_node.
* testsuite/23_containers/list/allocator/copy.cc: New.
* testsuite/23_containers/list/allocator/copy_assign.cc: New.
* testsuite/23_containers/list/allocator/minimal.cc: New.
* testsuite/23_containers/list/allocator/move.cc: New.
* testsuite/23_containers/list/allocator/move_assign.cc: New.
* testsuite/23_containers/list/allocator/noexcept.cc: New.
* testsuite/23_containers/list/allocator/swap.cc: New.
* testsuite/23_containers/list/requirements/dr438/assign_neg.cc:
Adjust dg-prune-output line number.
* testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc:
Likewise.
* testsuite/23_containers/list/requirements/dr438/insert_neg.cc:
Likewise.
From-SVN: r224580
2015-06-17 21:36:42 +01:00
|
|
|
# C++11 implementation, node stores value in __aligned_membuf
|
Implement C++17 node extraction and insertion (P0083R5)
* doc/xml/manual/status_cxx2017.xml: Document status.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/node_handle.h and reorder.
* include/Makefile.in: Regenerate.
* include/bits/hashtable.h (_Hashtable::node_type)
(_Hashtable::insert_return_type, _Hashtable::_M_reinsert_node)
(_Hashtable::_M_reinsert_node_multi, _Hashtable::extract)
(_Hashtable::_M_merge_unique, _Hashtable::_M_merge_multi): Define.
(_Hash_merge_helper): Define primary template.
* include/bits/node_handle.h: New header.
* include/bits/stl_map.h (map): Declare _Rb_tree_merge_helper as
friend.
(map::node_type, map::insert_return_type, map::extract, map::merge)
(map::insert(node_type&&), map::insert(const_iterator, node_type&&)):
Define new members.
(_Rb_tree_merge_helper): Specialize for map.
* include/bits/stl_multimap.h (multimap): Declare _Rb_tree_merge_helper
as friend.
(multimap::node_type, multimap::extract, multimap::merge)
(multimap::insert(node_type&&))
(multimap::insert(const_iterator, node_type&&)): Define.
(_Rb_tree_merge_helper): Specialize for multimap.
* include/bits/stl_multiset.h (multiset): Declare _Rb_tree_merge_helper
as friend.
(multiset::node_type, multiset::extract, multiset::merge)
(multiset::insert(node_type&&))
(multiset::insert(const_iterator, node_type&&)): Define.
* include/bits/stl_set.h (set): Declare _Rb_tree_merge_helper as
friend.
(set::node_type, set::insert_return_type, set::extract, set::merge)
(set::insert(node_type&&), set::insert(const_iterator, node_type&&)):
Define.
(_Rb_tree_merge_helper): Specialize for set.
* include/bits/stl_tree.h (_Rb_tree): Declare _Rb_tree<> as friend.
(_Rb_tree::node_type, _Rb_tree::insert_return_type)
(_Rb_tree::_M_reinsert_node_unique, _Rb_tree::_M_reinsert_node_equal)
(_Rb_tree::_M_reinsert_node_hint_unique)
(_Rb_tree::_M_reinsert_node_hint_equal, _Rb_tree::extract)
(_Rb_tree::_M_merge_unique, _Rb_tree::_M_merge_equal): Define.
(_Rb_tree_merge_helper): Specialize for multiset.
* include/bits/unordered_map.h (unordered_map): Declare
unordered_map<> and unordered_multimap<> as friends.
(unordered_map::node_type, unordered_map::insert_return_type)
(unordered_map::extract, unordered_map::merge)
(unordered_map::insert(node_type&&))
(unordered_map::insert(const_iterator, node_type&&))
(unordered_multimap): Declare _Hash_merge_helper as friend.
(unordered_multimap::node_type, unordered_multimap::extract)
(unordered_multimap::merge, unordered_multimap::insert(node_type&&))
(unordered_multimap::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered maps and multimaps.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Declare _Hash_merge_helper as friend.
(unordered_set::node_type, unordered_set::insert_return_type)
(unordered_set::extract, unordered_set::merge)
(unordered_set::insert(node_type&&))
(unordered_set::insert(const_iterator, node_type&&)): Define.
(unordered_multiset::node_type, unordered_multiset::extract)
(unordered_multiset::merge, unordered_multiset::insert(node_type&&))
(unordered_multiset::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered sets and multisets.
* include/debug/map.h (map): Add using declarations or forwarding
functions for new members.
* include/debug/map.h (multimap): Likewise.
* include/debug/map.h (multiset): Likewise.
* include/debug/map.h (set): Likewise.
* include/debug/unordered_map (unordered_map, unordered_multimap):
Likewise.
* include/debug/unordered_set( unordered_set, unordered_multiset):
Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_aligned_membuf): New
helper function.
(get_value_from_list_node, get_value_from_Rb_tree_node): Use helper.
(StdNodeHandlePrinter): Define printer for node handles.
(build_libstdcxx_dictionary): Register StdNodeHandlePrinter.
* testsuite/23_containers/map/modifiers/extract.cc: New.
* testsuite/23_containers/map/modifiers/merge.cc: New.
* testsuite/23_containers/multimap/modifiers/extract.cc: New.
* testsuite/23_containers/multimap/modifiers/merge.cc: New.
* testsuite/23_containers/multiset/modifiers/extract.cc: New.
* testsuite/23_containers/multiset/modifiers/merge.cc: New.
* testsuite/23_containers/set/modifiers/extract.cc: New.
* testsuite/23_containers/set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_map/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_map/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multimap/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multiset/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
dg-error lineno.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test node handles.
From-SVN: r240363
2016-09-22 14:58:49 +01:00
|
|
|
valtype = node.type.template_argument(0)
|
|
|
|
return get_value_from_aligned_membuf(node['_M_storage'], valtype)
|
2014-05-02 17:01:30 +01:00
|
|
|
except:
|
|
|
|
pass
|
2014-05-19 22:43:13 +01:00
|
|
|
raise ValueError("Unsupported implementation for %s" % str(node.type))
|
2014-05-02 17:01:30 +01:00
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
# This is a pretty printer for std::_Rb_tree_iterator (which is
|
|
|
|
# std::map::iterator), and has nothing to do with the RbtreeIterator
|
|
|
|
# class above.
|
|
|
|
class StdRbtreeIteratorPrinter:
|
2016-12-15 12:45:47 +00:00
|
|
|
"Print std::map::iterator, std::set::iterator, etc."
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__ (self, typename, val):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
2019-11-29 14:47:03 +00:00
|
|
|
nodetype = lookup_node_type('_Rb_tree_node', self.val.type)
|
|
|
|
self.link_type = nodetype.pointer()
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def to_string (self):
|
2016-12-15 14:13:36 +00:00
|
|
|
if not self.val['_M_node']:
|
|
|
|
return 'non-dereferenceable iterator for associative container'
|
2015-05-27 12:18:37 +01:00
|
|
|
node = self.val['_M_node'].cast(self.link_type).dereference()
|
2016-12-15 13:25:22 +00:00
|
|
|
return str(get_value_from_Rb_tree_node(node))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2009-10-01 20:43:13 +00:00
|
|
|
class StdDebugIteratorPrinter:
|
|
|
|
"Print a debug enabled version of an iterator"
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__ (self, typename, val):
|
2009-10-01 20:43:13 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
# Just strip away the encapsulating __gnu_debug::_Safe_iterator
|
|
|
|
# and return the wrapped iterator value.
|
|
|
|
def to_string (self):
|
2016-12-14 15:17:57 +00:00
|
|
|
base_type = gdb.lookup_type('__gnu_debug::_Safe_iterator_base')
|
2018-03-08 06:26:15 +00:00
|
|
|
itype = self.val.type.template_argument(0)
|
2016-12-14 15:17:57 +00:00
|
|
|
safe_seq = self.val.cast(base_type)['_M_sequence']
|
2018-03-08 06:26:15 +00:00
|
|
|
if not safe_seq:
|
|
|
|
return str(self.val.cast(itype))
|
|
|
|
if self.val['_M_version'] != safe_seq['_M_version']:
|
2016-12-14 15:17:57 +00:00
|
|
|
return "invalid iterator"
|
2016-12-15 13:25:22 +00:00
|
|
|
return str(self.val.cast(itype))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2016-12-14 16:07:29 +00:00
|
|
|
def num_elements(num):
|
|
|
|
"""Return either "1 element" or "N elements" depending on the argument."""
|
|
|
|
return '1 element' if num == 1 else '%d elements' % num
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
class StdMapPrinter:
|
|
|
|
"Print a std::map or std::multimap"
|
|
|
|
|
|
|
|
# Turn an RbtreeIterator into a pretty-print iterator.
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iter(Iterator):
|
2009-05-28 17:14:18 +00:00
|
|
|
def __init__(self, rbiter, type):
|
|
|
|
self.rbiter = rbiter
|
|
|
|
self.count = 0
|
|
|
|
self.type = type
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2009-05-28 17:14:18 +00:00
|
|
|
if self.count % 2 == 0:
|
2014-07-11 13:43:07 +00:00
|
|
|
n = next(self.rbiter)
|
2014-05-02 17:01:30 +01:00
|
|
|
n = n.cast(self.type).dereference()
|
|
|
|
n = get_value_from_Rb_tree_node(n)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.pair = n
|
|
|
|
item = n['first']
|
|
|
|
else:
|
|
|
|
item = self.pair['second']
|
|
|
|
result = ('[%d]' % self.count, item)
|
|
|
|
self.count = self.count + 1
|
|
|
|
return result
|
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def to_string (self):
|
2016-12-14 16:07:29 +00:00
|
|
|
return '%s with %s' % (self.typename,
|
|
|
|
num_elements(len(RbtreeIterator (self.val))))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def children (self):
|
2019-11-29 14:47:03 +00:00
|
|
|
node = lookup_node_type('_Rb_tree_node', self.val.type).pointer()
|
2012-01-30 16:25:11 +00:00
|
|
|
return self._iter (RbtreeIterator (self.val), node)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def display_hint (self):
|
|
|
|
return 'map'
|
|
|
|
|
|
|
|
class StdSetPrinter:
|
|
|
|
"Print a std::set or std::multiset"
|
|
|
|
|
|
|
|
# Turn an RbtreeIterator into a pretty-print iterator.
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iter(Iterator):
|
2009-05-28 17:14:18 +00:00
|
|
|
def __init__(self, rbiter, type):
|
|
|
|
self.rbiter = rbiter
|
|
|
|
self.count = 0
|
|
|
|
self.type = type
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
|
|
|
item = next(self.rbiter)
|
2014-05-02 17:01:30 +01:00
|
|
|
item = item.cast(self.type).dereference()
|
|
|
|
item = get_value_from_Rb_tree_node(item)
|
2009-05-28 17:14:18 +00:00
|
|
|
# FIXME: this is weird ... what to do?
|
|
|
|
# Maybe a 'set' display hint?
|
|
|
|
result = ('[%d]' % self.count, item)
|
|
|
|
self.count = self.count + 1
|
|
|
|
return result
|
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def to_string (self):
|
2016-12-14 16:07:29 +00:00
|
|
|
return '%s with %s' % (self.typename,
|
|
|
|
num_elements(len(RbtreeIterator (self.val))))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def children (self):
|
2019-11-29 14:47:03 +00:00
|
|
|
node = lookup_node_type('_Rb_tree_node', self.val.type).pointer()
|
2012-01-30 16:25:11 +00:00
|
|
|
return self._iter (RbtreeIterator (self.val), node)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
class StdBitsetPrinter:
|
|
|
|
"Print a std::bitset"
|
|
|
|
|
2009-10-01 20:43:13 +00:00
|
|
|
def __init__(self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
# If template_argument handled values, we could print the
|
|
|
|
# size. Or we could use a regexp on the type.
|
2009-10-01 20:43:13 +00:00
|
|
|
return '%s' % (self.typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def children (self):
|
2018-11-23 16:12:03 +00:00
|
|
|
try:
|
|
|
|
# An empty bitset may not have any members which will
|
|
|
|
# result in an exception being thrown.
|
|
|
|
words = self.val['_M_w']
|
|
|
|
except:
|
|
|
|
return []
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
wtype = words.type
|
|
|
|
|
|
|
|
# The _M_w member can be either an unsigned long, or an
|
|
|
|
# array. This depends on the template specialization used.
|
|
|
|
# If it is a single long, convert to a single element list.
|
|
|
|
if wtype.code == gdb.TYPE_CODE_ARRAY:
|
|
|
|
tsize = wtype.target ().sizeof
|
|
|
|
else:
|
|
|
|
words = [words]
|
2018-11-23 16:12:03 +00:00
|
|
|
tsize = wtype.sizeof
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
nwords = wtype.sizeof / tsize
|
|
|
|
result = []
|
|
|
|
byte = 0
|
|
|
|
while byte < nwords:
|
|
|
|
w = words[byte]
|
|
|
|
bit = 0
|
|
|
|
while w != 0:
|
|
|
|
if (w & 1) != 0:
|
|
|
|
# Another spot where we could use 'set'?
|
|
|
|
result.append(('[%d]' % (byte * tsize * 8 + bit), 1))
|
|
|
|
bit = bit + 1
|
|
|
|
w = w >> 1
|
|
|
|
byte = byte + 1
|
|
|
|
return result
|
|
|
|
|
|
|
|
class StdDequePrinter:
|
|
|
|
"Print a std::deque"
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iter(Iterator):
|
2009-05-28 17:14:18 +00:00
|
|
|
def __init__(self, node, start, end, last, buffer_size):
|
|
|
|
self.node = node
|
|
|
|
self.p = start
|
|
|
|
self.end = end
|
|
|
|
self.last = last
|
|
|
|
self.buffer_size = buffer_size
|
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2009-05-28 17:14:18 +00:00
|
|
|
if self.p == self.last:
|
|
|
|
raise StopIteration
|
|
|
|
|
|
|
|
result = ('[%d]' % self.count, self.p.dereference())
|
|
|
|
self.count = self.count + 1
|
|
|
|
|
|
|
|
# Advance the 'cur' pointer.
|
|
|
|
self.p = self.p + 1
|
|
|
|
if self.p == self.end:
|
|
|
|
# If we got to the end of this bucket, move to the
|
|
|
|
# next bucket.
|
|
|
|
self.node = self.node + 1
|
|
|
|
self.p = self.node[0]
|
|
|
|
self.end = self.p + self.buffer_size
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
2009-10-01 20:43:13 +00:00
|
|
|
def __init__(self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
self.elttype = val.type.template_argument(0)
|
|
|
|
size = self.elttype.sizeof
|
|
|
|
if size < 512:
|
|
|
|
self.buffer_size = int (512 / size)
|
|
|
|
else:
|
|
|
|
self.buffer_size = 1
|
|
|
|
|
|
|
|
def to_string(self):
|
|
|
|
start = self.val['_M_impl']['_M_start']
|
|
|
|
end = self.val['_M_impl']['_M_finish']
|
|
|
|
|
|
|
|
delta_n = end['_M_node'] - start['_M_node'] - 1
|
|
|
|
delta_s = start['_M_last'] - start['_M_cur']
|
|
|
|
delta_e = end['_M_cur'] - end['_M_first']
|
|
|
|
|
|
|
|
size = self.buffer_size * delta_n + delta_s + delta_e
|
|
|
|
|
2016-12-14 16:07:29 +00:00
|
|
|
return '%s with %s' % (self.typename, num_elements(long(size)))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def children(self):
|
|
|
|
start = self.val['_M_impl']['_M_start']
|
|
|
|
end = self.val['_M_impl']['_M_finish']
|
|
|
|
return self._iter(start['_M_node'], start['_M_cur'], start['_M_last'],
|
|
|
|
end['_M_cur'], self.buffer_size)
|
|
|
|
|
|
|
|
def display_hint (self):
|
|
|
|
return 'array'
|
|
|
|
|
|
|
|
class StdDequeIteratorPrinter:
|
|
|
|
"Print std::deque::iterator"
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__(self, typename, val):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def to_string(self):
|
2016-12-15 14:13:36 +00:00
|
|
|
if not self.val['_M_cur']:
|
|
|
|
return 'non-dereferenceable iterator for std::deque'
|
2016-12-15 13:25:22 +00:00
|
|
|
return str(self.val['_M_cur'].dereference())
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
class StdStringPrinter:
|
|
|
|
"Print a std::basic_string of some kind"
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __init__(self, typename, val):
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
self.new_string = typename.find("::__cxx11::basic_string") != -1
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def to_string(self):
|
2009-07-16 16:33:31 +00:00
|
|
|
# Make sure &string works, too.
|
|
|
|
type = self.val.type
|
|
|
|
if type.code == gdb.TYPE_CODE_REF:
|
|
|
|
type = type.target ()
|
|
|
|
|
|
|
|
# Calculate the length of the string so that to_string returns
|
|
|
|
# the string according to length, not according to first null
|
|
|
|
# encountered.
|
|
|
|
ptr = self.val ['_M_dataplus']['_M_p']
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
if self.new_string:
|
|
|
|
length = self.val['_M_string_length']
|
|
|
|
# https://sourceware.org/bugzilla/show_bug.cgi?id=17728
|
|
|
|
ptr = ptr.cast(ptr.type.strip_typedefs())
|
|
|
|
else:
|
|
|
|
realtype = type.unqualified ().strip_typedefs ()
|
|
|
|
reptype = gdb.lookup_type (str (realtype) + '::_Rep').pointer ()
|
|
|
|
header = ptr.cast(reptype) - 1
|
|
|
|
length = header.dereference ()['_M_length']
|
2010-10-08 11:31:56 +00:00
|
|
|
if hasattr(ptr, "lazy_string"):
|
New std::string implementation.
* acinclude.m4 (GLIBCXX_ENABLE_LIBSTDCXX_CXX11_ABI): Remove.
(GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI, GLIBCXX_DEFAULT_ABI): Add.
* configure.ac: Use new macros.
* configure: Regenerate.
* Makefile.in: Regenerate.
* doc/Makefile.in: Regenerate.
* libsupc++/Makefile.in: Regenerate.
* po/Makefile.in: Regenerate.
* src/Makefile.in: Regenerate.
* testsuite/Makefile.in: Regenerate.
* include/Makefile.am: Set _GLIBCXX_USE_DUAL_ABI.
* include/Makefile.in: Regenerate.
* config/abi/pre/gnu.ver: Export symbols related to new std::string.
Tighten old patterns to not match new symbols.
* config/locale/generic/monetary_members.cc: Guard some definitions
to not compile with new ABI.
* config/locale/gnu/monetary_members.cc: Likewise.
* config/locale/gnu/numeric_members.cc: Prevent double-free.
* config/os/gnu-linux/ldbl-extra.ver: Add new __gnu_cxx_ldbl128
exports. Tighten old patterns.
* doc/xml/manual/configure.xml: Document new configure options.
* doc/html/*: Regenerate.
* include/bits/basic_string.h (__cxx11::basic_string): Define new
non-reference-counted implementation in inline namespace __cxx11.
(stoi, stol, stoll, stof, stod, stold, to_string): Conditionally use
inline namespace.
(literals::string_literals::operator"): Conditionally use abi-tag.
* include/bits/basic_string.tcc (__cxx11::basic_string): Define.
* include/bits/c++config: Define _GLIBCXX_USE_DUAL_ABI and
LDBL_CXX11_ABI namespace macros.
* include/bits/locale_classes.h (locale::name()): Use abi_tag when
new ABI is in use.
(locale::_S_twinned_facets): New static member.
(locale::facet::__shim): Declare new type.
(locale::_facet::_M_sso_shim, locale::_facet::_M_cow_shim): New
functions for creating shims.
(locale::_Impl::_M_facet_unchecked): New member function for use
during construction.
(locale::_Impl::_M_init_extra): New member functions to create second
version of some facets.
(collate, collate_byname): Use abi_tag when new ABI is in use.
* include/bits/locale_facets.h: Add _GLIBCXX_NUM_CXX11_FACETS macro.
(numpunct, numpunct_byname): Use __cxx11 namespace.
(num_get::_M_extract_float, num_get::_M_extract_int): Use abi_tag
when new ABI is in use.
(num_get::__do_get, num_put::__do_put): Do not declare long double
compat functions for new ABI.
* include/bits/locale_facets.tcc (num_get, num_put): Use abi_tag on
definitions.
(numpunct, numpunct_byname): Qualify explicit instantiations.
* include/bits/locale_facets_nonio.h (time_get, time_get_byname,
moneypunct, moneypunct_byname, money_get, money_put, messages,
messages_byname): Use new inline namespace macros.
(money_get::__do_get, money_put::__do_put): Do not declare long
double compat functions for new ABI.
* include/bits/locale_facets_nonio.tcc (money_get, money_put): Use
new namespace macros.
(money_get::__do_get, money_put::__do_put): Do not define for new ABI.
* include/bits/localefwd.h (numpunct, numpunct_byname, collate,
collate_byname, time_get, time_get_byname, moneypunct,
moneypunct_byname, money_get, money_put, messages, messages_byname):
Use new namespace macros.
* include/bits/regex.h: Use inline namespace macros.
* include/bits/stl_list.h (_List_base, list): Use inline namespace
instead of abi-tag.
* include/bits/stringfwd.h (basic_string): Use namespace macros.
* include/std/iosfwd (basic_stringbuf, basic_istringstream,
basic_ostringstream, basic_stringstream): Likewise.
* include/std/sstream: Likewise.
(basic_stringbuf::__xfer_bufptrs): Update streambuf pointers on move.
* include/std/stdexcept (__cow_string, __sso_string): New types for
indirectly using std::string with either ABI.
(logic_error, runtime_error): Replace std::string member with
__cow_string when new ABI is in use. Declare non-inline copy
constructor and assignment operator. Declare const char* constructors.
(domain_error, invalid_argument, length_error, out_of_range,
range_error, overflow_error, underflow_error): Declare const char*
constructors.
* include/std/system_error (error_category): Replace with new
definition in inline namespace _V2.
(error_code::message, error_condition::message): Use abi_tag on
functions returning std::string.
* python/libstdcxx/v6/printers.py (StdStringPrinter): Handle new ABI.
* src/c++11/Makefile.am: Add new files.
* src/c++11/Makefile.in: Regenerate.
* src/c++11/compatibility-c++0x.cc: Compile with old std::string ABI.
Define old error_category symbols.
* src/c++11/cow-fstream-inst.cc: New. Instantiate fstream members
using old std::string ABI.
* src/c++11/cow-locale_init.cc (locale::_Impl::_M_init_extra): Define.
* src/c++11/cow-shim_facets.cc: Define shim facets using old ABI.
* src/c++11/cow-sstream-inst.cc: Instantiate stringstreams using old
std::string ABI.
* src/c++11/cow-stdexcept.cc: Define new constructors and assignment
operators.
(__cow_string, error_category::_M_message): Define.
* src/c++11/cow-string-inst.cc: Explicit instantiations using old
std::string. Include src/c++98/istream-string.cc.
* src/c++11/cow-wstring-inst.cc: Explicit instantiations using old
std::wstring.
* src/c++11/cxx11-hash_tr1.cc: Explicit instantiations using new
string.
* src/c++11/cxx11-ios_failure.cc: Add sanity check.
* src/c++11/cxx11-locale-inst.cc: Instantiate facets using new
std::string.
* src/c++11/cxx11-shim_facets.cc: Define shim facets using new ABI.
* src/c++11/cxx11-stdexcept.cc: Define constructors taking new
std::string.
* src/c++11/cxx11-wlocale-inst.cc: Instantiate facets using
new std::wstring.
* src/c++11/fstream-inst.cc: Compile with new ABI.
* src/c++11/functexcept.cc: Compile with old ABI.
* src/c++11/random.cc: Compile with new ABI.
* src/c++11/sstream-inst.cc: Compile with new ABI.
* src/c++11/string-inst.cc: Explicit instantiations for new string.
* src/c++11/system_error.cc (__sso_string, error_category::_M_message):
Define.
* src/c++11/wstring-inst.cc: Compile with new ABI.
* src/c++98/Makefile.am: Compile some host files twice for old and
new std::string. Add new files.
* src/c++98/Makefile.in: Regenerate.
* src/c++98/compatibility-ldbl.cc: Compile with old ABI.
* src/c++98/compatibility.cc: Likewise.
* src/c++98/concept-inst.cc: Likewise.
* src/c++98/hash_tr1.cc: Likewise.
* src/c++98/istream-string.cc: New file defining functions that
work with istream and std::string moved from ...
* src/c++98/istream.cc: ... here.
* src/c++98/cow-istream-string.cc: Recompile istream-string.cc with
old ABI.
* src/c++98/locale-inst.cc: Adjust facet instantiations to work for
either ABI.
* src/c++98/locale.cc (locale::_M_install_facet,
locale::_M_install_cache): Handle twinned facets.
* src/c++98/locale-facets.cc: Compile with old std::string ABI.
(__verify_grouping): Define new overload and old std::string version.
* src/c++98/locale_init.cc: Initialize twinned facets.
* src/c++98/localename.cc: Likewise.
* src/c++98/misc-inst.cc: Instantiate C++98-only std::string members.
(__verify_grouping): Define new std::string version.
* src/c++98/stdexcept.cc: Compile with old std::string ABI.
* src/c++98/wlocale-inst.cc: Likewise.
* testsuite/18_support/50594.cc: Adjust to work with SSO strings.
* testsuite/21_strings/basic_string/capacity/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/18654.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/char/2.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/1.cc: Likewise.
* testsuite/21_strings/basic_string/capacity/wchar_t/18654.cc:
Likewise.
* testsuite/21_strings/headers/string/synopsis.cc: Use inline
namespace macros.
* testsuite/23_containers/headers/list/synopsis.cc: Likewise.
* testsuite/27_io/basic_ios/copyfmt/char/1.cc: Set dg-options so
correct exception type can be caught.
* testsuite/27_io/basic_ios/exceptions/char/1.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/char/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_arithmetic/wchar_t/
exceptions_failbit.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/char/12297.cc: Likewise.
* testsuite/27_io/basic_istream/sentry/wchar_t/12297.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/
exceptions_null.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/
exceptions_null.cc: Likewise.
* testsuite/27_io/ios_base/storage/2.cc: Likewise.
* testsuite/27_io/ios_base/failure/cxx11.cc: Disable for old ABI.
* testsuite/ext/profile/mutex_extensions_neg.cc: Adjust dg-error.
* testsuite/libstdc++-prettyprinters/libfundts.cc: Use old ABI.
* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
* testsuite/util/exception/safety.h: Adjust member function types
for new std::string.
* testsuite/util/testsuite_abi.cc: Add new version and ignore
__float128 symbols in __cxx11 namespace.
From-SVN: r218964
2014-12-19 18:16:39 +00:00
|
|
|
return ptr.lazy_string (length = length)
|
|
|
|
return ptr.string (length = length)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def display_hint (self):
|
|
|
|
return 'string'
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class Tr1HashtableIterator(Iterator):
|
2019-11-29 14:47:03 +00:00
|
|
|
def __init__ (self, hashtable):
|
|
|
|
self.buckets = hashtable['_M_buckets']
|
2013-05-15 19:39:18 +00:00
|
|
|
self.bucket = 0
|
2019-11-29 14:47:03 +00:00
|
|
|
self.bucket_count = hashtable['_M_bucket_count']
|
|
|
|
self.node_type = find_type(hashtable.type, '_Node').pointer()
|
2013-05-15 19:39:18 +00:00
|
|
|
self.node = 0
|
|
|
|
while self.bucket != self.bucket_count:
|
|
|
|
self.node = self.buckets[self.bucket]
|
|
|
|
if self.node:
|
|
|
|
break
|
2018-11-23 16:12:03 +00:00
|
|
|
self.bucket = self.bucket + 1
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def __iter__ (self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__ (self):
|
2012-02-14 20:38:39 +00:00
|
|
|
if self.node == 0:
|
2009-05-28 17:14:18 +00:00
|
|
|
raise StopIteration
|
2012-02-14 20:38:39 +00:00
|
|
|
node = self.node.cast(self.node_type)
|
|
|
|
result = node.dereference()['_M_v']
|
2013-05-15 19:39:18 +00:00
|
|
|
self.node = node.dereference()['_M_next'];
|
|
|
|
if self.node == 0:
|
|
|
|
self.bucket = self.bucket + 1
|
|
|
|
while self.bucket != self.bucket_count:
|
|
|
|
self.node = self.buckets[self.bucket]
|
|
|
|
if self.node:
|
|
|
|
break
|
|
|
|
self.bucket = self.bucket + 1
|
2009-05-28 17:14:18 +00:00
|
|
|
return result
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class StdHashtableIterator(Iterator):
|
2019-11-29 14:47:03 +00:00
|
|
|
def __init__(self, hashtable):
|
|
|
|
self.node = hashtable['_M_before_begin']['_M_nxt']
|
|
|
|
valtype = hashtable.type.template_argument(1)
|
|
|
|
cached = hashtable.type.template_argument(9).template_argument(0)
|
|
|
|
node_type = lookup_templ_spec('std::__detail::_Hash_node', str(valtype),
|
|
|
|
'true' if cached else 'false')
|
|
|
|
self.node_type = node_type.pointer()
|
2013-05-15 19:39:18 +00:00
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2013-05-15 19:39:18 +00:00
|
|
|
if self.node == 0:
|
|
|
|
raise StopIteration
|
|
|
|
elt = self.node.cast(self.node_type).dereference()
|
|
|
|
self.node = elt['_M_nxt']
|
|
|
|
valptr = elt['_M_storage'].address
|
|
|
|
valptr = valptr.cast(elt.type.template_argument(0).pointer())
|
|
|
|
return valptr.dereference()
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
class Tr1UnorderedSetPrinter:
|
2019-11-29 14:47:03 +00:00
|
|
|
"Print a std::unordered_set or tr1::unordered_set"
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
2012-10-28 13:20:31 +00:00
|
|
|
def hashtable (self):
|
|
|
|
if self.typename.startswith('std::tr1'):
|
|
|
|
return self.val
|
|
|
|
return self.val['_M_h']
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
def to_string (self):
|
2016-12-14 16:07:29 +00:00
|
|
|
count = self.hashtable()['_M_element_count']
|
|
|
|
return '%s with %s' % (self.typename, num_elements(count))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def format_count (i):
|
|
|
|
return '[%d]' % i
|
|
|
|
|
|
|
|
def children (self):
|
2014-07-11 13:43:07 +00:00
|
|
|
counter = imap (self.format_count, itertools.count())
|
2013-05-15 19:39:18 +00:00
|
|
|
if self.typename.startswith('std::tr1'):
|
2014-07-11 13:43:07 +00:00
|
|
|
return izip (counter, Tr1HashtableIterator (self.hashtable()))
|
|
|
|
return izip (counter, StdHashtableIterator (self.hashtable()))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
class Tr1UnorderedMapPrinter:
|
2019-11-29 14:47:03 +00:00
|
|
|
"Print a std::unordered_map or tr1::unordered_map"
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2009-05-28 17:14:18 +00:00
|
|
|
self.val = val
|
|
|
|
|
2012-10-28 13:20:31 +00:00
|
|
|
def hashtable (self):
|
|
|
|
if self.typename.startswith('std::tr1'):
|
|
|
|
return self.val
|
|
|
|
return self.val['_M_h']
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
def to_string (self):
|
2016-12-14 16:07:29 +00:00
|
|
|
count = self.hashtable()['_M_element_count']
|
|
|
|
return '%s with %s' % (self.typename, num_elements(count))
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def flatten (list):
|
|
|
|
for elt in list:
|
|
|
|
for i in elt:
|
|
|
|
yield i
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def format_one (elt):
|
|
|
|
return (elt['first'], elt['second'])
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def format_count (i):
|
|
|
|
return '[%d]' % i
|
|
|
|
|
|
|
|
def children (self):
|
2014-07-11 13:43:07 +00:00
|
|
|
counter = imap (self.format_count, itertools.count())
|
2009-05-28 17:14:18 +00:00
|
|
|
# Map over the hash table and flatten the result.
|
2013-05-15 19:39:18 +00:00
|
|
|
if self.typename.startswith('std::tr1'):
|
2014-07-11 13:43:07 +00:00
|
|
|
data = self.flatten (imap (self.format_one, Tr1HashtableIterator (self.hashtable())))
|
2013-05-15 19:39:18 +00:00
|
|
|
# Zip the two iterators together.
|
2014-07-11 13:43:07 +00:00
|
|
|
return izip (counter, data)
|
|
|
|
data = self.flatten (imap (self.format_one, StdHashtableIterator (self.hashtable())))
|
2009-05-28 17:14:18 +00:00
|
|
|
# Zip the two iterators together.
|
2014-07-11 13:43:07 +00:00
|
|
|
return izip (counter, data)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
def display_hint (self):
|
|
|
|
return 'map'
|
|
|
|
|
2012-01-08 12:34:00 +00:00
|
|
|
class StdForwardListPrinter:
|
|
|
|
"Print a std::forward_list"
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
class _iterator(Iterator):
|
2012-01-08 12:34:00 +00:00
|
|
|
def __init__(self, nodetype, head):
|
|
|
|
self.nodetype = nodetype
|
|
|
|
self.base = head['_M_next']
|
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
2014-07-11 13:43:07 +00:00
|
|
|
def __next__(self):
|
2012-01-08 12:34:00 +00:00
|
|
|
if self.base == 0:
|
|
|
|
raise StopIteration
|
|
|
|
elt = self.base.cast(self.nodetype).dereference()
|
|
|
|
self.base = elt['_M_next']
|
|
|
|
count = self.count
|
|
|
|
self.count = self.count + 1
|
2012-11-02 01:47:17 +00:00
|
|
|
valptr = elt['_M_storage'].address
|
|
|
|
valptr = valptr.cast(elt.type.template_argument(0).pointer())
|
|
|
|
return ('[%d]' % count, valptr.dereference())
|
2012-01-08 12:34:00 +00:00
|
|
|
|
|
|
|
def __init__(self, typename, val):
|
|
|
|
self.val = val
|
2017-01-10 12:38:42 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
2012-01-08 12:34:00 +00:00
|
|
|
|
|
|
|
def children(self):
|
2019-11-29 14:47:03 +00:00
|
|
|
nodetype = lookup_node_type('_Fwd_list_node', self.val.type).pointer()
|
2012-01-08 12:34:00 +00:00
|
|
|
return self._iterator(nodetype, self.val['_M_impl']['_M_head'])
|
|
|
|
|
|
|
|
def to_string(self):
|
|
|
|
if self.val['_M_impl']['_M_head']['_M_next'] == 0:
|
2016-12-15 12:45:47 +00:00
|
|
|
return 'empty %s' % self.typename
|
|
|
|
return '%s' % self.typename
|
2012-01-08 12:34:00 +00:00
|
|
|
|
2014-07-15 13:00:18 +01:00
|
|
|
class SingleObjContainerPrinter(object):
|
|
|
|
"Base class for printers of containers of single objects"
|
|
|
|
|
2016-09-19 16:49:27 +01:00
|
|
|
def __init__ (self, val, viz, hint = None):
|
2014-07-15 13:00:18 +01:00
|
|
|
self.contained_value = val
|
|
|
|
self.visualizer = viz
|
2016-09-19 16:49:27 +01:00
|
|
|
self.hint = hint
|
2014-07-15 13:00:18 +01:00
|
|
|
|
|
|
|
def _recognize(self, type):
|
|
|
|
"""Return TYPE as a string after applying type printers"""
|
2014-07-18 16:56:00 +01:00
|
|
|
global _use_type_printing
|
|
|
|
if not _use_type_printing:
|
|
|
|
return str(type)
|
2014-07-15 13:00:18 +01:00
|
|
|
return gdb.types.apply_type_recognizers(gdb.types.get_type_recognizers(),
|
|
|
|
type) or str(type)
|
|
|
|
|
2014-07-29 22:35:57 +01:00
|
|
|
class _contained(Iterator):
|
2014-07-15 13:00:18 +01:00
|
|
|
def __init__ (self, val):
|
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def __iter__ (self):
|
|
|
|
return self
|
|
|
|
|
2014-07-29 22:35:57 +01:00
|
|
|
def __next__(self):
|
2014-07-15 13:00:18 +01:00
|
|
|
if self.val is None:
|
|
|
|
raise StopIteration
|
|
|
|
retval = self.val
|
|
|
|
self.val = None
|
|
|
|
return ('[contained value]', retval)
|
|
|
|
|
|
|
|
def children (self):
|
|
|
|
if self.contained_value is None:
|
|
|
|
return self._contained (None)
|
|
|
|
if hasattr (self.visualizer, 'children'):
|
|
|
|
return self.visualizer.children ()
|
|
|
|
return self._contained (self.contained_value)
|
|
|
|
|
|
|
|
def display_hint (self):
|
|
|
|
# if contained value is a map we want to display in the same way
|
|
|
|
if hasattr (self.visualizer, 'children') and hasattr (self.visualizer, 'display_hint'):
|
|
|
|
return self.visualizer.display_hint ()
|
2016-09-19 16:49:27 +01:00
|
|
|
return self.hint
|
2014-07-15 13:00:18 +01:00
|
|
|
|
|
|
|
class StdExpAnyPrinter(SingleObjContainerPrinter):
|
2016-09-17 16:20:23 +01:00
|
|
|
"Print a std::any or std::experimental::any"
|
2014-07-15 13:00:18 +01:00
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
2017-11-01 17:52:05 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
|
|
|
self.typename = re.sub('^std::experimental::fundamentals_v\d::', 'std::experimental::', self.typename, 1)
|
2014-07-15 13:00:18 +01:00
|
|
|
self.val = val
|
|
|
|
self.contained_type = None
|
|
|
|
contained_value = None
|
|
|
|
visualizer = None
|
|
|
|
mgr = self.val['_M_manager']
|
|
|
|
if mgr != 0:
|
|
|
|
func = gdb.block_for_pc(int(mgr.cast(gdb.lookup_type('intptr_t'))))
|
|
|
|
if not func:
|
2016-09-17 16:20:23 +01:00
|
|
|
raise ValueError("Invalid function pointer in %s" % self.typename)
|
2018-11-23 15:48:56 +00:00
|
|
|
rx = r"""({0}::_Manager_\w+<.*>)::_S_manage\((enum )?{0}::_Op, (const {0}|{0} const) ?\*, (union )?{0}::_Arg ?\*\)""".format(typename)
|
2014-07-15 13:00:18 +01:00
|
|
|
m = re.match(rx, func.function.name)
|
|
|
|
if not m:
|
2016-09-17 16:20:23 +01:00
|
|
|
raise ValueError("Unknown manager function in %s" % self.typename)
|
2014-07-15 13:00:18 +01:00
|
|
|
|
2017-01-10 12:38:42 +00:00
|
|
|
mgrname = m.group(1)
|
2014-07-15 13:00:18 +01:00
|
|
|
# FIXME need to expand 'std::string' so that gdb.lookup_type works
|
2017-01-10 12:38:42 +00:00
|
|
|
if 'std::string' in mgrname:
|
|
|
|
mgrname = re.sub("std::string(?!\w)", str(gdb.lookup_type('std::string').strip_typedefs()), m.group(1))
|
|
|
|
|
2014-07-15 13:00:18 +01:00
|
|
|
mgrtype = gdb.lookup_type(mgrname)
|
|
|
|
self.contained_type = mgrtype.template_argument(0)
|
|
|
|
valptr = None
|
|
|
|
if '::_Manager_internal' in mgrname:
|
|
|
|
valptr = self.val['_M_storage']['_M_buffer'].address
|
|
|
|
elif '::_Manager_external' in mgrname:
|
|
|
|
valptr = self.val['_M_storage']['_M_ptr']
|
|
|
|
else:
|
2016-09-17 16:20:23 +01:00
|
|
|
raise ValueError("Unknown manager function in %s" % self.typename)
|
2014-07-15 13:00:18 +01:00
|
|
|
contained_value = valptr.cast(self.contained_type.pointer()).dereference()
|
|
|
|
visualizer = gdb.default_visualizer(contained_value)
|
|
|
|
super(StdExpAnyPrinter, self).__init__ (contained_value, visualizer)
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
if self.contained_type is None:
|
|
|
|
return '%s [no contained value]' % self.typename
|
|
|
|
desc = "%s containing " % self.typename
|
|
|
|
if hasattr (self.visualizer, 'children'):
|
|
|
|
return desc + self.visualizer.to_string ()
|
|
|
|
valtype = self._recognize (self.contained_type)
|
2017-01-10 12:38:42 +00:00
|
|
|
return desc + strip_versioned_namespace(str(valtype))
|
2014-07-15 13:00:18 +01:00
|
|
|
|
|
|
|
class StdExpOptionalPrinter(SingleObjContainerPrinter):
|
2016-09-17 16:20:23 +01:00
|
|
|
"Print a std::optional or std::experimental::optional"
|
2014-07-15 13:00:18 +01:00
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
|
|
|
valtype = self._recognize (val.type.template_argument(0))
|
PR libstdc++/87855 fix optional for types with non-trivial copy/move
When the contained value is not trivially copy (or move) constructible
the union's copy (or move) constructor will be deleted, and so the
_Optional_payload delegating constructors are invalid. G++ fails to
diagnose this because it incorrectly performs copy elision in the
delegating constructors. Clang does diagnose it (llvm.org/PR40245).
The solution is to avoid performing any copy (or move) when the
contained value's copy (or move) constructor isn't trivial. Instead the
contained value can be constructed by calling _M_construct. This is OK,
because the relevant constructor doesn't need to be constexpr when the
contained value isn't trivially copy (or move) constructible.
Additionally, this patch removes a lot of code duplication in the
_Optional_payload partial specializations and the _Optional_base partial
specialization, by hoisting it into common base classes.
The Python pretty printer for std::optional needs to be adjusted to
support the new layout. Retain support for the old layout, and add a
test to verify that the support still works.
PR libstdc++/87855
* include/std/optional (_Optional_payload_base): New class template
for common code hoisted from _Optional_payload specializations. Use
a template for the union, to allow a partial specialization for
types with non-trivial destructors. Add constructors for in-place
initialization to the union.
(_Optional_payload(bool, const _Optional_payload&)): Use _M_construct
to perform non-trivial copy construction, instead of relying on
non-standard copy elision in a delegating constructor.
(_Optional_payload(bool, _Optional_payload&&)): Likewise for
non-trivial move construction.
(_Optional_payload): Derive from _Optional_payload_base and use it
for everything except the non-trivial assignment operators, which are
defined as needed.
(_Optional_payload<false, C, M>): Derive from the specialization
_Optional_payload<true, false, false> and add a destructor.
(_Optional_base_impl::_M_destruct, _Optional_base_impl::_M_reset):
Forward to corresponding members of _Optional_payload.
(_Optional_base_impl::_M_is_engaged, _Optional_base_impl::_M_get):
Hoist common members from _Optional_base.
(_Optional_base): Make all members and base class public.
(_Optional_base::_M_get, _Optional_base::_M_is_engaged): Move to
_Optional_base_impl.
* python/libstdcxx/v6/printers.py (StdExpOptionalPrinter): Add
support for new std::optional layout.
* testsuite/libstdc++-prettyprinters/compat.cc: New test.
From-SVN: r267742
2019-01-08 23:00:46 +00:00
|
|
|
typename = strip_versioned_namespace(typename)
|
|
|
|
self.typename = re.sub('^std::(experimental::|)(fundamentals_v\d::|)(.*)', r'std::\1\3<%s>' % valtype, typename, 1)
|
|
|
|
payload = val['_M_payload']
|
|
|
|
if self.typename.startswith('std::experimental'):
|
|
|
|
engaged = val['_M_engaged']
|
|
|
|
contained_value = payload
|
|
|
|
else:
|
|
|
|
engaged = payload['_M_engaged']
|
|
|
|
contained_value = payload['_M_payload']
|
|
|
|
try:
|
|
|
|
# Since GCC 9
|
|
|
|
contained_value = contained_value['_M_value']
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
visualizer = gdb.default_visualizer (contained_value)
|
|
|
|
if not engaged:
|
|
|
|
contained_value = None
|
2014-07-15 13:00:18 +01:00
|
|
|
super (StdExpOptionalPrinter, self).__init__ (contained_value, visualizer)
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
if self.contained_value is None:
|
2016-12-15 12:45:47 +00:00
|
|
|
return "%s [no contained value]" % self.typename
|
2014-07-15 13:00:18 +01:00
|
|
|
if hasattr (self.visualizer, 'children'):
|
2016-12-15 12:45:47 +00:00
|
|
|
return "%s containing %s" % (self.typename,
|
|
|
|
self.visualizer.to_string())
|
2014-07-15 13:00:18 +01:00
|
|
|
return self.typename
|
|
|
|
|
2016-09-17 16:20:23 +01:00
|
|
|
class StdVariantPrinter(SingleObjContainerPrinter):
|
|
|
|
"Print a std::variant"
|
|
|
|
|
|
|
|
def __init__(self, typename, val):
|
2018-01-15 11:13:53 +00:00
|
|
|
alternatives = get_template_arg_list(val.type)
|
2017-11-01 17:52:05 +00:00
|
|
|
self.typename = strip_versioned_namespace(typename)
|
|
|
|
self.typename = "%s<%s>" % (self.typename, ', '.join([self._recognize(alt) for alt in alternatives]))
|
2016-09-17 16:20:23 +01:00
|
|
|
self.index = val['_M_index']
|
|
|
|
if self.index >= len(alternatives):
|
|
|
|
self.contained_type = None
|
|
|
|
contained_value = None
|
|
|
|
visualizer = None
|
|
|
|
else:
|
|
|
|
self.contained_type = alternatives[int(self.index)]
|
2016-12-06 14:36:07 +00:00
|
|
|
addr = val['_M_u']['_M_first']['_M_storage'].address
|
2016-09-17 16:20:23 +01:00
|
|
|
contained_value = addr.cast(self.contained_type.pointer()).dereference()
|
|
|
|
visualizer = gdb.default_visualizer(contained_value)
|
2016-09-19 16:49:27 +01:00
|
|
|
super (StdVariantPrinter, self).__init__(contained_value, visualizer, 'array')
|
2016-09-17 16:20:23 +01:00
|
|
|
|
|
|
|
def to_string(self):
|
|
|
|
if self.contained_value is None:
|
2016-09-19 16:49:27 +01:00
|
|
|
return "%s [no contained value]" % self.typename
|
2016-09-17 16:20:23 +01:00
|
|
|
if hasattr(self.visualizer, 'children'):
|
2016-12-15 12:45:47 +00:00
|
|
|
return "%s [index %d] containing %s" % (self.typename, self.index,
|
|
|
|
self.visualizer.to_string())
|
2016-09-19 16:49:27 +01:00
|
|
|
return "%s [index %d]" % (self.typename, self.index)
|
2016-09-17 16:20:23 +01:00
|
|
|
|
Implement C++17 node extraction and insertion (P0083R5)
* doc/xml/manual/status_cxx2017.xml: Document status.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/node_handle.h and reorder.
* include/Makefile.in: Regenerate.
* include/bits/hashtable.h (_Hashtable::node_type)
(_Hashtable::insert_return_type, _Hashtable::_M_reinsert_node)
(_Hashtable::_M_reinsert_node_multi, _Hashtable::extract)
(_Hashtable::_M_merge_unique, _Hashtable::_M_merge_multi): Define.
(_Hash_merge_helper): Define primary template.
* include/bits/node_handle.h: New header.
* include/bits/stl_map.h (map): Declare _Rb_tree_merge_helper as
friend.
(map::node_type, map::insert_return_type, map::extract, map::merge)
(map::insert(node_type&&), map::insert(const_iterator, node_type&&)):
Define new members.
(_Rb_tree_merge_helper): Specialize for map.
* include/bits/stl_multimap.h (multimap): Declare _Rb_tree_merge_helper
as friend.
(multimap::node_type, multimap::extract, multimap::merge)
(multimap::insert(node_type&&))
(multimap::insert(const_iterator, node_type&&)): Define.
(_Rb_tree_merge_helper): Specialize for multimap.
* include/bits/stl_multiset.h (multiset): Declare _Rb_tree_merge_helper
as friend.
(multiset::node_type, multiset::extract, multiset::merge)
(multiset::insert(node_type&&))
(multiset::insert(const_iterator, node_type&&)): Define.
* include/bits/stl_set.h (set): Declare _Rb_tree_merge_helper as
friend.
(set::node_type, set::insert_return_type, set::extract, set::merge)
(set::insert(node_type&&), set::insert(const_iterator, node_type&&)):
Define.
(_Rb_tree_merge_helper): Specialize for set.
* include/bits/stl_tree.h (_Rb_tree): Declare _Rb_tree<> as friend.
(_Rb_tree::node_type, _Rb_tree::insert_return_type)
(_Rb_tree::_M_reinsert_node_unique, _Rb_tree::_M_reinsert_node_equal)
(_Rb_tree::_M_reinsert_node_hint_unique)
(_Rb_tree::_M_reinsert_node_hint_equal, _Rb_tree::extract)
(_Rb_tree::_M_merge_unique, _Rb_tree::_M_merge_equal): Define.
(_Rb_tree_merge_helper): Specialize for multiset.
* include/bits/unordered_map.h (unordered_map): Declare
unordered_map<> and unordered_multimap<> as friends.
(unordered_map::node_type, unordered_map::insert_return_type)
(unordered_map::extract, unordered_map::merge)
(unordered_map::insert(node_type&&))
(unordered_map::insert(const_iterator, node_type&&))
(unordered_multimap): Declare _Hash_merge_helper as friend.
(unordered_multimap::node_type, unordered_multimap::extract)
(unordered_multimap::merge, unordered_multimap::insert(node_type&&))
(unordered_multimap::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered maps and multimaps.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Declare _Hash_merge_helper as friend.
(unordered_set::node_type, unordered_set::insert_return_type)
(unordered_set::extract, unordered_set::merge)
(unordered_set::insert(node_type&&))
(unordered_set::insert(const_iterator, node_type&&)): Define.
(unordered_multiset::node_type, unordered_multiset::extract)
(unordered_multiset::merge, unordered_multiset::insert(node_type&&))
(unordered_multiset::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered sets and multisets.
* include/debug/map.h (map): Add using declarations or forwarding
functions for new members.
* include/debug/map.h (multimap): Likewise.
* include/debug/map.h (multiset): Likewise.
* include/debug/map.h (set): Likewise.
* include/debug/unordered_map (unordered_map, unordered_multimap):
Likewise.
* include/debug/unordered_set( unordered_set, unordered_multiset):
Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_aligned_membuf): New
helper function.
(get_value_from_list_node, get_value_from_Rb_tree_node): Use helper.
(StdNodeHandlePrinter): Define printer for node handles.
(build_libstdcxx_dictionary): Register StdNodeHandlePrinter.
* testsuite/23_containers/map/modifiers/extract.cc: New.
* testsuite/23_containers/map/modifiers/merge.cc: New.
* testsuite/23_containers/multimap/modifiers/extract.cc: New.
* testsuite/23_containers/multimap/modifiers/merge.cc: New.
* testsuite/23_containers/multiset/modifiers/extract.cc: New.
* testsuite/23_containers/multiset/modifiers/merge.cc: New.
* testsuite/23_containers/set/modifiers/extract.cc: New.
* testsuite/23_containers/set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_map/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_map/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multimap/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multiset/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
dg-error lineno.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test node handles.
From-SVN: r240363
2016-09-22 14:58:49 +01:00
|
|
|
class StdNodeHandlePrinter(SingleObjContainerPrinter):
|
|
|
|
"Print a container node handle"
|
|
|
|
|
|
|
|
def __init__(self, typename, val):
|
|
|
|
self.value_type = val.type.template_argument(1)
|
|
|
|
nodetype = val.type.template_argument(2).template_argument(0)
|
2017-01-10 12:38:42 +00:00
|
|
|
self.is_rb_tree_node = is_specialization_of(nodetype.name, '_Rb_tree_node')
|
Implement C++17 node extraction and insertion (P0083R5)
* doc/xml/manual/status_cxx2017.xml: Document status.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/node_handle.h and reorder.
* include/Makefile.in: Regenerate.
* include/bits/hashtable.h (_Hashtable::node_type)
(_Hashtable::insert_return_type, _Hashtable::_M_reinsert_node)
(_Hashtable::_M_reinsert_node_multi, _Hashtable::extract)
(_Hashtable::_M_merge_unique, _Hashtable::_M_merge_multi): Define.
(_Hash_merge_helper): Define primary template.
* include/bits/node_handle.h: New header.
* include/bits/stl_map.h (map): Declare _Rb_tree_merge_helper as
friend.
(map::node_type, map::insert_return_type, map::extract, map::merge)
(map::insert(node_type&&), map::insert(const_iterator, node_type&&)):
Define new members.
(_Rb_tree_merge_helper): Specialize for map.
* include/bits/stl_multimap.h (multimap): Declare _Rb_tree_merge_helper
as friend.
(multimap::node_type, multimap::extract, multimap::merge)
(multimap::insert(node_type&&))
(multimap::insert(const_iterator, node_type&&)): Define.
(_Rb_tree_merge_helper): Specialize for multimap.
* include/bits/stl_multiset.h (multiset): Declare _Rb_tree_merge_helper
as friend.
(multiset::node_type, multiset::extract, multiset::merge)
(multiset::insert(node_type&&))
(multiset::insert(const_iterator, node_type&&)): Define.
* include/bits/stl_set.h (set): Declare _Rb_tree_merge_helper as
friend.
(set::node_type, set::insert_return_type, set::extract, set::merge)
(set::insert(node_type&&), set::insert(const_iterator, node_type&&)):
Define.
(_Rb_tree_merge_helper): Specialize for set.
* include/bits/stl_tree.h (_Rb_tree): Declare _Rb_tree<> as friend.
(_Rb_tree::node_type, _Rb_tree::insert_return_type)
(_Rb_tree::_M_reinsert_node_unique, _Rb_tree::_M_reinsert_node_equal)
(_Rb_tree::_M_reinsert_node_hint_unique)
(_Rb_tree::_M_reinsert_node_hint_equal, _Rb_tree::extract)
(_Rb_tree::_M_merge_unique, _Rb_tree::_M_merge_equal): Define.
(_Rb_tree_merge_helper): Specialize for multiset.
* include/bits/unordered_map.h (unordered_map): Declare
unordered_map<> and unordered_multimap<> as friends.
(unordered_map::node_type, unordered_map::insert_return_type)
(unordered_map::extract, unordered_map::merge)
(unordered_map::insert(node_type&&))
(unordered_map::insert(const_iterator, node_type&&))
(unordered_multimap): Declare _Hash_merge_helper as friend.
(unordered_multimap::node_type, unordered_multimap::extract)
(unordered_multimap::merge, unordered_multimap::insert(node_type&&))
(unordered_multimap::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered maps and multimaps.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Declare _Hash_merge_helper as friend.
(unordered_set::node_type, unordered_set::insert_return_type)
(unordered_set::extract, unordered_set::merge)
(unordered_set::insert(node_type&&))
(unordered_set::insert(const_iterator, node_type&&)): Define.
(unordered_multiset::node_type, unordered_multiset::extract)
(unordered_multiset::merge, unordered_multiset::insert(node_type&&))
(unordered_multiset::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered sets and multisets.
* include/debug/map.h (map): Add using declarations or forwarding
functions for new members.
* include/debug/map.h (multimap): Likewise.
* include/debug/map.h (multiset): Likewise.
* include/debug/map.h (set): Likewise.
* include/debug/unordered_map (unordered_map, unordered_multimap):
Likewise.
* include/debug/unordered_set( unordered_set, unordered_multiset):
Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_aligned_membuf): New
helper function.
(get_value_from_list_node, get_value_from_Rb_tree_node): Use helper.
(StdNodeHandlePrinter): Define printer for node handles.
(build_libstdcxx_dictionary): Register StdNodeHandlePrinter.
* testsuite/23_containers/map/modifiers/extract.cc: New.
* testsuite/23_containers/map/modifiers/merge.cc: New.
* testsuite/23_containers/multimap/modifiers/extract.cc: New.
* testsuite/23_containers/multimap/modifiers/merge.cc: New.
* testsuite/23_containers/multiset/modifiers/extract.cc: New.
* testsuite/23_containers/multiset/modifiers/merge.cc: New.
* testsuite/23_containers/set/modifiers/extract.cc: New.
* testsuite/23_containers/set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_map/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_map/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multimap/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multiset/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
dg-error lineno.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test node handles.
From-SVN: r240363
2016-09-22 14:58:49 +01:00
|
|
|
self.is_map_node = val.type.template_argument(0) != self.value_type
|
|
|
|
nodeptr = val['_M_ptr']
|
|
|
|
if nodeptr:
|
|
|
|
if self.is_rb_tree_node:
|
|
|
|
contained_value = get_value_from_Rb_tree_node(nodeptr.dereference())
|
|
|
|
else:
|
|
|
|
contained_value = get_value_from_aligned_membuf(nodeptr['_M_storage'],
|
|
|
|
self.value_type)
|
|
|
|
visualizer = gdb.default_visualizer(contained_value)
|
|
|
|
else:
|
|
|
|
contained_value = None
|
|
|
|
visualizer = None
|
|
|
|
optalloc = val['_M_alloc']
|
|
|
|
self.alloc = optalloc['_M_payload'] if optalloc['_M_engaged'] else None
|
|
|
|
super(StdNodeHandlePrinter, self).__init__(contained_value, visualizer,
|
|
|
|
'array')
|
|
|
|
|
|
|
|
def to_string(self):
|
|
|
|
desc = 'node handle for '
|
|
|
|
if not self.is_rb_tree_node:
|
|
|
|
desc += 'unordered '
|
|
|
|
if self.is_map_node:
|
|
|
|
desc += 'map';
|
|
|
|
else:
|
|
|
|
desc += 'set';
|
|
|
|
|
|
|
|
if self.contained_value:
|
|
|
|
desc += ' with element'
|
|
|
|
if hasattr(self.visualizer, 'children'):
|
|
|
|
return "%s = %s" % (desc, self.visualizer.to_string())
|
|
|
|
return desc
|
|
|
|
else:
|
|
|
|
return 'empty %s' % desc
|
|
|
|
|
2014-07-15 13:00:18 +01:00
|
|
|
class StdExpStringViewPrinter:
|
2016-09-17 16:20:23 +01:00
|
|
|
"Print a std::basic_string_view or std::experimental::basic_string_view"
|
2014-07-15 13:00:18 +01:00
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
|
|
|
self.val = val
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
ptr = self.val['_M_str']
|
|
|
|
len = self.val['_M_len']
|
|
|
|
if hasattr (ptr, "lazy_string"):
|
|
|
|
return ptr.lazy_string (length = len)
|
|
|
|
return ptr.string (length = len)
|
|
|
|
|
|
|
|
def display_hint (self):
|
|
|
|
return 'string'
|
2012-01-08 12:34:00 +00:00
|
|
|
|
2015-04-30 20:11:52 +01:00
|
|
|
class StdExpPathPrinter:
|
|
|
|
"Print a std::experimental::filesystem::path"
|
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
|
|
|
self.val = val
|
2015-05-01 20:47:55 +01:00
|
|
|
start = self.val['_M_cmpts']['_M_impl']['_M_start']
|
|
|
|
finish = self.val['_M_cmpts']['_M_impl']['_M_finish']
|
|
|
|
self.num_cmpts = int (finish - start)
|
|
|
|
|
|
|
|
def _path_type(self):
|
|
|
|
t = str(self.val['_M_type'])
|
|
|
|
if t[-9:] == '_Root_dir':
|
|
|
|
return "root-directory"
|
|
|
|
if t[-10:] == '_Root_name':
|
|
|
|
return "root-name"
|
|
|
|
return None
|
2015-04-30 20:11:52 +01:00
|
|
|
|
|
|
|
def to_string (self):
|
2015-05-01 20:47:55 +01:00
|
|
|
path = "%s" % self.val ['_M_pathname']
|
|
|
|
if self.num_cmpts == 0:
|
|
|
|
t = self._path_type()
|
|
|
|
if t:
|
|
|
|
path = '%s [%s]' % (path, t)
|
|
|
|
return "filesystem::path %s" % path
|
|
|
|
|
|
|
|
class _iterator(Iterator):
|
|
|
|
def __init__(self, cmpts):
|
|
|
|
self.item = cmpts['_M_impl']['_M_start']
|
|
|
|
self.finish = cmpts['_M_impl']['_M_finish']
|
|
|
|
self.count = 0
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __next__(self):
|
|
|
|
if self.item == self.finish:
|
|
|
|
raise StopIteration
|
|
|
|
item = self.item.dereference()
|
|
|
|
count = self.count
|
|
|
|
self.count = self.count + 1
|
|
|
|
self.item = self.item + 1
|
|
|
|
path = item['_M_pathname']
|
|
|
|
t = StdExpPathPrinter(item.type.name, item)._path_type()
|
|
|
|
if not t:
|
|
|
|
t = count
|
|
|
|
return ('[%s]' % t, path)
|
|
|
|
|
|
|
|
def children(self):
|
|
|
|
return self._iterator(self.val['_M_cmpts'])
|
|
|
|
|
PR libstdc++/71044 optimize std::filesystem::path construction
This new implementation has a smaller footprint than the previous
implementation, due to replacing std::vector<_Cmpt> with a custom pimpl
type that only needs a single pointer. The _M_type enumeration is also
combined with the pimpl type, by using a tagged pointer, reducing
sizeof(path) further still.
Construction and modification of paths is now done more efficiently, by
splitting the input into a stack-based buffer of string_view objects
instead of a dynamically-allocated vector containing strings. Once the
final size is known only a single allocation is needed to reserve space
for it. The append and concat operations no longer require constructing
temporary path objects, nor re-parsing the entire native pathname.
This results in algorithmic improvements to path construction, and
working with large paths is much faster.
PR libstdc++/71044
* include/bits/fs_path.h (path::path(path&&)): Add noexcept when
appropriate. Move _M_cmpts instead of reparsing the native pathname.
(path::operator=(const path&)): Do not define as defaulted.
(path::operator/=, path::append): Call _M_append.
(path::concat): Call _M_concat.
(path::path(string_type, _Type): Change type of first parameter to
basic_string_view<value_type>.
(path::_M_append(basic_string_view<value_type>)): New member function.
(path::_M_concat(basic_string_view<value_type>)): New member function.
(_S_convert(value_type*, __null_terminated)): Return string view.
(_S_convert(const value_type*, __null_terminated)): Return string view.
(_S_convert(value_type*, value_type*))
(_S_convert(const value_type*, const value_type*)): Add overloads for
pairs of pointers.
(_S_convert(_InputIterator, __null_terminated)): Construct string_type
explicitly, for cases where _S_convert returns a string view.
(path::_S_is_dir_sep): Replace with non-member is_dir_sep.
(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
(path::_M_add_filename): Remove.
(path::_M_type()): New member function to replace _M_type data member.
(path::_List): Define new struct type instead of using std::vector.
(path::_Cmpt::_Cmpt(string_type, _Type, size_t)): Change type of
first parameter to basic_string_view<value_type>.
(path::operator+=(const path&)): Do not define inline.
(path::operator+=(const string_type&)): Call _M_concat.
(path::operator+=(const value_type*)): Likewise.
(path::operator+=(value_type)): Likewise.
(path::operator+=(basic_string_view<value_type>)): Likewise.
(path::operator/=(const path&)): Do not define inline.
(path::_M_append(path)): Remove.
* python/libstdcxx/v6/printers.py (StdPathPrinter): New printer that
understands the new path::_List type.
* src/filesystem/std-path.cc (is_dir_sep): New function to replace
path::_S_is_dir_sep.
(path::_Parser): New helper class to parse strings as paths.
(path::_List::_Impl): Define container type for path components.
(path::_List): Define members.
(path::operator=(const path&)): Define explicitly, to provide the
strong exception safety guarantee.
(path::operator/=(const path&)): Implement manually by processing
each component of the argument, rather than using _M_split_cmpts
to parse the entire string again.
(path::_M_append(string_type)): Likewise.
(path::operator+=(const path&)): Likewise.
(path::_M_concat(string_type)): Likewise.
(path::remove_filename()): Perform trim directly instead of calling
_M_trim().
(path::_M_split_cmpts()): Rewrite in terms of _Parser class.
(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
(path::_M_add_filename): Remove.
* testsuite/27_io/filesystem/path/append/source.cc: Test appending a
string view that aliases the path.
testsuite/27_io/filesystem/path/concat/strings.cc: Test concatenating
a string view that aliases the path.
From-SVN: r267106
2018-12-13 20:33:55 +00:00
|
|
|
class StdPathPrinter:
|
|
|
|
"Print a std::filesystem::path"
|
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
|
|
|
self.val = val
|
|
|
|
self.typename = typename
|
|
|
|
impl = self.val['_M_cmpts']['_M_impl']['_M_t']['_M_t']['_M_head_impl']
|
|
|
|
self.type = impl.cast(gdb.lookup_type('uintptr_t')) & 3
|
|
|
|
if self.type == 0:
|
|
|
|
self.impl = impl
|
|
|
|
else:
|
|
|
|
self.impl = None
|
|
|
|
|
|
|
|
def _path_type(self):
|
|
|
|
t = str(self.type.cast(gdb.lookup_type(self.typename + '::_Type')))
|
|
|
|
if t[-9:] == '_Root_dir':
|
|
|
|
return "root-directory"
|
|
|
|
if t[-10:] == '_Root_name':
|
|
|
|
return "root-name"
|
|
|
|
return None
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
path = "%s" % self.val ['_M_pathname']
|
|
|
|
if self.type != 0:
|
|
|
|
t = self._path_type()
|
|
|
|
if t:
|
|
|
|
path = '%s [%s]' % (path, t)
|
|
|
|
return "filesystem::path %s" % path
|
|
|
|
|
|
|
|
class _iterator(Iterator):
|
|
|
|
def __init__(self, impl, pathtype):
|
|
|
|
if impl:
|
|
|
|
# We can't access _Impl::_M_size because _Impl is incomplete
|
|
|
|
# so cast to int* to access the _M_size member at offset zero,
|
|
|
|
int_type = gdb.lookup_type('int')
|
|
|
|
cmpt_type = gdb.lookup_type(pathtype+'::_Cmpt')
|
|
|
|
char_type = gdb.lookup_type('char')
|
|
|
|
impl = impl.cast(int_type.pointer())
|
|
|
|
size = impl.dereference()
|
|
|
|
#self.capacity = (impl + 1).dereference()
|
|
|
|
if hasattr(gdb.Type, 'alignof'):
|
|
|
|
sizeof_Impl = max(2 * int_type.sizeof, cmpt_type.alignof)
|
|
|
|
else:
|
|
|
|
sizeof_Impl = 2 * int_type.sizeof
|
|
|
|
begin = impl.cast(char_type.pointer()) + sizeof_Impl
|
|
|
|
self.item = begin.cast(cmpt_type.pointer())
|
|
|
|
self.finish = self.item + size
|
|
|
|
self.count = 0
|
|
|
|
else:
|
|
|
|
self.item = None
|
|
|
|
self.finish = None
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __next__(self):
|
|
|
|
if self.item == self.finish:
|
|
|
|
raise StopIteration
|
|
|
|
item = self.item.dereference()
|
|
|
|
count = self.count
|
|
|
|
self.count = self.count + 1
|
|
|
|
self.item = self.item + 1
|
|
|
|
path = item['_M_pathname']
|
|
|
|
t = StdPathPrinter(item.type.name, item)._path_type()
|
|
|
|
if not t:
|
|
|
|
t = count
|
|
|
|
return ('[%s]' % t, path)
|
|
|
|
|
|
|
|
def children(self):
|
|
|
|
return self._iterator(self.impl, self.typename)
|
|
|
|
|
2015-04-30 20:11:52 +01:00
|
|
|
|
2018-07-31 23:31:20 +01:00
|
|
|
class StdPairPrinter:
|
|
|
|
"Print a std::pair object, with 'first' and 'second' as children"
|
|
|
|
|
|
|
|
def __init__(self, typename, val):
|
|
|
|
self.val = val
|
|
|
|
|
|
|
|
class _iter(Iterator):
|
|
|
|
"An iterator for std::pair types. Returns 'first' then 'second'."
|
|
|
|
|
|
|
|
def __init__(self, val):
|
|
|
|
self.val = val
|
|
|
|
self.which = 'first'
|
|
|
|
|
|
|
|
def __iter__(self):
|
|
|
|
return self
|
|
|
|
|
|
|
|
def __next__(self):
|
|
|
|
if self.which is None:
|
|
|
|
raise StopIteration
|
|
|
|
which = self.which
|
|
|
|
if which == 'first':
|
|
|
|
self.which = 'second'
|
|
|
|
else:
|
|
|
|
self.which = None
|
|
|
|
return (which, self.val[which])
|
|
|
|
|
|
|
|
def children(self):
|
|
|
|
return self._iter(self.val)
|
|
|
|
|
|
|
|
def to_string(self):
|
|
|
|
return None
|
|
|
|
|
2019-12-05 00:42:11 +00:00
|
|
|
class StdCmpCatPrinter:
|
|
|
|
"Print a comparison category object"
|
|
|
|
|
|
|
|
def __init__ (self, typename, val):
|
|
|
|
self.typename = typename[typename.rfind(':')+1:]
|
|
|
|
self.val = val['_M_value']
|
|
|
|
|
|
|
|
def to_string (self):
|
|
|
|
if self.typename == 'strong_ordering' and self.val == 0:
|
|
|
|
name = 'equal'
|
|
|
|
else:
|
2020-02-17 13:20:57 +00:00
|
|
|
names = {2:'unordered', -1:'less', 0:'equivalent', 1:'greater'}
|
2019-12-05 00:42:11 +00:00
|
|
|
name = names[int(self.val)]
|
|
|
|
return 'std::{}::{}'.format(self.typename, name)
|
2018-07-31 23:31:20 +01:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
# A "regular expression" printer which conforms to the
|
|
|
|
# "SubPrettyPrinter" protocol from gdb.printing.
|
|
|
|
class RxPrinter(object):
|
|
|
|
def __init__(self, name, function):
|
|
|
|
super(RxPrinter, self).__init__()
|
|
|
|
self.name = name
|
|
|
|
self.function = function
|
|
|
|
self.enabled = True
|
|
|
|
|
|
|
|
def invoke(self, value):
|
|
|
|
if not self.enabled:
|
|
|
|
return None
|
2013-08-20 19:20:42 +00:00
|
|
|
|
|
|
|
if value.type.code == gdb.TYPE_CODE_REF:
|
|
|
|
if hasattr(gdb.Value,"referenced_value"):
|
|
|
|
value = value.referenced_value()
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
return self.function(self.name, value)
|
|
|
|
|
|
|
|
# A pretty-printer that conforms to the "PrettyPrinter" protocol from
|
|
|
|
# gdb.printing. It can also be used directly as an old-style printer.
|
|
|
|
class Printer(object):
|
|
|
|
def __init__(self, name):
|
|
|
|
super(Printer, self).__init__()
|
|
|
|
self.name = name
|
|
|
|
self.subprinters = []
|
|
|
|
self.lookup = {}
|
|
|
|
self.enabled = True
|
2014-07-15 13:00:18 +01:00
|
|
|
self.compiled_rx = re.compile('^([a-zA-Z0-9_:]+)(<.*>)?$')
|
2011-03-14 20:29:23 +00:00
|
|
|
|
|
|
|
def add(self, name, function):
|
|
|
|
# A small sanity check.
|
|
|
|
# FIXME
|
2014-07-15 13:00:18 +01:00
|
|
|
if not self.compiled_rx.match(name):
|
2014-05-19 22:43:13 +01:00
|
|
|
raise ValueError('libstdc++ programming error: "%s" does not match' % name)
|
2011-03-14 20:29:23 +00:00
|
|
|
printer = RxPrinter(name, function)
|
|
|
|
self.subprinters.append(printer)
|
|
|
|
self.lookup[name] = printer
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2012-01-30 16:25:11 +00:00
|
|
|
# Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION.
|
|
|
|
def add_version(self, base, name, function):
|
|
|
|
self.add(base + name, function)
|
2017-01-10 12:38:42 +00:00
|
|
|
if _versioned_namespace:
|
2017-11-01 17:52:05 +00:00
|
|
|
vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' % _versioned_namespace, base)
|
|
|
|
self.add(vbase + name, function)
|
2012-01-30 16:25:11 +00:00
|
|
|
|
|
|
|
# Add a name using _GLIBCXX_BEGIN_NAMESPACE_CONTAINER.
|
|
|
|
def add_container(self, base, name, function):
|
|
|
|
self.add_version(base, name, function)
|
|
|
|
self.add_version(base + '__cxx1998::', name, function)
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
@staticmethod
|
|
|
|
def get_basic_type(type):
|
|
|
|
# If it points to a reference, get the reference.
|
|
|
|
if type.code == gdb.TYPE_CODE_REF:
|
|
|
|
type = type.target ()
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
# Get the unqualified type, stripped of typedefs.
|
|
|
|
type = type.unqualified ().strip_typedefs ()
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
return type.tag
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def __call__(self, val):
|
|
|
|
typename = self.get_basic_type(val.type)
|
|
|
|
if not typename:
|
|
|
|
return None
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
# All the types we match are template types, so we can use a
|
|
|
|
# dictionary.
|
|
|
|
match = self.compiled_rx.match(typename)
|
|
|
|
if not match:
|
|
|
|
return None
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
basename = match.group(1)
|
2013-08-20 19:20:42 +00:00
|
|
|
|
|
|
|
if val.type.code == gdb.TYPE_CODE_REF:
|
|
|
|
if hasattr(gdb.Value,"referenced_value"):
|
|
|
|
val = val.referenced_value()
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
if basename in self.lookup:
|
|
|
|
return self.lookup[basename].invoke(val)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
# Cannot find a pretty printer. Return None.
|
2009-05-28 17:14:18 +00:00
|
|
|
return None
|
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
libstdcxx_printer = None
|
|
|
|
|
2014-07-15 13:00:12 +01:00
|
|
|
class TemplateTypePrinter(object):
|
2016-12-15 12:45:47 +00:00
|
|
|
r"""
|
2018-01-15 11:13:53 +00:00
|
|
|
A type printer for class templates with default template arguments.
|
2014-07-15 13:00:12 +01:00
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
Recognizes specializations of class templates and prints them without
|
|
|
|
any template arguments that use a default template argument.
|
|
|
|
Type printers are recursively applied to the template arguments.
|
2014-07-15 13:00:12 +01:00
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
e.g. replace "std::vector<T, std::allocator<T> >" with "std::vector<T>".
|
2014-07-15 13:00:12 +01:00
|
|
|
"""
|
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
def __init__(self, name, defargs):
|
2014-07-15 13:00:12 +01:00
|
|
|
self.name = name
|
2018-01-15 11:13:53 +00:00
|
|
|
self.defargs = defargs
|
2014-07-15 13:00:12 +01:00
|
|
|
self.enabled = True
|
|
|
|
|
|
|
|
class _recognizer(object):
|
2018-01-15 11:13:53 +00:00
|
|
|
"The recognizer class for TemplateTypePrinter."
|
|
|
|
|
|
|
|
def __init__(self, name, defargs):
|
|
|
|
self.name = name
|
|
|
|
self.defargs = defargs
|
|
|
|
# self.type_obj = None
|
2014-07-15 13:00:12 +01:00
|
|
|
|
|
|
|
def recognize(self, type_obj):
|
2018-01-15 11:13:53 +00:00
|
|
|
"""
|
|
|
|
If type_obj is a specialization of self.name that uses all the
|
|
|
|
default template arguments for the class template, then return
|
|
|
|
a string representation of the type without default arguments.
|
|
|
|
Otherwise, return None.
|
|
|
|
"""
|
|
|
|
|
2014-07-15 13:00:12 +01:00
|
|
|
if type_obj.tag is None:
|
|
|
|
return None
|
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
if not type_obj.tag.startswith(self.name):
|
|
|
|
return None
|
|
|
|
|
|
|
|
template_args = get_template_arg_list(type_obj)
|
|
|
|
displayed_args = []
|
|
|
|
require_defaulted = False
|
|
|
|
for n in range(len(template_args)):
|
|
|
|
# The actual template argument in the type:
|
|
|
|
targ = template_args[n]
|
|
|
|
# The default template argument for the class template:
|
|
|
|
defarg = self.defargs.get(n)
|
|
|
|
if defarg is not None:
|
|
|
|
# Substitute other template arguments into the default:
|
|
|
|
defarg = defarg.format(*template_args)
|
|
|
|
# Fail to recognize the type (by returning None)
|
|
|
|
# unless the actual argument is the same as the default.
|
|
|
|
try:
|
|
|
|
if targ != gdb.lookup_type(defarg):
|
|
|
|
return None
|
|
|
|
except gdb.error:
|
|
|
|
# Type lookup failed, just use string comparison:
|
|
|
|
if targ.tag != defarg:
|
|
|
|
return None
|
|
|
|
# All subsequent args must have defaults:
|
|
|
|
require_defaulted = True
|
|
|
|
elif require_defaulted:
|
|
|
|
return None
|
|
|
|
else:
|
|
|
|
# Recursively apply recognizers to the template argument
|
|
|
|
# and add it to the arguments that will be displayed:
|
|
|
|
displayed_args.append(self._recognize_subtype(targ))
|
|
|
|
|
|
|
|
# This assumes no class templates in the nested-name-specifier:
|
|
|
|
template_name = type_obj.tag[0:type_obj.tag.find('<')]
|
|
|
|
template_name = strip_inline_namespaces(template_name)
|
|
|
|
|
|
|
|
return template_name + '<' + ', '.join(displayed_args) + '>'
|
|
|
|
|
|
|
|
def _recognize_subtype(self, type_obj):
|
|
|
|
"""Convert a gdb.Type to a string by applying recognizers,
|
|
|
|
or if that fails then simply converting to a string."""
|
|
|
|
|
|
|
|
if type_obj.code == gdb.TYPE_CODE_PTR:
|
|
|
|
return self._recognize_subtype(type_obj.target()) + '*'
|
|
|
|
if type_obj.code == gdb.TYPE_CODE_ARRAY:
|
|
|
|
type_str = self._recognize_subtype(type_obj.target())
|
|
|
|
if str(type_obj.strip_typedefs()).endswith('[]'):
|
|
|
|
return type_str + '[]' # array of unknown bound
|
|
|
|
return "%s[%d]" % (type_str, type_obj.range()[1] + 1)
|
|
|
|
if type_obj.code == gdb.TYPE_CODE_REF:
|
|
|
|
return self._recognize_subtype(type_obj.target()) + '&'
|
|
|
|
if hasattr(gdb, 'TYPE_CODE_RVALUE_REF'):
|
|
|
|
if type_obj.code == gdb.TYPE_CODE_RVALUE_REF:
|
|
|
|
return self._recognize_subtype(type_obj.target()) + '&&'
|
|
|
|
|
|
|
|
type_str = gdb.types.apply_type_recognizers(
|
|
|
|
gdb.types.get_type_recognizers(), type_obj)
|
|
|
|
if type_str:
|
|
|
|
return type_str
|
|
|
|
return str(type_obj)
|
2014-07-15 13:00:12 +01:00
|
|
|
|
|
|
|
def instantiate(self):
|
2018-01-15 11:13:53 +00:00
|
|
|
"Return a recognizer object for this type printer."
|
|
|
|
return self._recognizer(self.name, self.defargs)
|
2014-07-15 13:00:12 +01:00
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
def add_one_template_type_printer(obj, name, defargs):
|
|
|
|
r"""
|
|
|
|
Add a type printer for a class template with default template arguments.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
name (str): The template-name of the class template.
|
|
|
|
defargs (dict int:string) The default template arguments.
|
|
|
|
|
|
|
|
Types in defargs can refer to the Nth template-argument using {N}
|
|
|
|
(with zero-based indices).
|
|
|
|
|
|
|
|
e.g. 'unordered_map' has these defargs:
|
|
|
|
{ 2: 'std::hash<{0}>',
|
|
|
|
3: 'std::equal_to<{0}>',
|
|
|
|
4: 'std::allocator<std::pair<const {0}, {1}> >' }
|
|
|
|
|
|
|
|
"""
|
|
|
|
printer = TemplateTypePrinter('std::'+name, defargs)
|
2014-07-15 13:00:12 +01:00
|
|
|
gdb.types.register_type_printer(obj, printer)
|
2019-05-06 05:33:23 +00:00
|
|
|
|
|
|
|
# Add type printer for same type in debug namespace:
|
|
|
|
printer = TemplateTypePrinter('std::__debug::'+name, defargs)
|
|
|
|
gdb.types.register_type_printer(obj, printer)
|
|
|
|
|
2017-01-10 12:38:42 +00:00
|
|
|
if _versioned_namespace:
|
|
|
|
# Add second type printer for same type in versioned namespace:
|
2018-01-15 11:13:53 +00:00
|
|
|
ns = 'std::' + _versioned_namespace
|
2018-06-25 22:03:49 +01:00
|
|
|
# PR 86112 Cannot use dict comprehension here:
|
|
|
|
defargs = dict((n, d.replace('std::', ns)) for (n,d) in defargs.items())
|
2018-01-15 11:13:53 +00:00
|
|
|
printer = TemplateTypePrinter(ns+name, defargs)
|
2017-01-10 12:38:42 +00:00
|
|
|
gdb.types.register_type_printer(obj, printer)
|
2014-07-15 13:00:12 +01:00
|
|
|
|
2012-11-16 18:17:25 +00:00
|
|
|
class FilteringTypePrinter(object):
|
2018-01-15 11:13:53 +00:00
|
|
|
r"""
|
|
|
|
A type printer that uses typedef names for common template specializations.
|
|
|
|
|
|
|
|
Args:
|
|
|
|
match (str): The class template to recognize.
|
|
|
|
name (str): The typedef-name that will be used instead.
|
|
|
|
|
|
|
|
Checks if a specialization of the class template 'match' is the same type
|
|
|
|
as the typedef 'name', and prints it as 'name' instead.
|
|
|
|
|
|
|
|
e.g. if an instantiation of std::basic_istream<C, T> is the same type as
|
|
|
|
std::istream then print it as std::istream.
|
|
|
|
"""
|
|
|
|
|
2012-11-16 18:17:25 +00:00
|
|
|
def __init__(self, match, name):
|
|
|
|
self.match = match
|
|
|
|
self.name = name
|
|
|
|
self.enabled = True
|
|
|
|
|
|
|
|
class _recognizer(object):
|
2018-01-15 11:13:53 +00:00
|
|
|
"The recognizer class for TemplateTypePrinter."
|
|
|
|
|
2012-11-16 18:17:25 +00:00
|
|
|
def __init__(self, match, name):
|
|
|
|
self.match = match
|
|
|
|
self.name = name
|
|
|
|
self.type_obj = None
|
|
|
|
|
|
|
|
def recognize(self, type_obj):
|
2018-01-15 11:13:53 +00:00
|
|
|
"""
|
|
|
|
If type_obj starts with self.match and is the same type as
|
|
|
|
self.name then return self.name, otherwise None.
|
|
|
|
"""
|
2012-11-16 18:17:25 +00:00
|
|
|
if type_obj.tag is None:
|
|
|
|
return None
|
|
|
|
|
|
|
|
if self.type_obj is None:
|
2018-01-15 11:13:53 +00:00
|
|
|
if not type_obj.tag.startswith(self.match):
|
2012-11-16 18:17:25 +00:00
|
|
|
# Filter didn't match.
|
|
|
|
return None
|
|
|
|
try:
|
|
|
|
self.type_obj = gdb.lookup_type(self.name).strip_typedefs()
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
if self.type_obj == type_obj:
|
2018-01-15 11:13:53 +00:00
|
|
|
return strip_inline_namespaces(self.name)
|
2012-11-16 18:17:25 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
def instantiate(self):
|
2018-01-15 11:13:53 +00:00
|
|
|
"Return a recognizer object for this type printer."
|
2012-11-16 18:17:25 +00:00
|
|
|
return self._recognizer(self.match, self.name)
|
|
|
|
|
|
|
|
def add_one_type_printer(obj, match, name):
|
2018-01-15 11:13:53 +00:00
|
|
|
printer = FilteringTypePrinter('std::' + match, 'std::' + name)
|
2012-11-16 18:17:25 +00:00
|
|
|
gdb.types.register_type_printer(obj, printer)
|
2017-01-10 12:38:42 +00:00
|
|
|
if _versioned_namespace:
|
2018-01-15 11:13:53 +00:00
|
|
|
ns = 'std::' + _versioned_namespace
|
|
|
|
printer = FilteringTypePrinter(ns + match, ns + name)
|
2017-01-10 12:38:42 +00:00
|
|
|
gdb.types.register_type_printer(obj, printer)
|
2012-11-16 18:17:25 +00:00
|
|
|
|
|
|
|
def register_type_printers(obj):
|
|
|
|
global _use_type_printing
|
|
|
|
|
|
|
|
if not _use_type_printing:
|
|
|
|
return
|
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
# Add type printers for typedefs std::string, std::wstring etc.
|
2019-02-22 01:16:11 +00:00
|
|
|
for ch in ('', 'w', 'u8', 'u16', 'u32'):
|
2018-01-15 11:13:53 +00:00
|
|
|
add_one_type_printer(obj, 'basic_string', ch + 'string')
|
2018-10-09 14:06:46 +01:00
|
|
|
add_one_type_printer(obj, '__cxx11::basic_string', ch + 'string')
|
|
|
|
# Typedefs for __cxx11::basic_string used to be in namespace __cxx11:
|
2018-01-15 11:13:53 +00:00
|
|
|
add_one_type_printer(obj, '__cxx11::basic_string',
|
|
|
|
'__cxx11::' + ch + 'string')
|
|
|
|
add_one_type_printer(obj, 'basic_string_view', ch + 'string_view')
|
|
|
|
|
|
|
|
# Add type printers for typedefs std::istream, std::wistream etc.
|
|
|
|
for ch in ('', 'w'):
|
|
|
|
for x in ('ios', 'streambuf', 'istream', 'ostream', 'iostream',
|
|
|
|
'filebuf', 'ifstream', 'ofstream', 'fstream'):
|
|
|
|
add_one_type_printer(obj, 'basic_' + x, ch + x)
|
|
|
|
for x in ('stringbuf', 'istringstream', 'ostringstream',
|
|
|
|
'stringstream'):
|
|
|
|
add_one_type_printer(obj, 'basic_' + x, ch + x)
|
2018-10-09 14:06:46 +01:00
|
|
|
# <sstream> types are in __cxx11 namespace, but typedefs aren't:
|
2018-01-15 11:13:53 +00:00
|
|
|
add_one_type_printer(obj, '__cxx11::basic_' + x, ch + x)
|
|
|
|
|
|
|
|
# Add type printers for typedefs regex, wregex, cmatch, wcmatch etc.
|
|
|
|
for abi in ('', '__cxx11::'):
|
|
|
|
for ch in ('', 'w'):
|
|
|
|
add_one_type_printer(obj, abi + 'basic_regex', abi + ch + 'regex')
|
|
|
|
for ch in ('c', 's', 'wc', 'ws'):
|
|
|
|
add_one_type_printer(obj, abi + 'match_results', abi + ch + 'match')
|
|
|
|
for x in ('sub_match', 'regex_iterator', 'regex_token_iterator'):
|
|
|
|
add_one_type_printer(obj, abi + x, abi + ch + x)
|
2012-11-16 18:17:25 +00:00
|
|
|
|
|
|
|
# Note that we can't have a printer for std::wstreampos, because
|
2018-01-15 11:13:53 +00:00
|
|
|
# it is the same type as std::streampos.
|
2012-11-16 18:17:25 +00:00
|
|
|
add_one_type_printer(obj, 'fpos', 'streampos')
|
2017-01-10 12:38:42 +00:00
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
# Add type printers for <chrono> typedefs.
|
2012-11-16 18:17:25 +00:00
|
|
|
for dur in ('nanoseconds', 'microseconds', 'milliseconds',
|
|
|
|
'seconds', 'minutes', 'hours'):
|
|
|
|
add_one_type_printer(obj, 'duration', dur)
|
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
# Add type printers for <random> typedefs.
|
2012-11-16 18:17:25 +00:00
|
|
|
add_one_type_printer(obj, 'linear_congruential_engine', 'minstd_rand0')
|
|
|
|
add_one_type_printer(obj, 'linear_congruential_engine', 'minstd_rand')
|
|
|
|
add_one_type_printer(obj, 'mersenne_twister_engine', 'mt19937')
|
|
|
|
add_one_type_printer(obj, 'mersenne_twister_engine', 'mt19937_64')
|
|
|
|
add_one_type_printer(obj, 'subtract_with_carry_engine', 'ranlux24_base')
|
|
|
|
add_one_type_printer(obj, 'subtract_with_carry_engine', 'ranlux48_base')
|
|
|
|
add_one_type_printer(obj, 'discard_block_engine', 'ranlux24')
|
|
|
|
add_one_type_printer(obj, 'discard_block_engine', 'ranlux48')
|
|
|
|
add_one_type_printer(obj, 'shuffle_order_engine', 'knuth_b')
|
|
|
|
|
2018-01-15 11:13:53 +00:00
|
|
|
# Add type printers for experimental::basic_string_view typedefs.
|
|
|
|
ns = 'experimental::fundamentals_v1::'
|
2019-02-22 01:16:11 +00:00
|
|
|
for ch in ('', 'w', 'u8', 'u16', 'u32'):
|
2018-01-15 11:13:53 +00:00
|
|
|
add_one_type_printer(obj, ns + 'basic_string_view',
|
|
|
|
ns + ch + 'string_view')
|
|
|
|
|
|
|
|
# Do not show defaulted template arguments in class templates.
|
|
|
|
add_one_template_type_printer(obj, 'unique_ptr',
|
|
|
|
{ 1: 'std::default_delete<{0}>' })
|
|
|
|
add_one_template_type_printer(obj, 'deque', { 1: 'std::allocator<{0}>'})
|
|
|
|
add_one_template_type_printer(obj, 'forward_list', { 1: 'std::allocator<{0}>'})
|
|
|
|
add_one_template_type_printer(obj, 'list', { 1: 'std::allocator<{0}>'})
|
|
|
|
add_one_template_type_printer(obj, '__cxx11::list', { 1: 'std::allocator<{0}>'})
|
|
|
|
add_one_template_type_printer(obj, 'vector', { 1: 'std::allocator<{0}>'})
|
|
|
|
add_one_template_type_printer(obj, 'map',
|
|
|
|
{ 2: 'std::less<{0}>',
|
|
|
|
3: 'std::allocator<std::pair<{0} const, {1}>>' })
|
|
|
|
add_one_template_type_printer(obj, 'multimap',
|
|
|
|
{ 2: 'std::less<{0}>',
|
|
|
|
3: 'std::allocator<std::pair<{0} const, {1}>>' })
|
|
|
|
add_one_template_type_printer(obj, 'set',
|
|
|
|
{ 1: 'std::less<{0}>', 2: 'std::allocator<{0}>' })
|
|
|
|
add_one_template_type_printer(obj, 'multiset',
|
|
|
|
{ 1: 'std::less<{0}>', 2: 'std::allocator<{0}>' })
|
|
|
|
add_one_template_type_printer(obj, 'unordered_map',
|
|
|
|
{ 2: 'std::hash<{0}>',
|
|
|
|
3: 'std::equal_to<{0}>',
|
|
|
|
4: 'std::allocator<std::pair<{0} const, {1}>>'})
|
|
|
|
add_one_template_type_printer(obj, 'unordered_multimap',
|
|
|
|
{ 2: 'std::hash<{0}>',
|
|
|
|
3: 'std::equal_to<{0}>',
|
|
|
|
4: 'std::allocator<std::pair<{0} const, {1}>>'})
|
|
|
|
add_one_template_type_printer(obj, 'unordered_set',
|
|
|
|
{ 1: 'std::hash<{0}>',
|
|
|
|
2: 'std::equal_to<{0}>',
|
|
|
|
3: 'std::allocator<{0}>'})
|
|
|
|
add_one_template_type_printer(obj, 'unordered_multiset',
|
|
|
|
{ 1: 'std::hash<{0}>',
|
|
|
|
2: 'std::equal_to<{0}>',
|
|
|
|
3: 'std::allocator<{0}>'})
|
2014-07-15 13:00:12 +01:00
|
|
|
|
2011-03-14 20:29:23 +00:00
|
|
|
def register_libstdcxx_printers (obj):
|
|
|
|
"Register libstdc++ pretty-printers with objfile Obj."
|
|
|
|
|
|
|
|
global _use_gdb_pp
|
|
|
|
global libstdcxx_printer
|
|
|
|
|
|
|
|
if _use_gdb_pp:
|
|
|
|
gdb.printing.register_pretty_printer(obj, libstdcxx_printer)
|
|
|
|
else:
|
|
|
|
if obj is None:
|
|
|
|
obj = gdb
|
|
|
|
obj.pretty_printers.append(libstdcxx_printer)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2012-11-16 18:17:25 +00:00
|
|
|
register_type_printers(obj)
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
def build_libstdcxx_dictionary ():
|
2011-03-14 20:29:23 +00:00
|
|
|
global libstdcxx_printer
|
|
|
|
|
|
|
|
libstdcxx_printer = Printer("libstdc++-v6")
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
# libstdc++ objects requiring pretty-printing.
|
|
|
|
# In order from:
|
|
|
|
# http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/a01847.html
|
2012-01-30 16:25:11 +00:00
|
|
|
libstdcxx_printer.add_version('std::', 'basic_string', StdStringPrinter)
|
2017-11-01 17:52:05 +00:00
|
|
|
libstdcxx_printer.add_version('std::__cxx11::', 'basic_string', StdStringPrinter)
|
2012-01-30 16:25:11 +00:00
|
|
|
libstdcxx_printer.add_container('std::', 'bitset', StdBitsetPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'deque', StdDequePrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'list', StdListPrinter)
|
2016-10-11 11:33:29 +01:00
|
|
|
libstdcxx_printer.add_container('std::__cxx11::', 'list', StdListPrinter)
|
2012-01-30 16:25:11 +00:00
|
|
|
libstdcxx_printer.add_container('std::', 'map', StdMapPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'multimap', StdMapPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'multiset', StdSetPrinter)
|
2018-07-31 23:31:20 +01:00
|
|
|
libstdcxx_printer.add_version('std::', 'pair', StdPairPrinter)
|
2012-01-30 16:25:11 +00:00
|
|
|
libstdcxx_printer.add_version('std::', 'priority_queue',
|
|
|
|
StdStackOrQueuePrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', 'queue', StdStackOrQueuePrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', 'tuple', StdTuplePrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'set', StdSetPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', 'stack', StdStackOrQueuePrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', 'unique_ptr', UniquePointerPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'vector', StdVectorPrinter)
|
2009-05-28 17:14:18 +00:00
|
|
|
# vector<bool>
|
|
|
|
|
2009-10-01 20:43:13 +00:00
|
|
|
# Printer registrations for classes compiled with -D_GLIBCXX_DEBUG.
|
2011-03-14 20:29:23 +00:00
|
|
|
libstdcxx_printer.add('std::__debug::bitset', StdBitsetPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::deque', StdDequePrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::list', StdListPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::map', StdMapPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::multimap', StdMapPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::multiset', StdSetPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::priority_queue',
|
|
|
|
StdStackOrQueuePrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::queue', StdStackOrQueuePrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::set', StdSetPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::stack', StdStackOrQueuePrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::unique_ptr', UniquePointerPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::vector', StdVectorPrinter)
|
2009-10-01 20:43:13 +00:00
|
|
|
|
2016-09-17 16:20:23 +01:00
|
|
|
# These are the TR1 and C++11 printers.
|
2009-05-28 17:14:18 +00:00
|
|
|
# For array - the default GDB pretty-printer seems reasonable.
|
2012-02-05 19:10:15 +00:00
|
|
|
libstdcxx_printer.add_version('std::', 'shared_ptr', SharedPointerPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', 'weak_ptr', SharedPointerPrinter)
|
2012-01-30 16:25:11 +00:00
|
|
|
libstdcxx_printer.add_container('std::', 'unordered_map',
|
|
|
|
Tr1UnorderedMapPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'unordered_set',
|
|
|
|
Tr1UnorderedSetPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'unordered_multimap',
|
|
|
|
Tr1UnorderedMapPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'unordered_multiset',
|
|
|
|
Tr1UnorderedSetPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', 'forward_list',
|
|
|
|
StdForwardListPrinter)
|
|
|
|
|
2017-11-01 17:52:05 +00:00
|
|
|
libstdcxx_printer.add_version('std::tr1::', 'shared_ptr', SharedPointerPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::tr1::', 'weak_ptr', SharedPointerPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::tr1::', 'unordered_map',
|
2012-01-30 16:25:11 +00:00
|
|
|
Tr1UnorderedMapPrinter)
|
2017-11-01 17:52:05 +00:00
|
|
|
libstdcxx_printer.add_version('std::tr1::', 'unordered_set',
|
2012-01-30 16:25:11 +00:00
|
|
|
Tr1UnorderedSetPrinter)
|
2017-11-01 17:52:05 +00:00
|
|
|
libstdcxx_printer.add_version('std::tr1::', 'unordered_multimap',
|
2012-01-30 16:25:11 +00:00
|
|
|
Tr1UnorderedMapPrinter)
|
2017-11-01 17:52:05 +00:00
|
|
|
libstdcxx_printer.add_version('std::tr1::', 'unordered_multiset',
|
2012-01-30 16:25:11 +00:00
|
|
|
Tr1UnorderedSetPrinter)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2016-09-17 16:20:23 +01:00
|
|
|
# These are the C++11 printer registrations for -D_GLIBCXX_DEBUG cases.
|
2016-12-14 15:17:57 +00:00
|
|
|
# The tr1 namespace containers do not have any debug equivalents,
|
|
|
|
# so do not register printers for them.
|
2011-03-14 20:29:23 +00:00
|
|
|
libstdcxx_printer.add('std::__debug::unordered_map',
|
|
|
|
Tr1UnorderedMapPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::unordered_set',
|
|
|
|
Tr1UnorderedSetPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::unordered_multimap',
|
|
|
|
Tr1UnorderedMapPrinter)
|
|
|
|
libstdcxx_printer.add('std::__debug::unordered_multiset',
|
|
|
|
Tr1UnorderedSetPrinter)
|
2012-01-08 12:34:00 +00:00
|
|
|
libstdcxx_printer.add('std::__debug::forward_list',
|
|
|
|
StdForwardListPrinter)
|
2009-10-01 20:43:13 +00:00
|
|
|
|
2014-07-15 13:00:18 +01:00
|
|
|
# Library Fundamentals TS components
|
|
|
|
libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
|
|
|
|
'any', StdExpAnyPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
|
|
|
|
'optional', StdExpOptionalPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::experimental::fundamentals_v1::',
|
|
|
|
'basic_string_view', StdExpStringViewPrinter)
|
2015-04-30 20:11:52 +01:00
|
|
|
# Filesystem TS components
|
|
|
|
libstdcxx_printer.add_version('std::experimental::filesystem::v1::',
|
|
|
|
'path', StdExpPathPrinter)
|
2015-05-01 20:47:55 +01:00
|
|
|
libstdcxx_printer.add_version('std::experimental::filesystem::v1::__cxx11::',
|
2015-04-30 20:11:52 +01:00
|
|
|
'path', StdExpPathPrinter)
|
2017-10-23 13:11:22 +01:00
|
|
|
libstdcxx_printer.add_version('std::filesystem::',
|
PR libstdc++/71044 optimize std::filesystem::path construction
This new implementation has a smaller footprint than the previous
implementation, due to replacing std::vector<_Cmpt> with a custom pimpl
type that only needs a single pointer. The _M_type enumeration is also
combined with the pimpl type, by using a tagged pointer, reducing
sizeof(path) further still.
Construction and modification of paths is now done more efficiently, by
splitting the input into a stack-based buffer of string_view objects
instead of a dynamically-allocated vector containing strings. Once the
final size is known only a single allocation is needed to reserve space
for it. The append and concat operations no longer require constructing
temporary path objects, nor re-parsing the entire native pathname.
This results in algorithmic improvements to path construction, and
working with large paths is much faster.
PR libstdc++/71044
* include/bits/fs_path.h (path::path(path&&)): Add noexcept when
appropriate. Move _M_cmpts instead of reparsing the native pathname.
(path::operator=(const path&)): Do not define as defaulted.
(path::operator/=, path::append): Call _M_append.
(path::concat): Call _M_concat.
(path::path(string_type, _Type): Change type of first parameter to
basic_string_view<value_type>.
(path::_M_append(basic_string_view<value_type>)): New member function.
(path::_M_concat(basic_string_view<value_type>)): New member function.
(_S_convert(value_type*, __null_terminated)): Return string view.
(_S_convert(const value_type*, __null_terminated)): Return string view.
(_S_convert(value_type*, value_type*))
(_S_convert(const value_type*, const value_type*)): Add overloads for
pairs of pointers.
(_S_convert(_InputIterator, __null_terminated)): Construct string_type
explicitly, for cases where _S_convert returns a string view.
(path::_S_is_dir_sep): Replace with non-member is_dir_sep.
(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
(path::_M_add_filename): Remove.
(path::_M_type()): New member function to replace _M_type data member.
(path::_List): Define new struct type instead of using std::vector.
(path::_Cmpt::_Cmpt(string_type, _Type, size_t)): Change type of
first parameter to basic_string_view<value_type>.
(path::operator+=(const path&)): Do not define inline.
(path::operator+=(const string_type&)): Call _M_concat.
(path::operator+=(const value_type*)): Likewise.
(path::operator+=(value_type)): Likewise.
(path::operator+=(basic_string_view<value_type>)): Likewise.
(path::operator/=(const path&)): Do not define inline.
(path::_M_append(path)): Remove.
* python/libstdcxx/v6/printers.py (StdPathPrinter): New printer that
understands the new path::_List type.
* src/filesystem/std-path.cc (is_dir_sep): New function to replace
path::_S_is_dir_sep.
(path::_Parser): New helper class to parse strings as paths.
(path::_List::_Impl): Define container type for path components.
(path::_List): Define members.
(path::operator=(const path&)): Define explicitly, to provide the
strong exception safety guarantee.
(path::operator/=(const path&)): Implement manually by processing
each component of the argument, rather than using _M_split_cmpts
to parse the entire string again.
(path::_M_append(string_type)): Likewise.
(path::operator+=(const path&)): Likewise.
(path::_M_concat(string_type)): Likewise.
(path::remove_filename()): Perform trim directly instead of calling
_M_trim().
(path::_M_split_cmpts()): Rewrite in terms of _Parser class.
(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
(path::_M_add_filename): Remove.
* testsuite/27_io/filesystem/path/append/source.cc: Test appending a
string view that aliases the path.
testsuite/27_io/filesystem/path/concat/strings.cc: Test concatenating
a string view that aliases the path.
From-SVN: r267106
2018-12-13 20:33:55 +00:00
|
|
|
'path', StdPathPrinter)
|
2017-10-23 13:11:22 +01:00
|
|
|
libstdcxx_printer.add_version('std::filesystem::__cxx11::',
|
PR libstdc++/71044 optimize std::filesystem::path construction
This new implementation has a smaller footprint than the previous
implementation, due to replacing std::vector<_Cmpt> with a custom pimpl
type that only needs a single pointer. The _M_type enumeration is also
combined with the pimpl type, by using a tagged pointer, reducing
sizeof(path) further still.
Construction and modification of paths is now done more efficiently, by
splitting the input into a stack-based buffer of string_view objects
instead of a dynamically-allocated vector containing strings. Once the
final size is known only a single allocation is needed to reserve space
for it. The append and concat operations no longer require constructing
temporary path objects, nor re-parsing the entire native pathname.
This results in algorithmic improvements to path construction, and
working with large paths is much faster.
PR libstdc++/71044
* include/bits/fs_path.h (path::path(path&&)): Add noexcept when
appropriate. Move _M_cmpts instead of reparsing the native pathname.
(path::operator=(const path&)): Do not define as defaulted.
(path::operator/=, path::append): Call _M_append.
(path::concat): Call _M_concat.
(path::path(string_type, _Type): Change type of first parameter to
basic_string_view<value_type>.
(path::_M_append(basic_string_view<value_type>)): New member function.
(path::_M_concat(basic_string_view<value_type>)): New member function.
(_S_convert(value_type*, __null_terminated)): Return string view.
(_S_convert(const value_type*, __null_terminated)): Return string view.
(_S_convert(value_type*, value_type*))
(_S_convert(const value_type*, const value_type*)): Add overloads for
pairs of pointers.
(_S_convert(_InputIterator, __null_terminated)): Construct string_type
explicitly, for cases where _S_convert returns a string view.
(path::_S_is_dir_sep): Replace with non-member is_dir_sep.
(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
(path::_M_add_filename): Remove.
(path::_M_type()): New member function to replace _M_type data member.
(path::_List): Define new struct type instead of using std::vector.
(path::_Cmpt::_Cmpt(string_type, _Type, size_t)): Change type of
first parameter to basic_string_view<value_type>.
(path::operator+=(const path&)): Do not define inline.
(path::operator+=(const string_type&)): Call _M_concat.
(path::operator+=(const value_type*)): Likewise.
(path::operator+=(value_type)): Likewise.
(path::operator+=(basic_string_view<value_type>)): Likewise.
(path::operator/=(const path&)): Do not define inline.
(path::_M_append(path)): Remove.
* python/libstdcxx/v6/printers.py (StdPathPrinter): New printer that
understands the new path::_List type.
* src/filesystem/std-path.cc (is_dir_sep): New function to replace
path::_S_is_dir_sep.
(path::_Parser): New helper class to parse strings as paths.
(path::_List::_Impl): Define container type for path components.
(path::_List): Define members.
(path::operator=(const path&)): Define explicitly, to provide the
strong exception safety guarantee.
(path::operator/=(const path&)): Implement manually by processing
each component of the argument, rather than using _M_split_cmpts
to parse the entire string again.
(path::_M_append(string_type)): Likewise.
(path::operator+=(const path&)): Likewise.
(path::_M_concat(string_type)): Likewise.
(path::remove_filename()): Perform trim directly instead of calling
_M_trim().
(path::_M_split_cmpts()): Rewrite in terms of _Parser class.
(path::_M_trim, path::_M_add_root_name, path::_M_add_root_dir)
(path::_M_add_filename): Remove.
* testsuite/27_io/filesystem/path/append/source.cc: Test appending a
string view that aliases the path.
testsuite/27_io/filesystem/path/concat/strings.cc: Test concatenating
a string view that aliases the path.
From-SVN: r267106
2018-12-13 20:33:55 +00:00
|
|
|
'path', StdPathPrinter)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
2016-09-17 16:20:23 +01:00
|
|
|
# C++17 components
|
|
|
|
libstdcxx_printer.add_version('std::',
|
|
|
|
'any', StdExpAnyPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::',
|
|
|
|
'optional', StdExpOptionalPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::',
|
|
|
|
'basic_string_view', StdExpStringViewPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::',
|
|
|
|
'variant', StdVariantPrinter)
|
Implement C++17 node extraction and insertion (P0083R5)
* doc/xml/manual/status_cxx2017.xml: Document status.
* doc/html/*: Regenerate.
* include/Makefile.am: Add bits/node_handle.h and reorder.
* include/Makefile.in: Regenerate.
* include/bits/hashtable.h (_Hashtable::node_type)
(_Hashtable::insert_return_type, _Hashtable::_M_reinsert_node)
(_Hashtable::_M_reinsert_node_multi, _Hashtable::extract)
(_Hashtable::_M_merge_unique, _Hashtable::_M_merge_multi): Define.
(_Hash_merge_helper): Define primary template.
* include/bits/node_handle.h: New header.
* include/bits/stl_map.h (map): Declare _Rb_tree_merge_helper as
friend.
(map::node_type, map::insert_return_type, map::extract, map::merge)
(map::insert(node_type&&), map::insert(const_iterator, node_type&&)):
Define new members.
(_Rb_tree_merge_helper): Specialize for map.
* include/bits/stl_multimap.h (multimap): Declare _Rb_tree_merge_helper
as friend.
(multimap::node_type, multimap::extract, multimap::merge)
(multimap::insert(node_type&&))
(multimap::insert(const_iterator, node_type&&)): Define.
(_Rb_tree_merge_helper): Specialize for multimap.
* include/bits/stl_multiset.h (multiset): Declare _Rb_tree_merge_helper
as friend.
(multiset::node_type, multiset::extract, multiset::merge)
(multiset::insert(node_type&&))
(multiset::insert(const_iterator, node_type&&)): Define.
* include/bits/stl_set.h (set): Declare _Rb_tree_merge_helper as
friend.
(set::node_type, set::insert_return_type, set::extract, set::merge)
(set::insert(node_type&&), set::insert(const_iterator, node_type&&)):
Define.
(_Rb_tree_merge_helper): Specialize for set.
* include/bits/stl_tree.h (_Rb_tree): Declare _Rb_tree<> as friend.
(_Rb_tree::node_type, _Rb_tree::insert_return_type)
(_Rb_tree::_M_reinsert_node_unique, _Rb_tree::_M_reinsert_node_equal)
(_Rb_tree::_M_reinsert_node_hint_unique)
(_Rb_tree::_M_reinsert_node_hint_equal, _Rb_tree::extract)
(_Rb_tree::_M_merge_unique, _Rb_tree::_M_merge_equal): Define.
(_Rb_tree_merge_helper): Specialize for multiset.
* include/bits/unordered_map.h (unordered_map): Declare
unordered_map<> and unordered_multimap<> as friends.
(unordered_map::node_type, unordered_map::insert_return_type)
(unordered_map::extract, unordered_map::merge)
(unordered_map::insert(node_type&&))
(unordered_map::insert(const_iterator, node_type&&))
(unordered_multimap): Declare _Hash_merge_helper as friend.
(unordered_multimap::node_type, unordered_multimap::extract)
(unordered_multimap::merge, unordered_multimap::insert(node_type&&))
(unordered_multimap::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered maps and multimaps.
* include/bits/unordered_set.h (unordered_set, unordered_multiset):
Declare _Hash_merge_helper as friend.
(unordered_set::node_type, unordered_set::insert_return_type)
(unordered_set::extract, unordered_set::merge)
(unordered_set::insert(node_type&&))
(unordered_set::insert(const_iterator, node_type&&)): Define.
(unordered_multiset::node_type, unordered_multiset::extract)
(unordered_multiset::merge, unordered_multiset::insert(node_type&&))
(unordered_multiset::insert(const_iterator, node_type&&)): Define.
(_Hash_merge_helper): Specialize for unordered sets and multisets.
* include/debug/map.h (map): Add using declarations or forwarding
functions for new members.
* include/debug/map.h (multimap): Likewise.
* include/debug/map.h (multiset): Likewise.
* include/debug/map.h (set): Likewise.
* include/debug/unordered_map (unordered_map, unordered_multimap):
Likewise.
* include/debug/unordered_set( unordered_set, unordered_multiset):
Likewise.
* python/libstdcxx/v6/printers.py (get_value_from_aligned_membuf): New
helper function.
(get_value_from_list_node, get_value_from_Rb_tree_node): Use helper.
(StdNodeHandlePrinter): Define printer for node handles.
(build_libstdcxx_dictionary): Register StdNodeHandlePrinter.
* testsuite/23_containers/map/modifiers/extract.cc: New.
* testsuite/23_containers/map/modifiers/merge.cc: New.
* testsuite/23_containers/multimap/modifiers/extract.cc: New.
* testsuite/23_containers/multimap/modifiers/merge.cc: New.
* testsuite/23_containers/multiset/modifiers/extract.cc: New.
* testsuite/23_containers/multiset/modifiers/merge.cc: New.
* testsuite/23_containers/set/modifiers/extract.cc: New.
* testsuite/23_containers/set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_map/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_map/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multimap/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multimap/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_multiset/modifiers/extract.cc:
New.
* testsuite/23_containers/unordered_multiset/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/modifiers/extract.cc: New.
* testsuite/23_containers/unordered_set/modifiers/merge.cc: New.
* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
dg-error lineno.
* testsuite/libstdc++-prettyprinters/cxx17.cc: Test node handles.
From-SVN: r240363
2016-09-22 14:58:49 +01:00
|
|
|
libstdcxx_printer.add_version('std::',
|
|
|
|
'_Node_handle', StdNodeHandlePrinter)
|
2016-09-17 16:20:23 +01:00
|
|
|
|
2019-12-05 00:42:11 +00:00
|
|
|
# C++20 components
|
|
|
|
libstdcxx_printer.add_version('std::', 'partial_ordering', StdCmpCatPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', 'weak_ordering', StdCmpCatPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', 'strong_ordering', StdCmpCatPrinter)
|
|
|
|
|
2009-05-28 17:14:18 +00:00
|
|
|
# Extensions.
|
2012-01-30 16:25:11 +00:00
|
|
|
libstdcxx_printer.add_version('__gnu_cxx::', 'slist', StdSlistPrinter)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
if True:
|
|
|
|
# These shouldn't be necessary, if GDB "print *i" worked.
|
|
|
|
# But it often doesn't, so here they are.
|
2012-01-30 16:25:11 +00:00
|
|
|
libstdcxx_printer.add_container('std::', '_List_iterator',
|
|
|
|
StdListIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', '_List_const_iterator',
|
|
|
|
StdListIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', '_Rb_tree_iterator',
|
|
|
|
StdRbtreeIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_version('std::', '_Rb_tree_const_iterator',
|
|
|
|
StdRbtreeIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', '_Deque_iterator',
|
|
|
|
StdDequeIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', '_Deque_const_iterator',
|
|
|
|
StdDequeIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_version('__gnu_cxx::', '__normal_iterator',
|
|
|
|
StdVectorIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_version('__gnu_cxx::', '_Slist_iterator',
|
|
|
|
StdSlistIteratorPrinter)
|
2018-03-09 05:56:07 +00:00
|
|
|
libstdcxx_printer.add_container('std::', '_Fwd_list_iterator',
|
|
|
|
StdFwdListIteratorPrinter)
|
|
|
|
libstdcxx_printer.add_container('std::', '_Fwd_list_const_iterator',
|
|
|
|
StdFwdListIteratorPrinter)
|
2011-03-14 20:29:23 +00:00
|
|
|
|
|
|
|
# Debug (compiled with -D_GLIBCXX_DEBUG) printer
|
2018-03-08 06:26:15 +00:00
|
|
|
# registrations.
|
2011-03-14 20:29:23 +00:00
|
|
|
libstdcxx_printer.add('__gnu_debug::_Safe_iterator',
|
|
|
|
StdDebugIteratorPrinter)
|
2009-05-28 17:14:18 +00:00
|
|
|
|
|
|
|
build_libstdcxx_dictionary ()
|