code: def from_pyobject_ptr(cls, gdbval):
          '''
          Try to locate the appropriate derived class dynamically, and cast
          the pointer accordingly.
          '''
          try:
              p = PyObjectPtr(gdbval)
              cls = cls.subclass_from_type(p.type())
              return cls(gdbval, cast_to=cls.get_gdb_type())
          except RuntimeError:
              # Handle any kind of error e.g. NULL ptrs by simply using the base
              # class
              pass
          return cls(gdbvalf from_pyobject_ptr(cls, gdbval):
          '''
          Try to locate the appropriate derived class dynamically, and cast
          the pointer accordingly.
          '''
          try:
              p = PyObjectPtr(gdbval)
              cls = cls.subclass_from_type(p.type())
              return cls(gdbval, cast_to=cls.get_gdb_type())
          except RuntimeError:
              # Handle any kind of error e.g. NULL ptrs by simply using the base
              # class
              pass
          return cls(gdbval)
docs: Try to locate the appropriate derived class dynamically, and cast
          the pointer accordingly.