virtual ClassDescriptorSP
GetSuperclass () = 0;
+ virtual ClassDescriptorSP
+ GetMetaclass () const = 0;
+
// virtual if any implementation has some other version-specific rules
// but for the known v1/v2 this is all that needs to be done
virtual bool
if (class_method_func)
{
- ClassDescriptorV2 metaclass(m_runtime, objc_class->m_isa, NULL); // The metaclass is not in the cache
+ AppleObjCRuntime::ClassDescriptorSP metaclass(GetMetaclass());
// We don't care about the metaclass's superclass, or its class methods. Its instance methods are
// our class methods.
- metaclass.Describe(std::function <void (ObjCLanguageRuntime::ObjCISA)> (nullptr),
- class_method_func,
- std::function <bool (const char *, const char *)> (nullptr),
- std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> (nullptr));
+ if (metaclass) {
+ metaclass->Describe(std::function <void (ObjCLanguageRuntime::ObjCISA)> (nullptr),
+ class_method_func,
+ std::function <bool (const char *, const char *)> (nullptr),
+ std::function <bool (const char *, const char *, lldb::addr_t, uint64_t)> (nullptr));
+ }
}
if (ivar_func)
return m_runtime.ObjCLanguageRuntime::GetClassDescriptorFromISA(objc_class->m_superclass);
}
+ObjCLanguageRuntime::ClassDescriptorSP
+ClassDescriptorV2::GetMetaclass () const
+{
+ lldb_private::Process *process = m_runtime.GetProcess();
+
+ if (!process)
+ return ObjCLanguageRuntime::ClassDescriptorSP();
+
+ std::unique_ptr<objc_class_t> objc_class;
+
+ if (!Read_objc_class(process, objc_class))
+ return ObjCLanguageRuntime::ClassDescriptorSP();
+
+ lldb::addr_t candidate_isa = m_runtime.GetPointerISA(objc_class->m_isa);
+
+ return ObjCLanguageRuntime::ClassDescriptorSP(new ClassDescriptorV2(m_runtime, candidate_isa, nullptr));
+}
+
uint64_t
ClassDescriptorV2::GetInstanceSize ()
{
// The constructor should only be invoked by the runtime as it builds its caches
// or populates them. A ClassDescriptorV2 should only ever exist in a cache.
ClassDescriptorV2 (AppleObjCRuntimeV2 &runtime, ObjCLanguageRuntime::ObjCISA isa, const char *name) :
- m_runtime (runtime),
- m_objc_class_ptr (isa),
- m_name (name),
- m_ivars_storage()
+ m_runtime (runtime),
+ m_objc_class_ptr (isa),
+ m_name (name),
+ m_ivars_storage()
{
}
virtual ObjCLanguageRuntime::ClassDescriptorSP
GetSuperclass ();
+ virtual ObjCLanguageRuntime::ClassDescriptorSP
+ GetMetaclass () const;
+
virtual bool
IsValid ()
{
return ObjCLanguageRuntime::ClassDescriptorSP();
}
+ virtual ObjCLanguageRuntime::ClassDescriptorSP
+ GetMetaclass () const
+ {
+ return ObjCLanguageRuntime::ClassDescriptorSP();
+ }
+
virtual bool
IsValid ()
{
return ObjCLanguageRuntime::ClassDescriptorSP(new AppleObjCRuntimeV1::ClassDescriptorV1(m_parent_isa,process_sp));
}
+AppleObjCRuntime::ClassDescriptorSP
+AppleObjCRuntimeV1::ClassDescriptorV1::GetMetaclass () const
+{
+ return ClassDescriptorSP();
+}
+
bool
AppleObjCRuntimeV1::ClassDescriptorV1::Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)> const &superclass_func,
std::function <bool (const char *, const char *)> const &instance_method_func,
virtual ClassDescriptorSP
GetSuperclass ();
+ virtual ClassDescriptorSP
+ GetMetaclass () const;
+
virtual bool
IsValid ()
{
m_encoding_to_type_sp.reset(new AppleObjCTypeEncodingParser(*this));
return m_encoding_to_type_sp;
}
+
+lldb_private::AppleObjCRuntime::ObjCISA
+AppleObjCRuntimeV2::GetPointerISA (ObjCISA isa)
+{
+ ObjCISA ret = isa;
+
+ if (m_non_pointer_isa_cache_ap)
+ m_non_pointer_isa_cache_ap->EvaluateNonPointerISA(isa, ret);
+
+ return ret;
+}
uint64_t m_objc_debug_isa_magic_mask;
uint64_t m_objc_debug_isa_magic_value;
+ friend class AppleObjCRuntimeV2;
+
DISALLOW_COPY_AND_ASSIGN(NonPointerISACache);
};
AppleObjCRuntimeV2 (Process *process,
const lldb::ModuleSP &objc_module_sp);
+ ObjCISA
+ GetPointerISA (ObjCISA isa);
+
bool
IsTaggedPointer(lldb::addr_t ptr);
lldb::addr_t
GetSharedCacheReadOnlyAddress();
+ friend class ClassDescriptorV2;
+
std::unique_ptr<ClangFunction> m_get_class_info_function;
std::unique_ptr<ClangUtilityFunction> m_get_class_info_code;
lldb::addr_t m_get_class_info_args;