Skip to content

Commit

Permalink
Initialize ObjC runtime at the right location.
Browse files Browse the repository at this point in the history
Summary:
Saw this while reading some code in DynamicLoader classes. Looks like this has
been a FIXME since 2011 at least.

Test Plan: Run unit tests.

Reviewers: clayborg

Subscribers: lldb-commits

Differential Revision: http://reviews.llvm.org/D8558

llvm-svn: 232983
  • Loading branch information
sas committed Mar 23, 2015
1 parent 7773a72 commit 5a1774d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
Expand Up @@ -890,24 +890,6 @@ DynamicLoaderMacOSXDYLD::AddModulesUsingImageInfos (DYLDImageInfo::collection &i

if (loaded_module_list.GetSize() > 0)
{
// FIXME: This should really be in the Runtime handlers class, which should get
// called by the target's ModulesDidLoad, but we're doing it all locally for now
// to save time.
// Also, I'm assuming there can be only one libobjc dylib loaded...

ObjCLanguageRuntime *objc_runtime = m_process->GetObjCLanguageRuntime(true);
if (objc_runtime != NULL && !objc_runtime->HasReadObjCLibrary())
{
size_t num_modules = loaded_module_list.GetSize();
for (size_t i = 0; i < num_modules; i++)
{
if (objc_runtime->IsModuleObjCLibrary (loaded_module_list.GetModuleAtIndex (i)))
{
objc_runtime->ReadObjCLibrary (loaded_module_list.GetModuleAtIndex (i));
break;
}
}
}
if (log)
loaded_module_list.LogUUIDAndPaths (log, "DynamicLoaderMacOSXDYLD::ModulesDidLoad");
m_process->GetTarget().ModulesDidLoad (loaded_module_list);
Expand Down
18 changes: 18 additions & 0 deletions lldb/source/Target/Target.cpp
Expand Up @@ -1259,6 +1259,24 @@ Target::ModulesDidLoad (ModuleList &module_list)
if (m_process_sp)
{
m_process_sp->ModulesDidLoad (module_list);

// This assumes there can only be one libobjc loaded.
ObjCLanguageRuntime *objc_runtime = m_process_sp->GetObjCLanguageRuntime ();
if (objc_runtime && !objc_runtime->HasReadObjCLibrary ())
{
Mutex::Locker locker (module_list.GetMutex ());

size_t num_modules = module_list.GetSize();
for (size_t i = 0; i < num_modules; i++)
{
auto mod = module_list.GetModuleAtIndex (i);
if (objc_runtime->IsModuleObjCLibrary (mod))
{
objc_runtime->ReadObjCLibrary (mod);
break;
}
}
}
}
BroadcastEvent (eBroadcastBitModulesLoaded, new TargetEventData (this->shared_from_this(), module_list));
}
Expand Down

0 comments on commit 5a1774d

Please sign in to comment.