aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/python
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2019-05-18 00:08:00 +0100
committerJonathan Wakely <redi@gcc.gnu.org>2019-05-18 00:08:00 +0100
commit1a0a374429382d49830cf5759dcb6c3e82011908 (patch)
tree51602658be5e318b64c3808768457114ecacf329 /libstdc++-v3/python
parentb5ba95ba974d895b9de195494d947fa7effc6e48 (diff)
downloadgcc-1a0a374429382d49830cf5759dcb6c3e82011908.zip
gcc-1a0a374429382d49830cf5759dcb6c3e82011908.tar.gz
gcc-1a0a374429382d49830cf5759dcb6c3e82011908.tar.bz2
PR libstdc++/90520 adjust Xmethod for recent unique_ptr changes
PR libstdc++/90520 * python/libstdcxx/v6/printers.py (UniquePointerPrinter.__init__): Raise exception if unique_ptr tuple member has unknown structure. * python/libstdcxx/v6/xmethods.py (UniquePtrGetWorker.__call__): Adjust worker to support new __uniq_ptr_data base class. Do not assume field called _M_head_impl is the first tuple element. From-SVN: r271363
Diffstat (limited to 'libstdc++-v3/python')
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/printers.py2
-rw-r--r--libstdc++-v3/python/libstdcxx/v6/xmethods.py19
2 files changed, 17 insertions, 4 deletions
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index 162b007..0514315 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -197,6 +197,8 @@ class UniquePointerPrinter:
self.pointer = tuple_member['_M_head_impl']
elif head_field.is_base_class:
self.pointer = tuple_member.cast(head_field.type)
+ else:
+ raise ValueError("Unsupported implementation for tuple in unique_ptr: %s" % impl_type)
def children (self):
return SmartPtrIterator(self.pointer)
diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
index c405d8a..623cb80 100644
--- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py
+++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
@@ -586,11 +586,22 @@ class UniquePtrGetWorker(gdb.xmethod.XMethodWorker):
def __call__(self, obj):
impl_type = obj.dereference().type.fields()[0].type.tag
- if re.match('^std::(__\d+::)?__uniq_ptr_impl<.*>$', impl_type): # New implementation
- return obj['_M_t']['_M_t']['_M_head_impl']
+ # Check for new implementations first:
+ if re.match('^std::(__\d+::)?__uniq_ptr_(data|impl)<.*>$', impl_type):
+ tuple_member = obj['_M_t']['_M_t']
elif re.match('^std::(__\d+::)?tuple<.*>$', impl_type):
- return obj['_M_t']['_M_head_impl']
- return None
+ tuple_member = obj['_M_t']
+ else:
+ return None
+ tuple_impl_type = tuple_member.type.fields()[0].type # _Tuple_impl
+ tuple_head_type = tuple_impl_type.fields()[1].type # _Head_base
+ head_field = tuple_head_type.fields()[0]
+ if head_field.name == '_M_head_impl':
+ return tuple_member['_M_head_impl']
+ elif head_field.is_base_class:
+ return tuple_member.cast(head_field.type)
+ else:
+ return None
class UniquePtrDerefWorker(UniquePtrGetWorker):
"Implements std::unique_ptr<T>::operator*()"