Modify the EFI KDP debugging to not use any dynamic loader since it does manual dynam...
authorGreg Clayton <gclayton@apple.com>
Wed, 16 Jul 2014 21:16:27 +0000 (21:16 +0000)
committerGreg Clayton <gclayton@apple.com>
Wed, 16 Jul 2014 21:16:27 +0000 (21:16 +0000)
Also track down the required binary by trying to locate the main executable module through LLDB's symbol and executable file locating code.

<rdar://problem/16570258>

llvm-svn: 213199

lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp

index c2ae2b9..8ed106a 100644 (file)
@@ -297,7 +297,41 @@ ProcessKDP::DoConnectRemote (Stream *strm, const char *remote_url)
 
                     if (m_comm.RemoteIsEFI ())
                     {
-                        m_dyld_plugin_name = DynamicLoaderStatic::GetPluginNameStatic();
+                        // Select an invalid plugin name for the dynamic loader so one doesn't get used
+                        // since EFI does its own manual loading via python scripting
+                        static ConstString g_none_dynamic_loader("none");
+                        m_dyld_plugin_name = g_none_dynamic_loader;
+
+                        if (kernel_uuid.IsValid()) {
+                            // If EFI passed in a UUID= try to lookup UUID
+                            // The slide will not be provided. But the UUID
+                            // lookup will be used to launch EFI debug scripts
+                            // from the dSYM, that can load all of the symbols.
+                            ModuleSpec module_spec;
+                            module_spec.GetUUID() = kernel_uuid;
+                            module_spec.GetArchitecture() = m_target.GetArchitecture();
+
+                            // Lookup UUID locally, before attempting dsymForUUID like action
+                            module_spec.GetSymbolFileSpec() = Symbols::LocateExecutableSymbolFile(module_spec);
+                            if (module_spec.GetSymbolFileSpec())
+                                 module_spec.GetFileSpec() = Symbols::LocateExecutableObjectFile (module_spec);
+                            if (!module_spec.GetSymbolFileSpec() || !module_spec.GetSymbolFileSpec())
+                                 Symbols::DownloadObjectAndSymbolFile (module_spec, true);
+
+                            if (module_spec.GetFileSpec().Exists())
+                            {
+                                ModuleSP module_sp(new Module (module_spec.GetFileSpec(), m_target.GetArchitecture()));
+                                if (module_sp.get() && module_sp->MatchesModuleSpec (module_spec))
+                                {
+                                    // Get the current target executable
+                                    ModuleSP exe_module_sp (m_target.GetExecutableModule ());
+
+                                    // Make sure you don't already have the right module loaded and they will be uniqued
+                                    if (exe_module_sp.get() != module_sp.get())
+                                        m_target.SetExecutableModule (module_sp, false);
+                                }
+                            }
+                        }
                     }
                     else if (m_comm.RemoteIsDarwinKernel ())
                     {