https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91997

            Bug ID: 91997
           Summary: pretty printers: The __node_type type alias _Hashtable
                    is not available
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rafael at espindo dot la
  Target Milestone: ---

At least when compiling with optimizations with

gcc (GCC) 8.3.1 20190223 (Red Hat 8.3.1-2)

the debug info doesn't include the type alias

 using __node_type = __detail::_Hash_node<_Value, __hash_cached::value>

Which causes the pretty printer to fail with

-----------------------------------------------------
Traceback (most recent call last):
  File "/home/espindola/scylla/gdb-printers/libstdcxx/v6/printers.py", line
966, in children
    data = self.flatten (imap (self.format_one, StdHashtableIterator
(self.hashtable())))
  File "/home/espindola/scylla/gdb-printers/libstdcxx/v6/printers.py", line
889, in __init__
    self.node_type = find_type(hash.type, '__node_type').pointer()
  File "/home/espindola/scylla/gdb-printers/libstdcxx/v6/printers.py", line 97,
in find_type
    field = typ.fields()[0]
IndexError: list index out of range
-----------------------------------------------------

To work around that the pretty printer should reconstruct the type.
The best I was able to come up with was 

-        self.node_type = find_type(hash.type, '__node_type').pointer()
+        pair_name = hash.type.template_argument(1).name
+        traits_type = hash.type.template_argument(9)
+        cached = str(traits_type.template_argument(0)).lower()
+        node_name = '::std::__detail::_Hash_node<%s,%s>' % (pair_name, cached)
+        self.node_type = gdb.lookup_type(node_name).pointer()

Reply via email to