Fixes to the Objective-C V2 runtime:

- Only read the statically-defined isa table in the
  shared cache once.  Only the dynamically-constructed
  isa table can change.

- Ignore the statically-defined isa table if its
  version isn't what we expect.

llvm-svn: 166856
This commit is contained in:
Sean Callanan 2012-10-27 01:51:44 +00:00
parent c5f9943a60
commit cd6ce2ff31
2 changed files with 43 additions and 28 deletions

View File

@ -113,7 +113,8 @@ AppleObjCRuntimeV2::AppleObjCRuntimeV2 (Process *process,
m_type_vendor_ap (),
m_isa_hash_table_ptr (LLDB_INVALID_ADDRESS),
m_hash_signature (),
m_has_object_getClass (false)
m_has_object_getClass (false),
m_loaded_objc_opt (false)
{
static const ConstString g_gdb_object_getClass("gdb_object_getClass");
m_has_object_getClass = (objc_module_sp->FindFirstSymbolWithNameAndType(g_gdb_object_getClass, eSymbolTypeCode) != NULL);
@ -736,6 +737,9 @@ public:
m_version = m_process->ReadUnsignedIntegerFromMemory(cursor, sizeof(uint32_t), 0, err);
cursor += sizeof(uint32_t);
if (!IsValid())
return;
// int32_t selopt_offset;
cursor += sizeof(int32_t);
@ -750,9 +754,6 @@ public:
cursor += sizeof(int32_t);
}
if (m_version != 12)
return;
m_clsopt_ptr = load_addr + m_clsopt_offset;
cursor = m_clsopt_ptr;
@ -913,6 +914,9 @@ public:
const_iterator begin ()
{
if (!IsValid())
return m_end_iterator;
else
return const_iterator(*this, (int64_t)m_capacity + (int64_t)m_duplicateCount);
}
@ -922,6 +926,11 @@ public:
}
private:
bool IsValid()
{
return (m_version == 12);
}
// contents of objc_opt struct
uint32_t m_version;
int32_t m_clsopt_offset;
@ -1756,6 +1765,10 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapIfNeeded()
m_isa_to_descriptor_cache[elt.second] = descriptor_sp;
}
if (!m_loaded_objc_opt)
{
m_loaded_objc_opt = true;
ObjectFile *objc_object = objc_module_sp->GetObjectFile();
if (objc_object)
@ -1799,6 +1812,7 @@ AppleObjCRuntimeV2::UpdateISAToDescriptorMapIfNeeded()
}
}
}
}
else
{
m_isa_to_descriptor_cache_stop_id = UINT32_MAX;

View File

@ -142,6 +142,7 @@ private:
lldb::addr_t m_isa_hash_table_ptr;
HashTableSignature m_hash_signature;
bool m_has_object_getClass;
bool m_loaded_objc_opt;
static const char *g_find_class_name_function_name;
static const char *g_find_class_name_function_body;