From: Jonathan Wakely Date: Mon, 19 Sep 2016 15:49:19 +0000 (+0100) Subject: libstdc++/77645 Fix xmethods for std::list X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=019270bcb3ff03b1dfb5a48b436af54e1d660421;p=gcc.git libstdc++/77645 Fix xmethods for std::list PR libstdc++/77645 * python/libstdcxx/v6/xmethods.py (DequeWorkerBase.index): Rename argument. (ListWorkerBase.get_value_from_node): Define new method. (ListFrontWorker.__call__, ListBackWorker.__call__): Use it. From-SVN: r240233 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 70ff276beb4..8bbd29c720c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,11 @@ +2016-09-19 Jonathan Wakely + + PR libstdc++/77645 + * python/libstdcxx/v6/xmethods.py (DequeWorkerBase.index): Rename + argument. + (ListWorkerBase.get_value_from_node): Define new method. + (ListFrontWorker.__call__, ListBackWorker.__call__): Use it. + 2016-09-17 Jonathan Wakely * python/libstdcxx/v6/printers.py (StdVariantPrinter): Define. diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py index eccd57400f9..95f9af9db25 100644 --- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py +++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py @@ -174,10 +174,10 @@ class DequeWorkerBase(gdb.xmethod.XMethodWorker): first = obj['_M_impl']['_M_finish']['_M_first'] return (last_node - first_node) * self._bufsize + (cur - first) - def index(self, obj, index): + def index(self, obj, idx): first_node = obj['_M_impl']['_M_start']['_M_node'] - index_node = first_node + index / self._bufsize - return index_node[0][index % self._bufsize] + index_node = first_node + idx / self._bufsize + return index_node[0][idx % self._bufsize] class DequeEmptyWorker(DequeWorkerBase): def get_arg_types(self): @@ -328,6 +328,15 @@ class ListWorkerBase(gdb.xmethod.XMethodWorker): def get_arg_types(self): return None + def get_value_from_node(self, node): + node = node.dereference() + if node.type.fields()[1].name == '_M_data': + # C++03 implementation, node contains the value as a member + return node['_M_data'] + # C++11 implementation, node stores value in __aligned_membuf + addr = node['_M_storage'].address + return addr.cast(self._val_type.pointer()).dereference() + class ListEmptyWorker(ListWorkerBase): def get_result_type(self, obj): return get_bool_type() @@ -358,7 +367,7 @@ class ListFrontWorker(ListWorkerBase): def __call__(self, obj): node = obj['_M_impl']['_M_node']['_M_next'].cast(self._node_type) - return node['_M_data'] + return self.get_value_from_node(node) class ListBackWorker(ListWorkerBase): def get_result_type(self, obj): @@ -366,7 +375,7 @@ class ListBackWorker(ListWorkerBase): def __call__(self, obj): prev_node = obj['_M_impl']['_M_node']['_M_prev'].cast(self._node_type) - return prev_node['_M_data'] + return self.get_value_from_node(prev_node) class ListMethodsMatcher(gdb.xmethod.XMethodMatcher): def __init__(self):