[RFC] libstdc++: Fix pretty-printing old implementations of std::unique_ptr

Message ID 20200728190512.92283-1-andresx7@gmail.com
State Superseded
Headers show
  • [RFC] libstdc++: Fix pretty-printing old implementations of std::unique_ptr
Related show

Commit Message

Qing Zhao via Gcc-patches July 28, 2020, 7:05 p.m.
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.


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.


 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'):