[Lldb-commits] [lldb] r273954 - Change PlatformDarwinKernel::GetSharedModule to be a little more

Jason Molenda via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 27 15:48:05 PDT 2016


Author: jmolenda
Date: Mon Jun 27 17:48:05 2016
New Revision: 273954

URL: http://llvm.org/viewvc/llvm-project?rev=273954&view=rev
Log:
Change PlatformDarwinKernel::GetSharedModule to be a little more
explicit in how it adds the kernel binary, to guard against the
case where a kernel corefile might incorrectly include the kernel's
UUID in it (so calling ::GetSharedModule may end up returning the
global module cache's copy of the core file instead of adding the
kerenl binary).

<rdar://problem/26988816> 

Modified:
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp?rev=273954&r1=273953&r2=273954&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp Mon Jun 27 17:48:05 2016
@@ -30,6 +30,7 @@
 #include "lldb/Interpreter/OptionValueFileSpecList.h"
 #include "lldb/Interpreter/OptionValueProperties.h"
 #include "lldb/Interpreter/Property.h"
+#include "lldb/Symbol/ObjectFile.h"
 #include "lldb/Target/Platform.h"
 #include "lldb/Target/Process.h"
 #include "lldb/Target/Target.h"
@@ -881,12 +882,24 @@ PlatformDarwinKernel::GetSharedModule (c
                 ModuleSP module_sp (new Module (kern_spec));
                 if (module_sp && module_sp->GetObjectFile() && module_sp->MatchesModuleSpec (kern_spec))
                 {
-                    Error error;
-                    error = ModuleList::GetSharedModule (kern_spec, module_sp, NULL, NULL, NULL);
-                    if (module_sp && module_sp->GetObjectFile())
+                    // module_sp is an actual kernel binary we want to add.
+                    if (process)
                     {
+                        process->GetTarget().GetImages().AppendIfNeeded (module_sp);
+                        error.Clear();
                         return error;
                     }
+                    else
+                    {
+                        error = ModuleList::GetSharedModule (kern_spec, module_sp, NULL, NULL, NULL);
+                        if (module_sp 
+                            && module_sp->GetObjectFile() 
+                            && module_sp->GetObjectFile()->GetType() != ObjectFile::Type::eTypeCoreFile)
+                        {
+                            return error;
+                        }
+                        module_sp.reset();
+                    }
                 }
             }
         }




More information about the lldb-commits mailing list