diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py index 245b6e3dbcd..b4878b93bb2 100644 --- a/libstdc++-v3/python/libstdcxx/v6/printers.py +++ b/libstdc++-v3/python/libstdcxx/v6/printers.py @@ -1857,7 +1857,7 @@ class Printer(object): # Add a name using _GLIBCXX_BEGIN_NAMESPACE_VERSION. def add_version(self, base, name, function): self.add(base + name, function) - if _versioned_namespace: + if _versioned_namespace and not '__cxx11' in base: vbase = re.sub('^(std|__gnu_cxx)::', r'\g<0>%s' % _versioned_namespace, base) self.add(vbase + name, function) @@ -2026,7 +2026,7 @@ def add_one_template_type_printer(obj, name, defargs): printer = TemplateTypePrinter('std::__debug::'+name, defargs) gdb.types.register_type_printer(obj, printer) - if _versioned_namespace: + if _versioned_namespace and not '__cxx11' in name: # Add second type printer for same type in versioned namespace: ns = 'std::' + _versioned_namespace # PR 86112 Cannot use dict comprehension here: @@ -2084,6 +2084,21 @@ class FilteringTypePrinter(object): pass if self.type_obj == type_obj: return strip_inline_namespaces(self.name) + + if self.type_obj is None: + return None + + # Workaround ambiguous typedefs matching both std:: and std::__cxx11:: symbols. + ambiguous = False + for ch in ('', 'w', 'u8', 'u16', 'u32'): + if self.name == 'std::' + ch + 'string': + ambiguous = True + break + + if ambiguous: + if self.type_obj.tag.replace('__cxx11::', '') == type_obj.tag.replace('__cxx11::', ''): + return strip_inline_namespaces(self.name) + return None def instantiate(self): @@ -2093,7 +2108,7 @@ class FilteringTypePrinter(object): def add_one_type_printer(obj, match, name): printer = FilteringTypePrinter('std::' + match, 'std::' + name) gdb.types.register_type_printer(obj, printer) - if _versioned_namespace: + if _versioned_namespace and not '__cxx11' in match: ns = 'std::' + _versioned_namespace printer = FilteringTypePrinter(ns + match, ns + name) gdb.types.register_type_printer(obj, printer) @@ -2105,29 +2120,26 @@ def register_type_printers(obj): return # Add type printers for typedefs std::string, std::wstring etc. - for ch in ('', 'w', 'u8', 'u16', 'u32'): - add_one_type_printer(obj, 'basic_string', ch + 'string') - add_one_type_printer(obj, '__cxx11::basic_string', ch + 'string') - # Typedefs for __cxx11::basic_string used to be in namespace __cxx11: - add_one_type_printer(obj, '__cxx11::basic_string', - '__cxx11::' + ch + 'string') - add_one_type_printer(obj, 'basic_string_view', ch + 'string_view') + for ch in (('char', ''), ('wchar_t', 'w'), ('char8_t', 'u8'), ('char16_t', 'u16'), ('char32_t', 'u32')): + add_one_type_printer(obj, 'basic_string<' + ch[0], ch[1] + 'string') + add_one_type_printer(obj, '__cxx11::basic_string<' + ch[0], '__cxx11::' + ch[1] + 'string') + add_one_type_printer(obj, 'basic_string_view<' + ch[0], ch[1] + 'string_view') # Add type printers for typedefs std::istream, std::wistream etc. - for ch in ('', 'w'): + for ch in (('char', ''), ('wchar_t', 'w')): for x in ('ios', 'streambuf', 'istream', 'ostream', 'iostream', 'filebuf', 'ifstream', 'ofstream', 'fstream'): - add_one_type_printer(obj, 'basic_' + x, ch + x) + add_one_type_printer(obj, 'basic_' + x + '<' + ch[0], ch[1] + x) for x in ('stringbuf', 'istringstream', 'ostringstream', 'stringstream'): - add_one_type_printer(obj, 'basic_' + x, ch + x) + add_one_type_printer(obj, 'basic_' + x, ch[1] + x) # types are in __cxx11 namespace, but typedefs aren't: - add_one_type_printer(obj, '__cxx11::basic_' + x, ch + x) + add_one_type_printer(obj, '__cxx11::basic_' + x + '<' + ch[0], ch[1] + 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 (('char', ''), ('wchar_t', 'w')): + add_one_type_printer(obj, abi + 'basic_regex<' + ch[0], abi + ch[1] + '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'): diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc index 4abe7d384e8..d1016b58d79 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/80276.cc @@ -18,9 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// Type printers only recognize the old std::string for now. -#define _GLIBCXX_USE_CXX11_ABI 0 - #include #include #include @@ -46,7 +43,7 @@ main() // { dg-final { whatis-regexp-test p1 "std::unique_ptr\\*>>>" } } // { dg-final { whatis-regexp-test p2 "std::unique_ptr\\*>>\\\[\\\]>" } } // { dg-final { whatis-regexp-test p3 "std::unique_ptr\\*>>\\\[10\\\]>" } } - // { dg-final { whatis-regexp-test p4 "std::unique_ptr\\\[\\\]>>\\\[99\\\]>" { xfail { c++20 || debug_mode } } } } + // { dg-final { whatis-regexp-test p4 "std::unique_ptr\\\[\\\]>>\\\[99\\\]>" } } placeholder(&p1); // Mark SPOT placeholder(&p2); diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc index e52ffbbcc15..cf699d22e78 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx17.cc @@ -18,9 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// Type printers only recognize the old std::string for now. -#define _GLIBCXX_USE_CXX11_ABI 0 - #include #include #include diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc index e81308d4f7e..b2f464d0894 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/libfundts.cc @@ -18,9 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// Type printers only recognize the old std::string for now. -#define _GLIBCXX_USE_CXX11_ABI 0 - #include #include #include @@ -50,7 +47,7 @@ main() om = std::map{ {1, 2.}, {3, 4.}, {5, 6.} }; // { dg-final { regexp-test om {std::experimental::optional> containing std::(__debug::)?map with 3 elements = {\[1\] = 2, \[3\] = 4, \[5\] = 6}} } } optional os{ "stringy" }; -// { dg-final { note-test os {std::experimental::optional = {[contained value] = "stringy"}} { xfail { c++20 || debug_mode } } } } +// { dg-final { note-test os {std::experimental::optional = {[contained value] = "stringy"}} } } any a; // { dg-final { note-test a {std::experimental::any [no contained value]} } } @@ -61,7 +58,7 @@ main() any ap = (void*)nullptr; // { dg-final { note-test ap {std::experimental::any containing void * = {[contained value] = 0x0}} } } any as = *os; -// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} { xfail { c++20 || debug_mode } } } } +// { dg-final { note-test as {std::experimental::any containing std::string = {[contained value] = "stringy"}} } } any as2("stringiest"); // { dg-final { regexp-test as2 {std::experimental::any containing const char \* = {\[contained value\] = 0x[[:xdigit:]]+ "stringiest"}} } } any am = *om; diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc index 1609ae2c8db..3d14120371e 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple.cc @@ -20,9 +20,6 @@ // with this library; see the file COPYING3. If not see // . -// Type printers only recognize the old std::string for now. -#define _GLIBCXX_USE_CXX11_ABI 0 - #include #include #include diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc index a4b82e30f9c..367e04579ca 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/simple11.cc @@ -20,9 +20,6 @@ // with this library; see the file COPYING3. If not see // . -// Type printers only recognize the old std::string for now. -#define _GLIBCXX_USE_CXX11_ABI 0 - #include #include #include diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc index 046d26f0020..23b9947a5de 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/whatis.cc @@ -18,10 +18,6 @@ // with this library; see the file COPYING3. If not see // . -// GDB can't find global variables using the abi_tag attribute. -// https://sourceware.org/bugzilla/show_bug.cgi?id=19436 -#define _GLIBCXX_USE_CXX11_ABI 0 - #include #include #include