diff options
author | Doug Evans <dje@google.com> | 2015-04-29 22:50:31 +0000 |
---|---|---|
committer | Doug Evans <devans@gcc.gnu.org> | 2015-04-29 22:50:31 +0000 |
commit | 8996b63b093db0afcaaa13c6bb79baf6439a60d0 (patch) | |
tree | 048767fd59972361cef4a8feef8ae8c8577a891a | |
parent | 1dea42c94bf801399e23d7e952fa058f3541de4c (diff) | |
download | gcc-8996b63b093db0afcaaa13c6bb79baf6439a60d0.zip gcc-8996b63b093db0afcaaa13c6bb79baf6439a60d0.tar.gz gcc-8996b63b093db0afcaaa13c6bb79baf6439a60d0.tar.bz2 |
re PR libstdc++/65839 (xmethods need updating once gdb decides how to fix 18285)
PR libstdc++/65839
* python/libstdcxx/v6/xmethods.py (get_bool_type): New function.
Replace all lookups of "bool" with this.
(get_std_size_type): New function. Replace all lookups of std::size_t
with this.
(*Worker): New method get_result_type.
(DequeWorkerBase.__init__): New arg val_type. All callers updated.
(ListWorkerBase.__init__): New arg val_type. All callers updated.
(UniquePtrGetWorker.__init__): New arg elem_type. All callers updated.
Delete setting of name, enabled.
(UniquePtrDerefWorker.__init__): New arg elem_type. All callers
updated. Delete setting of name.
(UniquePtrMethodsMatcher): Rewrite for consistency with all other
libstdc++ xmethod matchers.
* testsuite/libstdc++-xmethods/array.cc: Add whatis tests.
* testsuite/libstdc++-xmethods/associative-containers.cc: Ditto.
* testsuite/libstdc++-xmethods/deque.cc: Ditto.
* testsuite/libstdc++-xmethods/forwardlist.cc: Ditto.
* testsuite/libstdc++-xmethods/list.cc: Ditto.
* testsuite/libstdc++-xmethods/unique_ptr.cc: Ditto.
* testsuite/libstdc++-xmethods/vector.cc: Ditto.
From-SVN: r222599
-rw-r--r-- | libstdc++-v3/ChangeLog | 24 | ||||
-rw-r--r-- | libstdc++-v3/python/libstdcxx/v6/xmethods.py | 135 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-xmethods/array.cc | 7 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-xmethods/associative-containers.cc | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-xmethods/deque.cc | 6 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-xmethods/forwardlist.cc | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-xmethods/list.cc | 4 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-xmethods/unique_ptr.cc | 3 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/libstdc++-xmethods/vector.cc | 13 |
9 files changed, 177 insertions, 21 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index ca9ca6a..5b509f7 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,29 @@ 2015-04-29 Doug Evans <dje@google.com> + PR libstdc++/65839 + * python/libstdcxx/v6/xmethods.py (get_bool_type): New function. + Replace all lookups of "bool" with this. + (get_std_size_type): New function. Replace all lookups of std::size_t + with this. + (*Worker): New method get_result_type. + (DequeWorkerBase.__init__): New arg val_type. All callers updated. + (ListWorkerBase.__init__): New arg val_type. All callers updated. + (UniquePtrGetWorker.__init__): New arg elem_type. All callers updated. + Delete setting of name, enabled. + (UniquePtrDerefWorker.__init__): New arg elem_type. All callers + updated. Delete setting of name. + (UniquePtrMethodsMatcher): Rewrite for consistency with all other + libstdc++ xmethod matchers. + * testsuite/libstdc++-xmethods/array.cc: Add whatis tests. + * testsuite/libstdc++-xmethods/associative-containers.cc: Ditto. + * testsuite/libstdc++-xmethods/deque.cc: Ditto. + * testsuite/libstdc++-xmethods/forwardlist.cc: Ditto. + * testsuite/libstdc++-xmethods/list.cc: Ditto. + * testsuite/libstdc++-xmethods/unique_ptr.cc: Ditto. + * testsuite/libstdc++-xmethods/vector.cc: Ditto. + +2015-04-29 Doug Evans <dje@google.com> + Use consistent naming for value type attributes. * python/libstdcxx/v6/xmethods.py (ArrayWorkerBase): Rename _valtype to _val_type. diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index e4e920a..6db0e16 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -21,6 +21,12 @@ import re matcher_name_prefix = 'libstdc++::' +def get_bool_type(): + return gdb.lookup_type('bool') + +def get_std_size_type(): + return gdb.lookup_type('std::size_t') + class LibStdCxxXMethod(gdb.xmethod.XMethod): def __init__(self, name, worker_class): gdb.xmethod.XMethod.__init__(self, name) @@ -44,6 +50,9 @@ class ArraySizeWorker(ArrayWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return get_std_size_type() + def __call__(self, obj): return self._size @@ -54,6 +63,9 @@ class ArrayEmptyWorker(ArrayWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return get_bool_type() + def __call__(self, obj): return (int(self._size) == 0) @@ -64,6 +76,9 @@ class ArrayFrontWorker(ArrayWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): if int(self._size) > 0: return obj['_M_elems'][0] @@ -77,6 +92,9 @@ class ArrayBackWorker(ArrayWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): if int(self._size) > 0: return obj['_M_elems'][self._size - 1] @@ -88,7 +106,10 @@ class ArrayAtWorker(ArrayWorkerBase): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): - return gdb.lookup_type('std::size_t') + return get_std_size_type() + + def get_result_type(self, obj, index): + return self._val_type def __call__(self, obj, index): if int(index) >= int(self._size): @@ -101,7 +122,10 @@ class ArraySubscriptWorker(ArrayWorkerBase): ArrayWorkerBase.__init__(self, val_type, size) def get_arg_types(self): - return gdb.lookup_type('std::size_t') + return get_std_size_type() + + def get_result_type(self, obj, index): + return self._val_type def __call__(self, obj, index): if int(self._size) > 0: @@ -140,6 +164,7 @@ class ArrayMethodsMatcher(gdb.xmethod.XMethodMatcher): class DequeWorkerBase(gdb.xmethod.XMethodWorker): def __init__(self, val_type): + self._val_type = val_type self._bufsize = (512 / val_type.sizeof) or 1 def size(self, obj): @@ -158,6 +183,9 @@ class DequeEmptyWorker(DequeWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return get_bool_type() + def __call__(self, obj): return (obj['_M_impl']['_M_start']['_M_cur'] == obj['_M_impl']['_M_finish']['_M_cur']) @@ -166,6 +194,9 @@ class DequeSizeWorker(DequeWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return get_std_size_type() + def __call__(self, obj): return self.size(obj) @@ -173,6 +204,9 @@ class DequeFrontWorker(DequeWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): return obj['_M_impl']['_M_start']['_M_cur'][0] @@ -180,6 +214,9 @@ class DequeBackWorker(DequeWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): if (obj['_M_impl']['_M_finish']['_M_cur'] == obj['_M_impl']['_M_finish']['_M_first']): @@ -190,14 +227,20 @@ class DequeBackWorker(DequeWorkerBase): class DequeSubscriptWorker(DequeWorkerBase): def get_arg_types(self): - return gdb.lookup_type('std::size_t') + return get_std_size_type() + + def get_result_type(self, obj, subscript): + return self._val_type def __call__(self, obj, subscript): return self.index(obj, subscript) class DequeAtWorker(DequeWorkerBase): def get_arg_types(self): - return gdb.lookup_type('std::size_t') + return get_std_size_type() + + def get_result_type(self, obj, index): + return self._val_type def __call__(self, obj, index): deque_size = int(self.size(obj)) @@ -240,10 +283,16 @@ class ForwardListWorkerBase(gdb.xmethod.XMethodMatcher): return None class ForwardListEmptyWorker(ForwardListWorkerBase): + def get_result_type(self, obj): + return get_bool_type() + def __call__(self, obj): return obj['_M_impl']['_M_head']['_M_next'] == 0 class ForwardListFrontWorker(ForwardListWorkerBase): + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): node = obj['_M_impl']['_M_head']['_M_next'].cast(self._node_type) val_address = node['_M_storage']['_M_storage'].address @@ -272,13 +321,17 @@ class ForwardListMethodsMatcher(gdb.xmethod.XMethodMatcher): # Xmethods for std::list class ListWorkerBase(gdb.xmethod.XMethodWorker): - def __init__(self, node_type): + def __init__(self, val_type, node_type): + self._val_type = val_type self._node_type = node_type def get_arg_types(self): return None class ListEmptyWorker(ListWorkerBase): + def get_result_type(self, obj): + return get_bool_type() + def __call__(self, obj): base_node = obj['_M_impl']['_M_node'] if base_node['_M_next'] == base_node.address: @@ -287,6 +340,9 @@ class ListEmptyWorker(ListWorkerBase): return False class ListSizeWorker(ListWorkerBase): + def get_result_type(self, obj): + return get_std_size_type() + def __call__(self, obj): begin_node = obj['_M_impl']['_M_node']['_M_next'] end_node = obj['_M_impl']['_M_node'].address @@ -297,11 +353,17 @@ class ListSizeWorker(ListWorkerBase): return size class ListFrontWorker(ListWorkerBase): + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): node = obj['_M_impl']['_M_node']['_M_next'].cast(self._node_type) return node['_M_data'] class ListBackWorker(ListWorkerBase): + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): prev_node = obj['_M_impl']['_M_node']['_M_prev'].cast(self._node_type) return prev_node['_M_data'] @@ -324,8 +386,9 @@ class ListMethodsMatcher(gdb.xmethod.XMethodMatcher): method = self._method_dict.get(method_name) if method is None or not method.enabled: return None + val_type = class_type.template_argument(0) node_type = gdb.lookup_type(str(class_type) + '::_Node').pointer() - return method.worker_class(node_type) + return method.worker_class(val_type, node_type) # Xmethods for std::vector @@ -357,6 +420,9 @@ class VectorEmptyWorker(VectorWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return get_bool_type() + def __call__(self, obj): return int(self.size(obj)) == 0 @@ -364,6 +430,9 @@ class VectorSizeWorker(VectorWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return get_std_size_type() + def __call__(self, obj): return self.size(obj) @@ -371,6 +440,9 @@ class VectorFrontWorker(VectorWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): return self.get(obj, 0) @@ -378,12 +450,18 @@ class VectorBackWorker(VectorWorkerBase): def get_arg_types(self): return None + def get_result_type(self, obj): + return self._val_type + def __call__(self, obj): return self.get(obj, int(self.size(obj)) - 1) class VectorAtWorker(VectorWorkerBase): def get_arg_types(self): - return gdb.lookup_type('std::size_t') + return get_std_size_type() + + def get_result_type(self, obj, index): + return self._val_type def __call__(self, obj, index): size = int(self.size(obj)) @@ -394,7 +472,10 @@ class VectorAtWorker(VectorWorkerBase): class VectorSubscriptWorker(VectorWorkerBase): def get_arg_types(self): - return gdb.lookup_type('std::size_t') + return get_std_size_type() + + def get_result_type(self, obj, subscript): + return self._val_type def __call__(self, obj, subscript): return self.get(obj, int(subscript)) @@ -438,10 +519,16 @@ class AssociativeContainerWorkerBase(gdb.xmethod.XMethodWorker): return None class AssociativeContainerEmptyWorker(AssociativeContainerWorkerBase): + def get_result_type(self, obj): + return get_bool_type() + def __call__(self, obj): return int(self.node_count(obj)) == 0 class AssociativeContainerSizeWorker(AssociativeContainerWorkerBase): + def get_result_type(self, obj): + return get_std_size_type() + def __call__(self, obj): return self.node_count(obj) @@ -469,20 +556,24 @@ class AssociativeContainerMethodsMatcher(gdb.xmethod.XMethodMatcher): # Xmethods for std::unique_ptr class UniquePtrGetWorker(gdb.xmethod.XMethodWorker): - def __init__(self): - self.name = 'get' - self.enabled = True + def __init__(self, elem_type): + self._elem_type = elem_type def get_arg_types(self): return None + def get_result_type(self, obj): + return self._elem_type.pointer() + def __call__(self, obj): return obj['_M_t']['_M_head_impl'] class UniquePtrDerefWorker(UniquePtrGetWorker): - def __init__(self): - UniquePtrGetWorker.__init__(self) - self.name = 'operator*' + def __init__(self, elem_type): + UniquePtrGetWorker.__init__(self, elem_type) + + def get_result_type(self, obj): + return self._elem_type def __call__(self, obj): return UniquePtrGetWorker.__call__(self, obj).dereference() @@ -491,17 +582,19 @@ class UniquePtrMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self): gdb.xmethod.XMethodMatcher.__init__(self, matcher_name_prefix + 'unique_ptr') - self._get_worker = UniquePtrGetWorker() - self._deref_worker = UniquePtrDerefWorker() - self.methods = [self._get_worker, self._deref_worker] + self._method_dict = { + 'get': LibStdCxxXMethod('get', UniquePtrGetWorker), + 'operator*': LibStdCxxXMethod('operator*', UniquePtrDerefWorker), + } + 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): return None - if method_name == 'operator*' and self._deref_worker.enabled: - return self._deref_worker - elif method_name == 'get' and self._get_worker.enabled: - return self._get_worker + method = self._method_dict.get(method_name) + if method is None or not method.enabled: + return None + return method.worker_class(class_type.template_argument(0)) def register_libstdcxx_xmethods(locus): gdb.xmethod.register_xmethod_matcher(locus, ArrayMethodsMatcher()) diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/array.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/array.cc index 0b314e4..dfe6146 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/array.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/array.cc @@ -40,6 +40,13 @@ main () // { dg-final { note-test a\[4\] 104 } } // { dg-final { note-test a\[9\] 109 } } +// { dg-final { whatis-test a.size() std::size_t } } +// { dg-final { whatis-test a.empty() bool } } +// { dg-final { whatis-test a.front() int } } +// { dg-final { whatis-test a.back() int } } +// { dg-final { whatis-test a.at(5) int } } +// { dg-final { whatis-test a\[0\] int } } + return 0; // Mark SPOT } diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/associative-containers.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/associative-containers.cc index fae61ae..2f04b24 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/associative-containers.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/associative-containers.cc @@ -73,6 +73,9 @@ main () // { dg-final { note-test umm.empty() false } } // { dg-final { note-test umm1.empty() true } } +// { dg-final { whatis-test s.size() std::size_t } } +// { dg-final { whatis-test s.empty() bool } } + return 0; // Mark SPOT } diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/deque.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/deque.cc index e40898e..5890dd8 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/deque.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/deque.cc @@ -61,6 +61,12 @@ main () // { dg-final { note-test q3\[q3_size/2\]==(300+q3_size/2) true } } // { dg-final { note-test q3\[q3_size-1]==(300+q3_size-1) true } } +// { dg-final { whatis-test q0.empty() bool } } +// { dg-final { whatis-test q0.size() std::size_t } } +// { dg-final { whatis-test q1.front() int } } +// { dg-final { whatis-test q1.back() int } } +// { dg-final { whatis-test q3\[0\] int } } + return 0; // Mark SPOT } diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/forwardlist.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/forwardlist.cc index 224bbd3..2e8b7ac 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/forwardlist.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/forwardlist.cc @@ -34,6 +34,9 @@ main () // { dg-final { note-test l1.empty() false } } // { dg-final { note-test l1.front() 11011 } } +// { dg-final { whatis-test l1.empty() bool } } +// { dg-final { whatis-test l1.front() int } } + return 0; // Mark SPOT } diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc index 9f716f7..050f75b 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/list.cc @@ -38,6 +38,10 @@ main () // { dg-final { note-test l1.front() 123 } } // { dg-final { note-test l1.back() 789 } } +// { dg-final { whatis-test l1.empty() bool } } +// { dg-final { whatis-test l1.size() std::size_t } } +// { dg-final { whatis-test l1.front() int } } +// { dg-final { whatis-test l1.back() int } } return 0; // Mark SPOT } diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/unique_ptr.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/unique_ptr.cc index cd6d2e8..5d59b55 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/unique_ptr.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/unique_ptr.cc @@ -30,6 +30,9 @@ main () // { dg-final { note-test *p 10 } } // { dg-final { regexp-test p.get() 0x.* } } +// { dg-final { whatis-test *p int } } +// { dg-final { whatis-test p.get() "int \*" } } + return 0; // Mark SPOT } diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/vector.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/vector.cc index 6f258bc..8967286 100644 --- a/libstdc++-v3/testsuite/libstdc++-xmethods/vector.cc +++ b/libstdc++-v3/testsuite/libstdc++-xmethods/vector.cc @@ -83,6 +83,19 @@ main () // { dg-final { note-test bv3.at(63) true } } // { dg-final { note-test bv3.at(64) false } } +// { dg-final { whatis-test v0.empty() bool } } +// { dg-final { whatis-test v0.size() std::size_t } } +// { dg-final { whatis-test v1.front() int } } +// { dg-final { whatis-test v1.back() int } } +// { dg-final { whatis-test v1\[0\] int } } +// { dg-final { whatis-test v1.at(1) int } } +// { dg-final { whatis-test bv0.empty() bool } } +// { dg-final { whatis-test bv0.size() std::size_t } } +// { dg-final { whatis-test bv1.front() bool } } +// { dg-final { whatis-test bv1.back() bool } } +// { dg-final { whatis-test bv1\[0\] bool } } +// { dg-final { whatis-test bv1.at(1) bool } } + return 0; // Mark SPOT } |