[PATCH] libstdc++/77645 Fix xmethods for std::list
Jonathan Wakely
jwakely@redhat.com
Mon Sep 19 15:53:00 GMT 2016
The std::list xmethods have been broken since I added support for
allocators with fancy pointers, and the switch to std::gnu++14 by
default. This makes them work for any -std option.
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.
Tested x86_64-linux, committed to trunk and gcc-6-branch.
-------------- next part --------------
commit e25f0f03f10c4bd72ddeb6e32e51a5c71134455b
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Mon Sep 19 15:25:06 2016 +0100
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.
diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
index eccd574..95f9af9 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):
More information about the Libstdc++
mailing list