mirror of
https://github.com/intel/llvm.git
synced 2026-01-16 13:35:38 +08:00
Resolve non-pointer isas for metaclasses.
Patch by Enrico Granata. <rdar://problem/18618298> llvm-svn: 219641
This commit is contained in:
@@ -166,6 +166,9 @@ public:
|
||||
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
|
||||
|
||||
@@ -375,15 +375,17 @@ ClassDescriptorV2::Describe (std::function <void (ObjCLanguageRuntime::ObjCISA)>
|
||||
|
||||
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)
|
||||
@@ -449,6 +451,24 @@ ClassDescriptorV2::GetSuperclass ()
|
||||
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 ()
|
||||
{
|
||||
|
||||
@@ -31,10 +31,10 @@ private:
|
||||
// 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()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ public:
|
||||
virtual ObjCLanguageRuntime::ClassDescriptorSP
|
||||
GetSuperclass ();
|
||||
|
||||
virtual ObjCLanguageRuntime::ClassDescriptorSP
|
||||
GetMetaclass () const;
|
||||
|
||||
virtual bool
|
||||
IsValid ()
|
||||
{
|
||||
@@ -328,6 +331,12 @@ public:
|
||||
return ObjCLanguageRuntime::ClassDescriptorSP();
|
||||
}
|
||||
|
||||
virtual ObjCLanguageRuntime::ClassDescriptorSP
|
||||
GetMetaclass () const
|
||||
{
|
||||
return ObjCLanguageRuntime::ClassDescriptorSP();
|
||||
}
|
||||
|
||||
virtual bool
|
||||
IsValid ()
|
||||
{
|
||||
|
||||
@@ -271,6 +271,12 @@ AppleObjCRuntimeV1::ClassDescriptorV1::GetSuperclass ()
|
||||
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,
|
||||
|
||||
@@ -40,6 +40,9 @@ public:
|
||||
virtual ClassDescriptorSP
|
||||
GetSuperclass ();
|
||||
|
||||
virtual ClassDescriptorSP
|
||||
GetMetaclass () const;
|
||||
|
||||
virtual bool
|
||||
IsValid ()
|
||||
{
|
||||
|
||||
@@ -1925,3 +1925,14 @@ AppleObjCRuntimeV2::GetEncodingToType ()
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -157,6 +157,8 @@ private:
|
||||
uint64_t m_objc_debug_isa_magic_mask;
|
||||
uint64_t m_objc_debug_isa_magic_value;
|
||||
|
||||
friend class AppleObjCRuntimeV2;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NonPointerISACache);
|
||||
};
|
||||
|
||||
@@ -241,6 +243,9 @@ private:
|
||||
AppleObjCRuntimeV2 (Process *process,
|
||||
const lldb::ModuleSP &objc_module_sp);
|
||||
|
||||
ObjCISA
|
||||
GetPointerISA (ObjCISA isa);
|
||||
|
||||
bool
|
||||
IsTaggedPointer(lldb::addr_t ptr);
|
||||
|
||||
@@ -263,6 +268,8 @@ private:
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user