[Lldb-commits] [lldb] r152427 - /lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

Jim Ingham jingham at apple.com
Fri Mar 9 11:59:28 PST 2012


Author: jingham
Date: Fri Mar  9 13:59:28 2012
New Revision: 152427

URL: http://llvm.org/viewvc/llvm-project?rev=152427&view=rev
Log:
Handle the case where we get called to determine the ObjC runtime version BEFORE the loader code has
winnowed all the unloaded libraries from the process module list.
<rdar://problem/11015223>

Modified:
    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp

Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp?rev=152427&r1=152426&r2=152427&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp (original)
+++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntime.cpp Fri Mar  9 13:59:28 2012
@@ -260,12 +260,21 @@
 enum ObjCRuntimeVersions
 AppleObjCRuntime::GetObjCVersion (Process *process, ModuleSP &objc_module_sp)
 {
-    ModuleList &images = process->GetTarget().GetImages();
+    if (!process)
+        return eObjC_VersionUnknown;
+        
+    Target &target = process->GetTarget();
+    ModuleList &images = target.GetImages();
     size_t num_images = images.GetSize();
     for (size_t i = 0; i < num_images; i++)
     {
         ModuleSP module_sp = images.GetModuleAtIndex(i);
-        if (AppleIsModuleObjCLibrary (module_sp))
+        // One tricky bit here is that we might get called as part of the initial module loading, but
+        // before all the pre-run libraries get winnowed from the module list.  So there might actually
+        // be an old and incorrect ObjC library sitting around in the list, and we don't want to look at that.
+        // That's why we call IsLoadedInTarget.
+        
+        if (AppleIsModuleObjCLibrary (module_sp) && module_sp->IsLoadedInTarget(&target))
         {
             objc_module_sp = module_sp;
             ObjectFile *ofile = module_sp->GetObjectFile();





More information about the lldb-commits mailing list