[RFC] libstdc++: Fix pretty-printing old implementations of std::unique_ptr
Andres Rodriguez
andresx7@gmail.com
Tue Jul 28 19:05:12 GMT 2020
On binaries compiled against gcc5 the impl_type parameter is None,
which results in an exception being raised by is_specialization_of()
These versions of std::unique_ptr have the tuple as a root element.
---
Hi,
I ran into this issue when debugging a binary built using gcc5.
I'm not very familiar with python or the gcc codebase, so this might be
the wrong way to address this problem. But a patch seemed like a good
way to start the conversation.
Thanks for taking a look.
-Andres
libstdc++-v3/python/libstdcxx/v6/printers.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index e4da8dfe5b6..3154a2a6f9d 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -247,7 +247,9 @@ class UniquePointerPrinter:
self.val = val
impl_type = val.type.fields()[0].type.tag
# Check for new implementations first:
- if is_specialization_of(impl_type, '__uniq_ptr_data') \
+ if impl_type is None:
+ tuple_member = val['_M_t']
+ elif is_specialization_of(impl_type, '__uniq_ptr_data') \
or is_specialization_of(impl_type, '__uniq_ptr_impl'):
tuple_member = val['_M_t']['_M_t']
elif is_specialization_of(impl_type, 'tuple'):
--
2.27.0
More information about the Gcc-patches
mailing list