Commit bab0a26d by Jonathan Wakely Committed by Jonathan Wakely

PR libstdc++/80276 fix template argument handling in type printers

	PR libstdc++/80276
	* python/libstdcxx/v6/printers.py (strip_inline_namespaces): New.
	(get_template_arg_list): New.
	(StdVariantPrinter._template_args): Remove, use get_template_arg_list
	instead.
	(TemplateTypePrinter): Rewrite to work with gdb.Type objects instead
	of strings and regular expressions.
	(add_one_template_type_printer): Adapt to new TemplateTypePrinter.
	(FilteringTypePrinter): Add docstring. Match using startswith. Use
	strip_inline_namespaces instead of strip_versioned_namespace.
	(add_one_type_printer): Prepend namespace to match argument.
	(register_type_printers): Add type printers for char16_t and char32_t
	string types and for types using cxx11 ABI. Update calls to
	add_one_template_type_printer to provide default argument dicts.
	* testsuite/libstdc++-prettyprinters/80276.cc: New test.
	* testsuite/libstdc++-prettyprinters/whatis.cc: Remove tests for
	basic_string<unsigned char> and basic_string<signed char>.
	* testsuite/libstdc++-prettyprinters/whatis2.cc: Duplicate whatis.cc
	to test local variables, without overriding _GLIBCXX_USE_CXX11_ABI.

From-SVN: r256689
parent ed99ae13
2018-01-15 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/80276
* python/libstdcxx/v6/printers.py (strip_inline_namespaces): New.
(get_template_arg_list): New.
(StdVariantPrinter._template_args): Remove, use get_template_arg_list
instead.
(TemplateTypePrinter): Rewrite to work with gdb.Type objects instead
of strings and regular expressions.
(add_one_template_type_printer): Adapt to new TemplateTypePrinter.
(FilteringTypePrinter): Add docstring. Match using startswith. Use
strip_inline_namespaces instead of strip_versioned_namespace.
(add_one_type_printer): Prepend namespace to match argument.
(register_type_printers): Add type printers for char16_t and char32_t
string types and for types using cxx11 ABI. Update calls to
add_one_template_type_printer to provide default argument dicts.
* testsuite/libstdc++-prettyprinters/80276.cc: New test.
* testsuite/libstdc++-prettyprinters/whatis.cc: Remove tests for
basic_string<unsigned char> and basic_string<signed char>.
* testsuite/libstdc++-prettyprinters/whatis2.cc: Duplicate whatis.cc
to test local variables, without overriding _GLIBCXX_USE_CXX11_ABI.
2018-01-14 Andreas Schwab <schwab@linux-m68k.org> 2018-01-14 Andreas Schwab <schwab@linux-m68k.org>
PR libstdc++/81092 PR libstdc++/81092
......
// { dg-do run { target c++11 } }
// { dg-options "-g -O0" }
// { dg-skip-if "" { *-*-* } { "-D_GLIBCXX_PROFILE" } }
// Copyright (C) 2018 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library 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, or (at your option)
// any later version.
// This library 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 library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <iostream>
#include <list>
#include <memory>
#include <set>
#include <string>
#include <vector>
template<class T>
void
placeholder(const T *s)
{
std::cout << (void *) s;
}
int
main()
{
using namespace std;
unique_ptr<vector<unique_ptr<vector<int>*>>> p1;
unique_ptr<vector<unique_ptr<set<int>*>>[]> p2;
unique_ptr<set<unique_ptr<vector<int>*>>[10]> p3;
unique_ptr<vector<unique_ptr<list<std::string>[]>>[99]> p4;
// { dg-final { whatis-test p1 "std::unique_ptr<std::vector<std::unique_ptr<std::vector<int>*>>>" } }
// { dg-final { whatis-test p2 "std::unique_ptr<std::vector<std::unique_ptr<std::set<int>*>>\[\]>" } }
// { dg-final { whatis-test p3 "std::unique_ptr<std::set<std::unique_ptr<std::vector<int>*>>\[10\]>" } }
// { dg-final { whatis-test p4 "std::unique_ptr<std::vector<std::unique_ptr<std::list<std::string>\[\]>>\[99\]>" } }
placeholder(&p1); // Mark SPOT
placeholder(&p2);
placeholder(&p3);
placeholder(&p4);
std::cout << "\n";
return 0;
}
// { dg-final { gdb-test SPOT } }
...@@ -19,7 +19,8 @@ ...@@ -19,7 +19,8 @@
// with this library; see the file COPYING3. If not see // with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>. // <http://www.gnu.org/licenses/>.
// Type printers only recognize the old std::string for now. // 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 #define _GLIBCXX_USE_CXX11_ABI 0
#include <string> #include <string>
...@@ -49,8 +50,6 @@ struct holder ...@@ -49,8 +50,6 @@ struct holder
T *f; T *f;
}; };
typedef std::basic_string<unsigned char> ustring;
// This test is written in a somewhat funny way. // This test is written in a somewhat funny way.
// Each type under test is used twice: first, to form a pointer type, // Each type under test is used twice: first, to form a pointer type,
// and second, as a template parameter. This is done to work around // and second, as a template parameter. This is done to work around
...@@ -165,14 +164,6 @@ std::knuth_b *knuth_b_ptr; ...@@ -165,14 +164,6 @@ std::knuth_b *knuth_b_ptr;
holder<std::knuth_b> knuth_b_holder; holder<std::knuth_b> knuth_b_holder;
// { dg-final { whatis-test knuth_b_holder "holder<std::knuth_b>" } } // { dg-final { whatis-test knuth_b_holder "holder<std::knuth_b>" } }
ustring *ustring_ptr;
holder<ustring> ustring_holder;
// { dg-final { whatis-test ustring_holder "holder<std::basic_string<unsigned char> >" } }
std::basic_string<signed char> *sstring_ptr;
holder< std::basic_string<signed char> > sstring_holder;
// { dg-final { whatis-test sstring_holder "holder<std::basic_string<signed char> >" } }
std::vector<std::deque<std::unique_ptr<char>>> *seq1_ptr; std::vector<std::deque<std::unique_ptr<char>>> *seq1_ptr;
holder< std::vector<std::deque<std::unique_ptr<char>>> > seq1_holder; holder< std::vector<std::deque<std::unique_ptr<char>>> > seq1_holder;
// { dg-final { whatis-test seq1_holder "holder<std::vector<std::deque<std::unique_ptr<char>>> >" } } // { dg-final { whatis-test seq1_holder "holder<std::vector<std::deque<std::unique_ptr<char>>> >" } }
...@@ -271,10 +262,6 @@ main() ...@@ -271,10 +262,6 @@ main()
placeholder(&ranlux48_holder); placeholder(&ranlux48_holder);
placeholder(&knuth_b_ptr); placeholder(&knuth_b_ptr);
placeholder(&knuth_b_holder); placeholder(&knuth_b_holder);
placeholder(&ustring_ptr);
placeholder(&ustring_holder);
placeholder(&sstring_ptr);
placeholder(&sstring_holder);
placeholder(&seq1_ptr); placeholder(&seq1_ptr);
placeholder(&seq1_holder); placeholder(&seq1_holder);
placeholder(&seq2_ptr); placeholder(&seq2_ptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment