const ModuleSP &objc_module_sp) :
AppleObjCRuntime (process),
m_get_class_name_args(LLDB_INVALID_ADDRESS),
- m_get_class_name_args_mutex(Mutex::eMutexTypeNormal)
+ m_get_class_name_args_mutex(Mutex::eMutexTypeNormal),
+ m_process_wp (process->shared_from_this())
{
static const ConstString g_gdb_object_getClass("gdb_object_getClass");
m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL);
class ClassDescriptorV2 : public ObjCLanguageRuntime::ClassDescriptor
{
public:
- ClassDescriptorV2 (ObjCLanguageRuntime &runtime, ValueObject &ptr_to_object) :
- m_runtime (runtime),
- m_valid (false),
- m_objc_class_ptr (0),
- m_objc_class (),
- m_name (),
- m_instance_size (0),
- m_realized (eLazyBoolCalculate),
- m_process_wp ()
- {
- lldb::addr_t object_ptr = ptr_to_object.GetValueAsUnsigned(0);
- lldb::ProcessSP process_sp = ptr_to_object.GetProcessSP();
-
- Error error;
- ObjCLanguageRuntime::ObjCISA isa = process_sp->ReadPointerFromMemory(object_ptr,
- error);
-
- if (isa != LLDB_INVALID_ADDRESS)
- Initialize (isa, process_sp);
- }
+ friend class lldb_private::AppleObjCRuntimeV2;
- ClassDescriptorV2 (ObjCLanguageRuntime &runtime, ObjCLanguageRuntime::ObjCISA isa, lldb::ProcessSP process_sp) :
+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) :
m_runtime (runtime),
m_valid (false),
m_objc_class_ptr (0),
m_realized (eLazyBoolCalculate),
m_process_wp ()
{
- Initialize (isa, process_sp);
+ Initialize (isa, m_runtime.GetProcessSP());
}
+public:
virtual ConstString
GetClassName ()
{
if (!m_valid)
return ObjCLanguageRuntime::ClassDescriptorSP();
- return m_runtime.GetClassDescriptor(m_objc_class.m_superclass);
+ return m_runtime.ObjCLanguageRuntime::GetClassDescriptor(m_objc_class.m_superclass);
}
virtual bool
if (class_method_func)
{
- ObjCLanguageRuntime::ClassDescriptorSP metaclass = m_runtime.GetClassDescriptor(m_objc_class.m_isa);
+ ObjCLanguageRuntime::ClassDescriptorSP metaclass = m_runtime.ObjCLanguageRuntime::GetClassDescriptor(m_objc_class.m_isa);
// We don't care about the metaclass's superclass, or its class methods. Its instance methods are
// our class methods.
}
};
- ObjCLanguageRuntime &m_runtime; // The runtime, so we can read our metaclass.
+ AppleObjCRuntimeV2 &m_runtime; // The runtime, so we can read our metaclass.
bool m_valid; // Gates whether we trust anything here at all.
lldb::addr_t m_objc_class_ptr; // The address of the objc_class_t.
objc_class_t m_objc_class;
{
ClassDescriptorSP objc_class_sp;
if (isa != 0)
- objc_class_sp.reset (new ClassDescriptorV2(*this, isa, m_process->CalculateProcess()));
+ objc_class_sp.reset (new ClassDescriptorV2(*this, isa));
return objc_class_sp;
}
if (m_isa_to_descriptor_cache.count(elt.second))
continue;
- ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, elt.second, process_sp));
+ ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, elt.second));
if (log && log->GetVerbose())
log->Printf("AppleObjCRuntimeV2 added (ObjCISA)0x%llx (%s) from dynamic table to isa->descriptor cache", elt.second, elt.first.AsCString());
if (m_isa_to_descriptor_cache.count(objc_isa))
continue;
- ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, objc_isa, process_sp));
+ ClassDescriptorSP descriptor_sp = ClassDescriptorSP(new ClassDescriptorV2(*this, objc_isa));
if (log && log->GetVerbose())
log->Printf("AppleObjCRuntimeV2 added (ObjCISA)0x%llx (%s) from static table to isa->descriptor cache", objc_isa, descriptor_sp->GetClassName().AsCString());