Skip to content
Snippets Groups Projects
  1. Sep 28, 2023
    • Tom Tromey's avatar
      libstdc++: Remove unused Python imports · bed1f849
      Tom Tromey authored
      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'.
      bed1f849
    • Tom Tromey's avatar
      libstdc++: Use gdb.ValuePrinter base class · 64f12103
      Tom Tromey authored
      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 "_".
      64f12103
    • Jonathan Wakely's avatar
      libstdc++: Refactor Python Xmethods to use is_specialization_of · 17d3477f
      Jonathan Wakely authored
      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.
      17d3477f
    • Jonathan Wakely's avatar
      libstdc++: Reformat Python code · 6b5c3f9b
      Jonathan Wakely authored
      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.
      6b5c3f9b
    • Jonathan Wakely's avatar
      libstdc++: Format Python docstrings according to PEP 357 · 0ef4cc82
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	* python/libstdcxx/v6/printers.py: Format docstrings according
      	to PEP 257.
      	* python/libstdcxx/v6/xmethods.py: Likewise.
      0ef4cc82
  2. Sep 27, 2023
  3. Sep 12, 2023
  4. Aug 24, 2023
    • Jonathan Wakely's avatar
      libstdc++: Add pretty printer for std::locale · 3d2e240a
      Jonathan Wakely authored
      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.
      3d2e240a
    • Jonathan Wakely's avatar
      libstdc++: Declutter std::optional and std:variant pretty printers [PR110944] · 701ce3c7
      Jonathan Wakely authored
      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.
      701ce3c7
  5. Aug 11, 2023
    • Jonathan Wakely's avatar
      libstdc++: Handle invalid values in std::chrono pretty printers · c19b542a
      Jonathan Wakely authored
      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.
      c19b542a
  6. May 09, 2023
    • Jonathan Wakely's avatar
      libstdc++: Fix <chrono> pretty printers and add tests · 7bd251ca
      Jonathan Wakely authored
      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.
      7bd251ca
  7. Mar 10, 2023
  8. Jan 16, 2023
  9. Jan 05, 2023
    • Jonathan Wakely's avatar
      libstdc++: Fix <chrono> printers for Python 2 [PR108212] · 80ff207d
      Jonathan Wakely authored
      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.
      80ff207d
  10. Dec 22, 2022
    • Jonathan Wakely's avatar
      libstdc++: Add GDB printers for <chrono> types · d33a250f
      Jonathan Wakely authored
      libstdc++-v3/ChangeLog:
      
      	* python/libstdcxx/v6/printers.py (StdChronoDurationPrinter)
      	(StdChronoTimePointPrinter, StdChronoZonedTimePrinter)
      	(StdChronoCalendarPrinter, StdChronoTimeZonePrinter)
      	(StdChronoLeapSecondPrinter, StdChronoTzdbPrinter)
      	(StdChronoTimeZoneRulePrinter): New printers.
      d33a250f
  11. Nov 16, 2022
    • Jonathan Wakely's avatar
      libstdc++: Fix std::any pretty printer · 3c54805d
      Jonathan Wakely authored
      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.
      3c54805d
    • Jonathan Wakely's avatar
      libstdc++: Improve comments on pretty printer code · 92281622
      Jonathan Wakely authored
      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.
      92281622
    • François Dumont's avatar
      libstdc++: Fix gdb FilteringTypePrinter · 2b7f0378
      François Dumont authored
      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.
      2b7f0378
  12. Nov 14, 2022
  13. Nov 13, 2022
    • Jonathan Wakely's avatar
      libstdc++: Implement C++20 <format> [PR104166] · 1d9454ab
      Jonathan Wakely authored
      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.
      1d9454ab
  14. Oct 28, 2022
    • Arsen Arsenović's avatar
      libstdc++: Don't use gstdint.h anymore · 655271e4
      Arsen Arsenović authored
      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.
      655271e4
  15. Oct 11, 2022
    • Jonathan Wakely's avatar
      libstdc++: Allow emergency EH alloc pool size to be tuned [PR68606] · 637e3668
      Jonathan Wakely authored
      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.
      637e3668
  16. Oct 03, 2022
    • François Dumont's avatar
      libstdc++: Fix gdb pretty printers when dealing with std::string · 4347fea9
      François Dumont authored
      Since revision 33b43b0d 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.
      4347fea9
  17. Sep 29, 2022
    • François Dumont's avatar
      libstdc++: [_GLIBCXX_INLINE_VERSION] Add gdb pretty print for _GLIBCXX_DEBUG · 13337ea9
      François Dumont authored
      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.
      13337ea9
  18. Sep 22, 2022
  19. Sep 14, 2022
    • Philipp Fent's avatar
      libstdc++: Add pretty printer for std::stringstreams · 93257ed6
      Philipp Fent authored
      
      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: default avatarPhilipp 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.
      93257ed6
  20. Aug 04, 2022
    • Ulrich Drepper's avatar
      Adjust index number of tuple pretty printer · 07568376
      Ulrich Drepper authored
      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.
      07568376
  21. May 26, 2022
  22. Apr 27, 2022
    • Jonathan Wakely's avatar
      libstdc++: Add pretty printer for std::atomic · a8495845
      Jonathan Wakely authored
      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.
      a8495845
  23. Apr 25, 2022
    • Philipp Fent's avatar
      libstdc++: Add pretty printer for std::initializer_list · 71999fde
      Philipp Fent authored
      
      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: default avatarPhilipp 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.
      71999fde
  24. Apr 19, 2022
    • Philipp Fent's avatar
      libstdc++: Add pretty printer for std::span · fdb3f82f
      Philipp Fent authored
      
      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: default avatarPhilipp Fent <fent@in.tum.de>
      
      libstdc++-v3/ChangeLog:
      
      	* python/libstdcxx/v6/printers.py (StdSpanPrinter): Define.
      	* testsuite/libstdc++-prettyprinters/cxx20.cc: Test it.
      fdb3f82f
  25. Feb 17, 2022
    • Jonathan Wakely's avatar
      libstdc++: Make std::error_code printer more robust · 36100e0e
      Jonathan Wakely authored
      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.
      36100e0e
  26. Jan 17, 2022
    • Jonathan Wakely's avatar
      libstdc++: Define <stacktrace> header for C++23 · 3acb929c
      Jonathan Wakely authored
      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.
      3acb929c
  27. Jan 10, 2022
    • Jonathan Wakely's avatar
      libstdc++: Fix and simplify freestanding configuration [PR103866] · 68c2e9e9
      Jonathan Wakely authored
      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.
      68c2e9e9
  28. Jan 05, 2022
  29. Jan 03, 2022
  30. Nov 04, 2021
    • Jonathan Wakely's avatar
      libstdc++: Fix pretty printing of std::unique_ptr [PR103086] · a634928f
      Jonathan Wakely authored
      Since std::tuple started using [[no_unique_address]] the tuple<T*, D>
      member of std::unique_ptr<T, D> has two _M_head_impl subobjects, in
      different base classes. That means this printer code is ambiguous:
      
          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']
      
      In older versions of GDB it happened to work by chance, because GDB
      returned the last _M_head_impl member and std::tuple's base classes are
      stored in reverse order, so the last one was the T* element of the
      tuple. Since GDB 11 it returns the first _M_head_impl, which is the
      deleter element.
      
      The fix is for the printer to stop using an ambiguous field name and
      cast the tuple to the correct base class before accessing the
      _M_head_impl member.
      
      Instead of fixing this in both UniquePointerPrinter and StdPathPrinter a
      new unique_ptr_get function is defined to do it correctly. That is
      defined in terms of new tuple_get and _tuple_impl_get functions.
      
      It would be possible to reuse _tuple_impl_get to access each element in
      StdTuplePrinter._iterator.__next__, but that already does the correct
      casting, and wouldn't be much simpler anyway.
      
      libstdc++-v3/ChangeLog:
      
      	PR libstdc++/103086
      	* python/libstdcxx/v6/printers.py (_tuple_impl_get): New helper
      	for accessing the tuple element stored in a _Tuple_impl node.
      	(tuple_get): New function for accessing a tuple element.
      	(unique_ptr_get): New function for accessing a unique_ptr.
      	(UniquePointerPrinter, StdPathPrinter): Use unique_ptr_get.
      	* python/libstdcxx/v6/xmethods.py (UniquePtrGetWorker): Cast
      	tuple to its base class before accessing _M_head_impl.
      a634928f
Loading