Commit graph

221 commits

Author SHA1 Message Date
Jonathan Wakely
df0a668b78 libstdc++: Implement C++26 std::text_encoding (P1885R12) [PR113318]
This is another C++26 change, approved in Varna 2023. We require a new
static array of data that is extracted from the IANA Character Sets
database. A new Python script to generate a header from the IANA CSV
file is added.

The text_encoding class is basically just a pointer to an {ID,name} pair
in the static array. The aliases view is also just the same pointer (or
empty), and the view's iterator moves forwards and backwards in the
array while the array elements have the same ID (or to one element
further, for a past-the-end iterator).

Because those iterators refer to a global array that never goes out of
scope, there's no reason they should every produce undefined behaviour
or indeterminate values.  They should either have well-defined
behaviour, or abort. The overhead of ensuring those properties is pretty
low, so seems worth it.

This means that an aliases_view iterator should never be able to access
out-of-bounds. A non-value-initialized iterator always points to an
element of the static array even when not dereferenceable (the array has
unreachable entries at the start and end, which means that even a
past-the-end iterator for the last encoding in the array still points to
valid memory).  Dereferencing an iterator can always return a valid
array element, or "" for a non-dereferenceable iterator (but doing so
will abort when assertions are enabled).  In the language being proposed
for C++26, dereferencing an invalid iterator erroneously returns "".
Attempting to increment/decrement past the last/first element in the
view is erroneously a no-op, so aborts when assertions are enabled, and
doesn't change value otherwise.

Similarly, constructing a std::text_encoding with an invalid id (one
that doesn't have the value of an enumerator) erroneously behaves the
same as constructing with id::unknown, or aborts with assertions
enabled.

libstdc++-v3/ChangeLog:

	PR libstdc++/113318
	* acinclude.m4 (GLIBCXX_CONFIGURE): Add c++26 directory.
	(GLIBCXX_CHECK_TEXT_ENCODING): Define.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_CHECK_TEXT_ENCODING.
	* include/Makefile.am: Add new headers.
	* include/Makefile.in: Regenerate.
	* include/bits/locale_classes.h (locale::encoding): Declare new
	member function.
	* include/bits/unicode.h (__charset_alias_match): New function.
	* include/bits/text_encoding-data.h: New file.
	* include/bits/version.def (text_encoding): Define.
	* include/bits/version.h: Regenerate.
	* include/std/text_encoding: New file.
	* src/Makefile.am: Add new subdirectory.
	* src/Makefile.in: Regenerate.
	* src/c++26/Makefile.am: New file.
	* src/c++26/Makefile.in: New file.
	* src/c++26/text_encoding.cc: New file.
	* src/experimental/Makefile.am: Include c++26 convenience
	library.
	* src/experimental/Makefile.in: Regenerate.
	* python/libstdcxx/v6/printers.py (StdTextEncodingPrinter): New
	printer.
	* scripts/gen_text_encoding_data.py: New file.
	* testsuite/22_locale/locale/encoding.cc: New test.
	* testsuite/ext/unicode/charset_alias_match.cc: New test.
	* testsuite/std/text_encoding/cons.cc: New test.
	* testsuite/std/text_encoding/members.cc: New test.
	* testsuite/std/text_encoding/requirements.cc: New test.

Reviewed-by: Ulrich Drepper <drepper.fsp@gmail.com>
Reviewed-by: Patrick Palka <ppalka@redhat.com>
2024-01-17 11:49:11 +00:00
Jonathan Wakely
cd2022f392 libstdc++: Add GDB printer for std::integral_constant
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdIntegralConstantPrinter):
	Add printer for std::integral_constant.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Test it.
2024-01-11 17:35:57 +00:00
Jakub Jelinek
a945c346f5 Update copyright years. 2024-01-03 12:19:35 +01:00
Jonathan Wakely
452476db0c libstdc++: Fix std::deque::operator[] Xmethod [PR112491]
The Xmethod for std::deque::operator[] has the same bug that I recently
fixed for the std::deque::size() Xmethod. The first node might have
unused capacity at the start, which needs to be accounted for when
indexing into the deque.

libstdc++-v3/ChangeLog:

	PR libstdc++/112491
	* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.index):
	Correctly handle unused capacity at the start of the first node.
	* testsuite/libstdc++-xmethods/deque.cc: Check index operator
	when elements have been removed from the front.
2023-11-15 11:16:49 +00:00
Jonathan Wakely
4db8209280 libstdc++: Fix std::deque::size() Xmethod [PR112491]
The Xmethod for std::deque::size() assumed that the first element would
be at the start of the first node. That's only true if elements are only
added at the back. If an element is inserted at the front, or removed
from the front (or anywhere before the middle) then the first node will
not be completely populated, and the Xmethod will give the wrong result.

libstdc++-v3/ChangeLog:

	PR libstdc++/112491
	* python/libstdcxx/v6/xmethods.py (DequeWorkerBase.size): Fix
	calculation to use _M_start._M_cur.
	* testsuite/libstdc++-xmethods/deque.cc: Check failing cases.
2023-11-14 15:55:03 +00:00
Tom Tromey
4bf77db70e libstdc++: Correctly call _string_types function
flake8 points out that the new call to _string_types from
StdExpAnyPrinter.__init__ is not correct -- it needs to be qualified.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py
	(StdExpAnyPrinter.__init__): Qualify call to
	_string_types.
2023-10-04 10:38:33 -06:00
Tom Tromey
d342c9de6a libstdc++: _versioned_namespace is always non-None
Some code in the pretty-printers seems to assume that the
_versioned_namespace global might be None (or the empty string).
However, doesn't occur, as the variable is never reassigned.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Assume that
	_versioned_namespace is non-None.
	* python/libstdcxx/v6/xmethods.py (is_specialization_of):
	Assume that _versioned_namespace is non-None.
2023-10-04 08:23:30 -06:00
Tom Tromey
83ec6e80ff libstdc++: Define _versioned_namespace in xmethods.py
flake8 pointed out that is_specialization_of in xmethods.py looks at a
global that wasn't added to the file.  This patch correct the
oversight.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/xmethods.py (_versioned_namespace):
	Define.
2023-10-04 08:23:30 -06:00
Tom Tromey
202810947c libstdc++: Use Python "not in" operator
flake8 warns about code like

    not something in "whatever"

Ordinarily in Python this should be written as:

    something not in "whatever"

This patch makes this change.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (Printer.add_version)
	(add_one_template_type_printer)
	(FilteringTypePrinter.add_one_type_printer): Use Python
	"not in" operator.
2023-09-28 14:56:09 -06:00
Tom Tromey
860b284e3e libstdc++: Remove std_ratio_t_tuple
This removes the std_ratio_t_tuple function from the Python
pretty-printer code.  It is not used.  Apparently the relevant parts
were moved to StdChronoDurationPrinter._ratio at some point in the
past.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (std_ratio_t_tuple):
	Remove.
2023-09-28 14:56:05 -06:00
Tom Tromey
33841921a2 libstdc++: Remove unused locals from printers.py
flake8 pointed out some unused local variables in the libstdc++
pretty-printers.  This removes them.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py
	(StdExpOptionalPrinter.__init__, lookup_node_type):
	Remove unused variables.
2023-09-28 14:56:00 -06:00
Tom Tromey
bed1f8498a libstdc++: Remove unused Python imports
flake8 pointed out some unused imports.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Don't import 'os'.
	* python/libstdcxx/v6/__init__.py: Don't import 'gdb'.
2023-09-28 14:55:54 -06:00
Tom Tromey
64f1210301 libstdc++: Use gdb.ValuePrinter base class
GDB 14 will add a new ValuePrinter tag class that will be used to
signal that pretty-printers will agree to the "extension protocol" --
essentially that they will follow some simple namespace rules, so that
GDB can add new methods over time.

A couple new methods have already been added to GDB, to support DAP.
While I haven't implemented these for any libstdc++ printers yet, this
patch makes the basic conversion: printers derive from
gdb.ValuePrinter if it is available, and all "non-standard" (that is,
not specified by GDB) members of the various value-printing classes
are renamed to have a leading underscore.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Use gdb.ValuePrinter
	everywhere.  Rename members to start with "_".
2023-09-28 14:55:23 -06:00
Jonathan Wakely
17d3477fa8 libstdc++: Refactor Python Xmethods to use is_specialization_of
This copies the is_specialization_of function from printers.py (with
slight modification for versioned namespace handling) and reuses it in
xmethods.py to replace repetitive re.match calls in every class.

This fixes the problem that the regular expressions used \d without
escaping the backslash properly.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/xmethods.py (is_specialization_of): Define
	new function.
	(ArrayMethodsMatcher, DequeMethodsMatcher)
	(ForwardListMethodsMatcher, ListMethodsMatcher)
	(VectorMethodsMatcher, AssociativeContainerMethodsMatcher)
	(UniquePtrGetWorker, UniquePtrMethodsMatcher)
	(SharedPtrSubscriptWorker, SharedPtrMethodsMatcher): Use
	is_specialization_of instead of re.match.
2023-09-28 21:20:27 +01:00
Jonathan Wakely
6b5c3f9b81 libstdc++: Reformat Python code
Some of these changes were suggested by autopep8's --aggressive
option, others are for readability.

Break long lines by splitting strings across multiple lines, or
introducing local variables to hold results.

Use raw strings for regular expressions, so that backslashes don't need
to be escaped.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Break long lines. Use raw
	strings for regular expressions. Add whitespace around
	operators.
	(is_member_of_namespace): Use isinstance to check type.
	(is_specialization_of): Likewise. Adjust template_name
	for versioned namespace instead of duplicating the re.match
	call.
	(StdExpAnyPrinter._string_types): New static method.
	(StdExpAnyPrinter.to_string): Use _string_types.
2023-09-28 21:20:21 +01:00
Jonathan Wakely
0ef4cc8225 libstdc++: Format Python docstrings according to PEP 357
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Format docstrings according
	to PEP 257.
	* python/libstdcxx/v6/xmethods.py: Likewise.
2023-09-28 20:56:44 +01:00
Jonathan Wakely
1fab05a885 libstdc++: Fix format string in StdChronoTimeZoneRulePrinter
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdChronoTimeZoneRulePrinter):
	Fix incorrect number of replacement fields.
2023-09-27 17:09:52 +01:00
Jonathan Wakely
e08559271b libstdc++: Format Python code according to PEP8
These files were filtered through autopep8 to reformat them more
conventionally.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Reformat.
	* python/libstdcxx/v6/xmethods.py: Likewise.
2023-09-12 12:41:27 +01:00
Jonathan Wakely
3d2e240af7 libstdc++: Add pretty printer for std::locale
Print the locale's name, except when it uses the same named C locale for
all categories except one, in which case print something like:
std::locale = "en_GB.UTF-8" with "LC_CTYPE=en_US.UTF-8"

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdLocalePrinter): New
	printer class.
	* testsuite/libstdc++-prettyprinters/locale.cc: New test.
2023-08-24 13:40:25 +01:00
Jonathan Wakely
701ce3c723 libstdc++: Declutter std::optional and std:variant pretty printers [PR110944]
As the PR says, including the template arguments in the GDB output of
these class templates can result in very long names, especially for
std::variant. You can use 'whatis' or other GDB commands to get details
of the type, we don't need to include it in the value.

We could consider including the type if it's not too long, but I think
consistency is better (and we already omit the template arguments for
std::vector and other class templates).

libstdc++-v3/ChangeLog:

	PR libstdc++/110944
	* python/libstdcxx/v6/printers.py (StdExpOptionalPrinter): Do
	not show template arguments.
	(StdVariantPrinter): Likewise.
	* testsuite/libstdc++-prettyprinters/compat.cc: Adjust expected
	output.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
2023-08-24 13:40:24 +01:00
Jonathan Wakely
c19b542a17 libstdc++: Handle invalid values in std::chrono pretty printers
This avoids an IndexError exception when printing invalid chrono::month
or chrono::weekday values.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdChronoCalendarPrinter):
	Check for out-of-range month an weekday indices.
	* testsuite/libstdc++-prettyprinters/chrono.cc: Check invalid
	month and weekday values.
2023-08-11 14:33:01 +01:00
Jonathan Wakely
7bd251ca75 libstdc++: Fix <chrono> pretty printers and add tests
This fixes a couple of errors in the printers for chrono types, and adds
tests to ensure they keep working.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdChronoDurationPrinter):
	Print floating-point durations correctly.
	(StdChronoTimePointPrinter): Support printing only the value,
	not the type name. Uncomment handling for known clocks.
	(StdChronoZonedTimePrinter): Remove type names from output.
	(StdChronoCalendarPrinter): Fix hh_mm_ss member access.
	(StdChronoTimeZonePrinter): Add equals sign to output.
	* testsuite/libstdc++-prettyprinters/chrono.cc: New test.
2023-05-09 20:36:56 +01:00
Jonathan Wakely
37c8a083d4 libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064]
libstdc++-v3/ChangeLog:

	PR libstdc++/109064
	* python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
	Remove self-recursion in __init__. Add missing _supports.
	* testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
	and unique().
2023-03-10 11:10:23 +00:00
Jakub Jelinek
83ffe9cde7 Update copyright years. 2023-01-16 11:52:17 +01:00
Jonathan Wakely
80ff207da6 libstdc++: Fix <chrono> printers for Python 2 [PR108212]
The datetime.timezone.utc singleton doesn't exist in Python 2, but we
can create it ourselves by deriving from datetime.tzinfo.

libstdc++-v3/ChangeLog:

	PR libstdc++/108212
	* python/libstdcxx/v6/printers.py (_utc_timezone): New global
	variable.
	(StdChronoTimePointPrinter::to_string): Use it.
2023-01-05 16:28:43 +00:00
Jonathan Wakely
d33a250f70 libstdc++: Add GDB printers for <chrono> types
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdChronoDurationPrinter)
	(StdChronoTimePointPrinter, StdChronoZonedTimePrinter)
	(StdChronoCalendarPrinter, StdChronoTimeZonePrinter)
	(StdChronoLeapSecondPrinter, StdChronoTzdbPrinter)
	(StdChronoTimeZoneRulePrinter): New printers.
2022-12-22 23:34:26 +00:00
Jonathan Wakely
3c54805d03 libstdc++: Fix std::any pretty printer
The recent changes to FilteringTypePrinter affect the result of
gdb.lookup_type('std::string') in StdExpAnyPrinter, causing it to always
return the std::__cxx11::basic_string specialization. This then causes a
gdb.error exception when trying to lookup the std::any manager type for
a specliaization using that string, but that manager was never
instantiated in the program. This causes FAILs when running the tests
with -D_GLIBCXX_USE_CXX11_ABI=0:

FAIL: libstdc++-prettyprinters/libfundts.cc print as
FAIL: libstdc++-prettyprinters/libfundts.cc print as

The ugly solution used in this patch is to repeat the lookup for every
type that std::string could be a typedef for, and hope it only works for
one of them.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdExpAnyPrinter): Make
	expansion of std::string in manager name more robust.
2022-11-16 13:37:38 +00:00
Jonathan Wakely
9228162202 libstdc++: Improve comments on pretty printer code
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (is_specialization_of): Fix
	incorrect terminology in docstring and describe arguments.
	(FilteringTypePrinter): Add default argument for new parameter,
	enhance docstring.
2022-11-16 13:37:37 +00:00
François Dumont
2b7f0378b9 libstdc++: Fix gdb FilteringTypePrinter
Once we found a matching FilteringTypePrinter instance we look for the associated
typedef and check that the returned Python Type is equal to the Type to recognize.
But gdb Python Type includes properties to distinguish a typedef from the actual
type. So use gdb.types.get_basic_type to check if we are indeed on the same type.

Additionnaly enhance FilteringTypePrinter matching mecanism by introducing targ1 that,
if not None, will be used as the 1st template parameter.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (FilteringTypePrinter): Rename 'match' field
	'template'. Add self.targ1 to specify the first template parameter of the instantiation
	to match.
	(add_one_type_printer): Add targ1 optional parameter, default to None.
	Use gdb.types.get_basic_type to compare the type to recognize and the type
	returned from the typedef lookup.
	(register_type_printers): Adapt calls to add_one_type_printers.
2022-11-16 06:53:31 +01:00
Jonathan Wakely
2b85d759da libstdc++: Fix installation of python files for debug lib
libstdc++-v3/ChangeLog:

	* python/Makefile.am (install-data-local): Use mkdirs_p for debug
	libdir.
	* python/Makefile.in: Regenerate.
2022-11-14 15:59:50 +00:00
Jonathan Wakely
1d9454aba6 libstdc++: Implement C++20 <format> [PR104166]
This doesn't add the newer C++23 features like formatting ranges
and escaped string prsentation types.

However, C++23 extended floating-point types are supported, as are
128-bit integers.

It could do with more tests.

libstdc++-v3/ChangeLog:

	PR libstdc++/104166
	* include/Makefile.am (std_headers): Add <format>.
	* include/Makefile.in: Regenerate.
	* include/precompiled/stdc++.h: Add <format>.
	* include/std/format: New file.
	* python/libstdcxx/v6/printers.py (StdFormatArgsPrinter): New
	printer for std::format_args.
	* testsuite/std/format/arguments/args.cc: New test.
	* testsuite/std/format/error.cc: New test.
	* testsuite/std/format/formatter.cc: New test.
	* testsuite/std/format/functions/format.cc: New test.
	* testsuite/std/format/functions/format_to_n.cc: New test.
	* testsuite/std/format/functions/size.cc: New test.
	* testsuite/std/format/functions/vformat_to.cc: New test.
	* testsuite/std/format/parse_ctx.cc: New test.
	* testsuite/std/format/string.cc: New test.
	* testsuite/std/format/string_neg.cc: New test.
2022-11-13 01:10:44 +00:00
Arsen Arsenović
655271e47f libstdc++: Don't use gstdint.h anymore
libstdc++-v3/ChangeLog:

	* configure.ac: Stop generating gstdint.h.
	* src/c++11/compatibility-atomic-c++0x.cc: Stop using gstdint.h.
	* Makefile.in: Regenerate.
	* aclocal.m4: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-10-29 00:55:42 +01:00
Jonathan Wakely
637e3668fd libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606]
Implement a long-standing request to support tuning the size of the
emergency buffer for allocating exceptions after malloc fails, or to
disable that buffer entirely.

It's now possible to disable the dynamic allocation of the buffer and
use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool.
This is a built-time choice that is baked into libstdc++ and so affects
all code linked against that build of libstdc++.

The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N
which is measured in units of sizeof(void*) not bytes. A given exception
type such as std::system_error depends on the target, so giving a size
in bytes wouldn't be portable across 16/32/64-bit targets.

When libstdc++ is configured to use a dynamic buffer, the size of that
buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES
environment variable (c.f. PR libstdc++/88264). The number of exceptions
to reserve space for is controlled by the "glibcxx.eh_pool.obj_count"
and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be
able to allocate obj_count exceptions of size obj_size*sizeof(void*) and
obj_count "dependent" exceptions rethrown by std::rethrow_exception.

With the ability to tune the buffer size, we can reduce the default pool
size on 32-bit and 16-bit targets. Most users never need to throw 1kB
exceptions in parallel from hundreds of threads after malloc is OOM. The
users who do need that can use the tunables to select larger sizes.

The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES
to:
64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112
32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104

Or approximated by configuring with:
64-bit: --with-libstdcxx-eh-pool-obj-count=252
32-bit: --with-libstdcxx-eh-pool-obj-count=94

libstdc++-v3/ChangeLog:

	PR libstdc++/68606
	* Makefile.in: Regenerate.
	* acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro.
	* configure: Regenerate.
	* configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC.
	* crossconfig.m4: Check for secure_getenv.
	* doc/Makefile.in: Regenerate.
	* doc/xml/manual/configure.xml: Document new configure options.
	* doc/xml/manual/evolution.xml: Document addition of tunables.
	* doc/xml/manual/using_exceptions.xml: Document emergency
	buffer and tunables.
	* doc/html/*: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.am: Use EH_POOL_FLAGS.
	* libsupc++/Makefile.in: Regenerate.
	* libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units
	of sizeof(void*) not including the ABI's exception header.
	(EMERGENCY_OBJ_COUNT): Define as target-independent calculation
	based on word size.
	(MAX_OBJ_COUNT): Define macro for upper limit on pool size.
	(pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer.
	(pool::buffer_size_in_bytes): New static member function.
	(pool::pool): Parse GLIBCXX_TUNABLES environment variable to set
	pool size at runtime.
	(pool::in_pool): Use std::less<void*> for total order.
	(__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing.
	(__cxa_free_exception, __cxa_free_dependent_exception): Add
	[[unlikely]] attributes.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-10-11 16:21:48 +01:00
François Dumont
4347fea9c2 libstdc++: Fix gdb pretty printers when dealing with std::string
Since revision 33b43b0d8c std::string and other
similar typedef are ambiguous from a gdb point of view because it matches both
std::basic_string<char> and std::__cxx11::basic_string<char> symbols. For those
typedef add a workaround to accept the substitution as long as the same regardless
of __cxx11 namespace.

Also avoid to register printers for types in std::__cxx11::__8:: namespace, there is
no such symbols.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (Printer.add_version): Do not add version
	namespace for __cxx11 symbols.
	(add_one_template_type_printer): Likewise.
	(add_one_type_printer): Likewise.
	(FilteringTypePrinter._recognizer.recognize): Add a workaround for std::string & al
	ambiguous typedef matching both std:: and std::__cxx11:: symbols.
	* testsuite/libstdc++-prettyprinters/cxx17.cc: Remove obsolete
	\#define _GLIBCXX_USE_CXX11_ABI 0.
	* testsuite/libstdc++-prettyprinters/simple.cc: Likewise. Adapt test to accept
	std::__cxx11::list.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/80276.cc: Likewise and remove xfail for c++20
	and debug mode.
	* testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
2022-10-03 07:01:10 +02:00
François Dumont
13337ea9a1 libstdc++: [_GLIBCXX_INLINE_VERSION] Add gdb pretty print for _GLIBCXX_DEBUG
In _GLIBCXX_DEBUG mode containers are in std::__debug namespace but not template
parameters. In _GLIBCXX_INLINE_VERSION mode most types are in std::__8 namespace but
not std::__debug containers. We need to register specific type printers for this
combination.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (add_one_template_type_printer): Register
	printer for types in std::__debug namespace with template parameters in std::__8
	namespace.
2022-09-29 20:41:37 +02:00
François Dumont
42630dc056 libstdc++: Remove useless gdb printer registrations
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py: Remove ptinter registration for non-existing
	types std::__debug::unique_ptr, std::__debug::stack, std::__debug::queue,
	std::__debug::priority_queue.
2022-09-22 06:22:59 +02:00
Philipp Fent
93257ed603 libstdc++: Add pretty printer for std::stringstreams
To display (o-,i-)stringstreams in the common case, we just print the
underlying stringbuf, without the many ios_base members. In the
unconventional case that the underlying streambuf was redirected, we
report the redirected target.

Signed-off-by: Philipp Fent <fent@in.tum.de>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (access_streambuf_ptrs):
	New helper function.
	(StdStringBufPrinter, StdStringStreamPrinter): New printers.
	(build_libstdcxx_dictionary): Register stringstream printers.
	* testsuite/libstdc++-prettyprinters/debug.cc: Check string
	streams.
	* testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
	* testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
2022-09-14 19:17:36 +01:00
Ulrich Drepper
075683767a Adjust index number of tuple pretty printer
The tuple pretty printer uses 1-based indeces which is quite confusing
considering the access to the same values with the std::get functions
uses 0-based indeces.  This patch changes the pretty printer since
this is not a guaranteed API.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (class StdTuplePrinter): Use
	zero-based indeces just like std:get takes.
2022-08-04 13:18:05 +02:00
Jonathan Wakely
11e1ee1b38 libstdc++: Fix atomic and error_code printers for versioned namespace
This fixes the printers to work with std::__8::atomic and
std::__v8::ios_errc and std::__v8::future_errc.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Make
	lookup for ios_errc and future_errc check versioned namespace.
	(StdAtomicPrinter): Strip versioned namespace from typename.
2022-05-26 22:29:04 +01:00
François Dumont
ace4b7f295 libstdc++: Fix printing of std::span for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdSpanPrinter.__init__):
	Strip typename from version namespace.
2022-05-26 11:38:34 +02:00
Jonathan Wakely
634b0089f6 libstdc++: Fix printing of std::atomic<shared_ptr<T>> for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (SharedPointerPrinter): Strip
	versioned namespace from the template argument too.
2022-05-26 10:05:51 +01:00
Jonathan Wakely
a849584587 libstdc++: Add pretty printer for std::atomic
For the atomic specializations for shared_ptr and weak_ptr we can reuse
the existing SharedPointerPrinter, with a small tweak.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (SharedPointerPrinter): Add
	support for atomic<shared_ptr<T>> and atomic<weak_ptr<T>>.
	(StdAtomicPrinter): New printer.
	(build_libstdcxx_dictionary): Register new printer.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Test std::atomic.
	* testsuite/libstdc++-prettyprinters/cxx20.cc: Test atomic smart
	pointers.
2022-04-27 15:48:32 +01:00
Philipp Fent
71999fde2a libstdc++: Add pretty printer for std::initializer_list
Re-using the std::span printer, this now shows the contents of the
initializer list instead of the pointer and length members.

Signed-off-by: Philipp Fent <fent@in.tum.de>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdSpanPrinter._iterator):
	Rename as iterator.
	(StdInitializerListPrinter): Define new printer.
	(build_libstdcxx_dictionary): Register new printer.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Check printer for
	initializer_list.
2022-04-25 13:32:04 +01:00
Philipp Fent
fdb3f82fb3 libstdc++: Add pretty printer for std::span
This improves the debug output for C++20 spans.

Before:
{static extent = 18446744073709551615, _M_ptr = 0x7fffffffb9a8, _M_extent = {_M_extent_value = 2}}
Now with StdSpanPrinter:
std::span of length 2 = {1, 2}

Signed-off-by: Philipp Fent <fent@in.tum.de>

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdSpanPrinter): Define.
	* testsuite/libstdc++-prettyprinters/cxx20.cc: Test it.
2022-04-19 14:18:33 +01:00
Jonathan Wakely
36100e0e95 libstdc++: Make std::error_code printer more robust
This attempts to implement a partial workaround for the GDB bug
https://sourceware.org/bugzilla/show_bug.cgi?id=28856 which causes GDB
to crash when printing a frame with a std::error_code argument.

By recognising the known error categories defined in the library and
hardcoding their names we do not need to call cat->name() on the
category.  This has the additional benefit of also working when
debugging a core file rather than a running process. For those known
categories we can also cast the int value to the corresponding error
code enum (e.g. future_errc) so that we show an enumerator instead of
just an integer.

For program-defined categories we just use the name of the dynamic type
to identify the category, and print the value as an integer. Once the
GDB bug is fixed and the virtual name() function can be called safely,
that would be preferable. For now it's better to have an imperfect
printer that doesn't crash GDB.

This rewritten StdErrorCodePrinter needs gdb.Value.dynamic_type, so is
only registered if that is supported, which means GDB 7.7 and later.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Replace
	code that call cat->name() on std::error_category objects.
	Identify known categories by symbol name and use a hardcoded
	name. Print error code values as enumerators where appopriate.
	* testsuite/libstdc++-prettyprinters/cxx11.cc: Adjust expected
	name of custom category. Check io_errc and future_errc errors.
2022-02-17 22:22:14 +00:00
Jonathan Wakely
3acb929cc0 libstdc++: Define <stacktrace> header for C++23
Add the <stacktrace> header and a new libstdc++_libbacktrace.a library
that provides the implementation. For now, the new library is only built
if --enable-libstdcxx-backtrace=yes is used. As with the Filesystem TS,
the new library is only provided as a static archive.

libstdc++-v3/ChangeLog:

	* acinclude.m4 (GLIBCXX_ENABLE_BACKTRACE): New macro.
	* configure.ac: Use GLIBCXX_ENABLE_BACKTRACE.
	* include/Makefile.am: Add new header.
	* include/Makefile.in: Regenerate.
	* include/std/stacktrace: New header.
	* include/std/version (__cpp_lib_stacktrace): Define.
	* Makefile.in: Regenerate.
	* config.h.in: Regenerate.
	* configure: Regenerate.
	* doc/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.am: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
	* src/libbacktrace/Makefile.am: New file.
	* src/libbacktrace/Makefile.in: New file.
	* src/libbacktrace/backtrace-rename.h: New file.
	* src/libbacktrace/backtrace-supported.h.in: New file.
	* src/libbacktrace/config.h.in: New file.
	* testsuite/lib/libstdc++.exp (check_effective_target_stacktrace):
	New proc.
	* testsuite/20_util/stacktrace/entry.cc: New test.
	* testsuite/20_util/stacktrace/synopsis.cc: New test.
	* testsuite/20_util/stacktrace/version.cc: New test.
2022-01-17 12:13:02 +00:00
Jonathan Wakely
68c2e9e923 libstdc++: Fix and simplify freestanding configuration [PR103866]
This fixes the --disable-hosted-libstdcxx build so that it works with
--without-headers. Currently you need to also use --with-newlib, which
is confusing for users who aren't actually using newlib.

The AM_PROG_LIBTOOL checks are currently skipped for --with-newlib and
--with-avrlibc builds, with this change they are also skipped when using
--without-headers.  It would be nice if using --disable-hosted-libstdcxx
automatically skipped those checks, but GLIBCXX_ENABLE_HOSTED comes too
late to make the AM_PROG_LIBTOOL checks depend on $is_hosted.

The checks for EOF, SEEK_CUR etc. cause the build to fail if there is no
<stdio.h> available.  Unlike most headers, which get a HAVE_FOO_H macro,
<stdio.h> is in autoconf's default includes, so every check tries to
include it unconditionally. This change skips those checks for
freestanding builds.

Similarly, the checks for <stdint.h> types done by GCC_HEADER_STDINT try
to include <stdio.h> and fail for --without-headers builds. This change
skips the use of GCC_HEADER_STDINT for freestanding. We can probably
stop using GCC_HEADER_STDINT entirely, since only one file uses the
gstdint.h header that is generated, and that could easily be changed to
use <stdint.h> instead. That can wait for stage 1.

We also need to skip the GLIBCXX_CROSSCONFIG stage if --without-headers
was used, since we don't have any of the functions it deals with.

The end result of the changes above is that it should not be necessary
for a --disable-hosted-libstdcxx --without-headers build to also use
--with-newlib.

Finally, compile libsupc++ with -ffreestanding when --without-headers is
used, so that <stdint.h> will use <gcc-stdint.h> instead of expecting it
to come from libc.

libstdc++-v3/ChangeLog:

	PR libstdc++/103866
	* acinclude.m4 (GLIBCXX_COMPUTE_STDIO_INTEGER_CONSTANTS): Do
	nothing for freestanding builds.
	(GLIBCXX_ENABLE_HOSTED): Define FREESTANDING_FLAGS.
	* configure.ac: Do not use AC_LIBTOOL_DLOPEN when configured
	with --without-headers.  Do not use GCC_HEADER_STDINT for
	freestanding builds.
	* libsupc++/Makefile.am (HOSTED_CXXFLAGS): Use -ffreestanding
	for freestanding builds.
	* configure: Regenerate.
	* Makefile.in: Regenerate.
	* doc/Makefile.in: Regenerate.
	* include/Makefile.in: Regenerate.
	* libsupc++/Makefile.in: Regenerate.
	* po/Makefile.in: Regenerate.
	* python/Makefile.in: Regenerate.
	* src/Makefile.in: Regenerate.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++17/Makefile.in: Regenerate.
	* src/c++20/Makefile.in: Regenerate.
	* src/c++98/Makefile.in: Regenerate.
	* src/filesystem/Makefile.in: Regenerate.
	* testsuite/Makefile.in: Regenerate.
2022-01-10 12:18:14 +00:00
Jonathan Wakely
1918067e2d libstdc++: Fix std::error_code pretty printer for versioned namespace
libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdErrorCodePrinter): Strip
	versioned namespace from the type name that is printed.
2022-01-05 14:17:50 +00:00
Jonathan Wakely
7a2f2d91aa libstdc++: Add pretty printer for std::regex internals
This helps visualize the NFA states in a std::regex.  It probably isn't
very useful for users, but helps when working on the implementation.

libstdc++-v3/ChangeLog:

	* python/libstdcxx/v6/printers.py (StdRegexStatePrinter): New
	printer for std::regex NFA states.
2022-01-05 13:47:02 +00:00
Jakub Jelinek
7adcbafe45 Update copyright years. 2022-01-03 10:42:10 +01:00