Commit f9a27859 by François Dumont Committed by Jonathan Wakely

Make Python printers and xmethods work with versioned namespace

2017-01-10  François Dumont  <fdumont@gcc.gnu.org>
	    Jonathan Wakely  <jwakely@redhat.com>

	* python/libstdcxx/v6/printers.py (_versioned_namespace): Define.
	(is_specialization, strip_versioned_namespace): New helpers functions
	to work with symbols in the versioned namespace.
	(Printer.add_version): Add second name using versioned namespace.
	(add_one_template_type_printer, add_one_type_printer): Add second
	type printers using versioned namespace.
	(register_type_printers): Add template type printer for basic_string.
	(build_libstdcxx_dictionary): Remove dead code.
	* python/libstdcxx/v6/xmethods.py: Make all matchers look for
	versioned namespace.
	* testsuite/libstdc++-prettyprinters/48362.cc: Adjust expected
	results.
	* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.

Co-Authored-By: Jonathan Wakely <jwakely@redhat.com>

From-SVN: r244262
parent ad730fac
2017-01-10 François Dumont <fdumont@gcc.gnu.org>
Jonathan Wakely <jwakely@redhat.com>
* python/libstdcxx/v6/printers.py (_versioned_namespace): Define.
(is_specialization, strip_versioned_namespace): New helpers functions
to work with symbols in the versioned namespace.
(Printer.add_version): Add second name using versioned namespace.
(add_one_template_type_printer, add_one_type_printer): Add second
type printers using versioned namespace.
(register_type_printers): Add template type printer for basic_string.
(build_libstdcxx_dictionary): Remove dead code.
* python/libstdcxx/v6/xmethods.py: Make all matchers look for
versioned namespace.
* testsuite/libstdc++-prettyprinters/48362.cc: Adjust expected
results.
* testsuite/libstdc++-prettyprinters/whatis.cc: Likewise.
2017-01-09 Jonathan Wakely <jwakely@redhat.com>
PR libstdc++/79017
......
......@@ -148,7 +148,7 @@ class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::array<.*>$', class_type.tag):
if not re.match('^std::(__\d+::)?array<.*>$', class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......@@ -265,7 +265,7 @@ class DequeMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::deque<.*>$', class_type.tag):
if not re.match('^std::(__\d+::)?deque<.*>$', class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......@@ -309,7 +309,7 @@ class ForwardListMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::forward_list<.*>$', class_type.tag):
if not re.match('^std::(__\d+::)?forward_list<.*>$', class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......@@ -390,7 +390,7 @@ class ListMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::(__cxx11::)?list<.*>$', class_type.tag):
if not re.match('^std::(__\d+::)?(__cxx11::)?list<.*>$', class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......@@ -505,7 +505,7 @@ class VectorMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::vector<.*>$', class_type.tag):
if not re.match('^std::(__\d+::)?vector<.*>$', class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......@@ -554,7 +554,7 @@ class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::%s<.*>$' % self._name, class_type.tag):
if not re.match('^std::(__\d+::)?%s<.*>$' % self._name, class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......@@ -586,9 +586,9 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker):
def __call__(self, obj):
impl_type = obj.dereference().type.fields()[0].type.tag
if impl_type.startswith('std::__uniq_ptr_impl<'): # New implementation
if re.match('^std::(__\d+::)?__uniq_ptr_impl<.*>$', impl_type): # New implementation
return obj['_M_t']['_M_t']['_M_head_impl']
elif impl_type.startswith('std::tuple<'):
elif re.match('^std::(__\d+::)?tuple<.*>$', impl_type):
return obj['_M_t']['_M_head_impl']
return None
......@@ -640,7 +640,7 @@ class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::unique_ptr<.*>$', class_type.tag):
if not re.match('^std::(__\d+::)?unique_ptr<.*>$', class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......@@ -758,7 +758,7 @@ class SharedPtrMethodsMatcher(gdb.xmethod.XMethodMatcher):
self.methods = [self._method_dict[m] for m in self._method_dict]
def match(self, class_type, method_name):
if not re.match('^std::shared_ptr<.*>$', class_type.tag):
if not re.match('^std::(__\d+::)?shared_ptr<.*>$', class_type.tag):
return None
method = self._method_dict.get(method_name)
if method is None or not method.enabled:
......
......@@ -26,10 +26,10 @@ int
main()
{
std::tuple<> t1;
// { dg-final { regexp-test t1 {empty std::(__7::)?tuple} } }
// { dg-final { regexp-test t1 {empty std::tuple} } }
std::tuple<std::string, int, std::tuple<>> t2{ "Johnny", 5, {} };
// { dg-final { regexp-test t2 {std::(__7::)?tuple containing = {\[1\] = "Johnny", \[2\] = 5, \[3\] = {<std::(__7::)?tuple<>> = empty std::(__7::)?tuple, <No data fields>}}} } }
// { dg-final { regexp-test t2 {std::tuple containing = {\[1\] = "Johnny", \[2\] = 5, \[3\] = {<std::(__7::)?tuple<>> = empty std::tuple, <No data fields>}}} } }
std::cout << "\n";
return 0; // Mark SPOT
......
......@@ -166,11 +166,11 @@ holder<std::knuth_b> knuth_b_holder;
ustring *ustring_ptr;
holder<ustring> ustring_holder;
// { dg-final { whatis-test ustring_holder "holder<std::basic_string<unsigned char, std::char_traits<unsigned char>, std::allocator<unsigned char> > >" } }
// { 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::char_traits<signed char>, std::allocator<signed char> > >" } }
// { dg-final { whatis-test sstring_holder "holder<std::basic_string<signed char> >" } }
std::vector<std::deque<std::unique_ptr<char>>> *seq1_ptr;
holder< std::vector<std::deque<std::unique_ptr<char>>> > seq1_holder;
......
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