[PATCH] Fix gdb printers for std::string

François Dumont frs.dumont@gmail.com
Sat Oct 1 07:20:31 GMT 2022


I had forgotten to re-run tests after I removed the #define 
_GLIBCXX_USE_CXX11_ABI 0.

The comment was misleading, it could also impact output of std::list.

I am also restoring the correct std::string alias for 
std::__cxx11::basic_string, even if with my workaround it doesn't really 
matter as the one for std::basic_string will be used.

I also restored the printer for std::__cxx11::string typedef. Is it 
intentional to keep this ?

     libstdc++: Fix gdb pretty printers when dealing with std::string

     Since revision 33b43b0d8cd2de722d177ef823930500948a7487 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:

             * libstdc++-v3/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.
             (register_type_printers): Refine type registration to limit 
false positive in
             FilteringTypePrinter._recognize.recognize requiring to look 
for the type in gdb.
             * libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc: 
Remove obsolete
             \#define _GLIBCXX_USE_CXX11_ABI 0.
             * 
libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc: Likewise. 
Adapt test
             to accept std::__cxx11::list.
             * 
libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
             * 
libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
             * libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc: 
Likewise and remove
             xfail for c++20 and debug mode.
             * 
libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.

Ok to commit ?

François

On 28/09/22 22:42, François Dumont wrote:
> Sometimes substitution of basic_string by one of the std::string 
> typeedef fails. Here is the fix.
>
>     libstdc++: Fix gdb pretty printers when dealing with std::string
>
>     Since revision 33b43b0d8cd2de722d177ef823930500948a7487 
> 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:
>
>             * libstdc++-v3/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.
>             (register_type_printers): Refine type registration to 
> limit false positive in
>             FilteringTypePrinter._recognize.recognize requiring to 
> look for the type in gdb.
>             * 
> libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc: Remove obsolete
>             \#define _GLIBCXX_USE_CXX11_ABI 0.
>             * 
> libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc: Likewise.
>             * 
> libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc: Likewise.
>             * 
> libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
>             * 
> libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc: Likewise and 
> remove
>             xfail for c++20 and debug mode.
>             * 
> libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc: Likewise.
>
> Tested under x86_64 linux w/o _GLIBCXX_INLINE_VERSION and w/o 
> _GLIBCXX_DEBUG.
>
> I also tested it with my patch to use cxx11 abi in 
> _GLIBCXX_INLINE_VERSION mode.
>
> Ok to commit ?
>
> François

-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb_printers.patch
Type: text/x-patch
Size: 11451 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20221001/6bd3b6fc/attachment-0001.bin>


More information about the Libstdc++ mailing list