+2016-09-19 Jonathan Wakely <jwakely@redhat.com>
+
+ 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 <jwakely@redhat.com>
* python/libstdcxx/v6/printers.py (StdVariantPrinter): Define.
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):
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()
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):
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):