docs: def subclass_from_type(cls, t):
          '''
          Given a PyTypeObjectPtr instance wrapping a gdb.Value that's a
          (PyTypeObject*), determine the corresponding subclass of PyObjectPtr
          to use
  
          Ideally, we would look up the symbols for the global types, but that
          isn't working yet:
            (gdb) python print gdb.lookup_symbol('PyList_Type')[0].value
            Traceback (most recent call last):
              File "<string>", line 1, in <module>
            NotImplementedError: Symbol type not yet supported in Python scripts.
            Error while executing Python code.
  
          For now, we use tp_flags, after doing some string comparisons on the
          tp_name for some special-cases that don't seem to be visible through
          flags
          '''
          try:
              tp_name = t.field('tp_name').string()
              tp_flags = int(t.field('tp_flags'))
          except RuntimeError:
              # Handle any kind of error e.g. NULL ptrs by simply using the base
              # class
              return cls
  
          #print 'tp_flags = 0x%08x' % tp_flags
          #print 'tp_name = %r' % tp_name
  
          name_map = {'bool': PyBoolObjectPtr,
                      'classobj': PyClassObjectPtr,
                      'instance': PyInstanceObjectPtr,
                      'NoneType': PyNoneStructPtr,
                      'frame': PyFrameObjectPtr,
                      'set' : PySetObjectPtr,
                      'frozenset' : PySetObjectPtr,
                      'builtin_function_or_method' : PyCFunctionObjectPtr,
                      }
          if tp_name in name_map:
              return name_map[tp_name]
  
          if tp_flags & Py_TPFLAGS_HEAPTYPE:
              return HeapTypeObjectPtr
  
          if tp_flags & Py_TPFLAGS_INT_SUBCLASS:
              return PyIntObjectPtr
          if tp_flags & Py_TPFLAGS_LONG_SUBCLASS:
              return PyLongObjectPtr
          if tp_flags & Py_TPFLAGS_LIST_SUBCLASS:
              return PyListObjectPtr
          if tp_flags & Py_TPFLAGS_TUPLE_SUBCLASS:
              return PyTupleObjectPtr
          if tp_flags & Py_TPFLAGS_STRING_SUBCLASS:
              return PyStringObjectPtr
          if tp_flags & Py_TPFLAGS_UNICODE_SUBCLASS:
              return PyUnicodeObjectPtr
          if tp_flags & Py_TPFLAGS_DICT_SUBCLASS:
              return PyDictObjectPtr
          if tp_flags & Py_TPFLAGS_BASE_EXC_SUBCLASS:
              return PyBaseExceptionObjectPtr
          #if tp_flags & Py_TPFLAGS_TYPE_SUBCLASS:
          #    return PyTypeObjectPtr
  
          # Use the base class:
          return cls