summaryrefslogtreecommitdiffstats
path: root/lldb/source
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/source')
-rw-r--r--lldb/source/Core/DynamicLoader.cpp4
-rw-r--r--lldb/source/Host/common/Host.cpp10
-rw-r--r--lldb/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp14
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp14
-rw-r--r--lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h2
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessLinux.cpp14
-rw-r--r--lldb/source/Plugins/Process/Linux/ProcessLinux.h6
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp28
-rw-r--r--lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h4
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp25
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h5
-rw-r--r--lldb/source/Target/Process.cpp66
12 files changed, 77 insertions, 115 deletions
diff --git a/lldb/source/Core/DynamicLoader.cpp b/lldb/source/Core/DynamicLoader.cpp
index a207e9f3315..fa00e77ceb7 100644
--- a/lldb/source/Core/DynamicLoader.cpp
+++ b/lldb/source/Core/DynamicLoader.cpp
@@ -23,7 +23,7 @@ DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
create_callback = PluginManager::GetDynamicLoaderCreateCallbackForPluginName (plugin_name);
if (create_callback)
{
- std::auto_ptr<DynamicLoader> instance_ap(create_callback(process));
+ std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, true));
if (instance_ap.get())
return instance_ap.release();
}
@@ -32,7 +32,7 @@ DynamicLoader::FindPlugin (Process *process, const char *plugin_name)
{
for (uint32_t idx = 0; (create_callback = PluginManager::GetDynamicLoaderCreateCallbackAtIndex(idx)) != NULL; ++idx)
{
- std::auto_ptr<DynamicLoader> instance_ap(create_callback(process));
+ std::auto_ptr<DynamicLoader> instance_ap(create_callback(process, false));
if (instance_ap.get())
return instance_ap.release();
}
diff --git a/lldb/source/Host/common/Host.cpp b/lldb/source/Host/common/Host.cpp
index 64d123570a8..20709ded465 100644
--- a/lldb/source/Host/common/Host.cpp
+++ b/lldb/source/Host/common/Host.cpp
@@ -261,20 +261,20 @@ Host::GetArchitecture (SystemDefaultArchitecture arch_kind)
if (is_64_bit_capable)
{
+#if defined (__i386__) || defined (__x86_64__)
+ if (cpusubtype == CPU_SUBTYPE_486)
+ cpusubtype = CPU_SUBTYPE_I386_ALL;
+#endif
if (cputype & CPU_ARCH_ABI64)
{
// We have a 64 bit kernel on a 64 bit system
- g_host_arch_32.SetMachOArch (CPU_TYPE_I386, CPU_SUBTYPE_386);
+ g_host_arch_32.SetMachOArch (~(CPU_ARCH_MASK) & cputype, cpusubtype);
g_host_arch_64.SetMachOArch (cputype, cpusubtype);
}
else
{
// We have a 32 bit kernel on a 64 bit system
g_host_arch_32.SetMachOArch (cputype, cpusubtype);
-#if defined (__i386__) || defined (__x86_64__)
- if (cpusubtype == CPU_SUBTYPE_486)
- cpusubtype = CPU_SUBTYPE_I386_ALL;
-#endif
cputype |= CPU_ARCH_ABI64;
g_host_arch_64.SetMachOArch (cputype, cpusubtype);
}
diff --git a/lldb/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp b/lldb/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp
index 0802ff65575..78ebe4db0ca 100644
--- a/lldb/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/Linux-DYLD/DynamicLoaderLinuxDYLD.cpp
@@ -73,9 +73,19 @@ DynamicLoaderLinuxDYLD::GetPluginVersion()
}
DynamicLoader *
-DynamicLoaderLinuxDYLD::CreateInstance(Process *process)
+DynamicLoaderLinuxDYLD::CreateInstance(Process *process, bool force)
{
- return new DynamicLoaderLinuxDYLD(process);
+ bool create = force;
+ if (!create)
+ {
+ const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple();
+ if (triple_ref.getOS() == llvm::Triple::Linux)
+ create = true;
+ }
+
+ if (create)
+ return new DynamicLoaderLinuxDYLD (process);
+ return NULL;
}
DynamicLoaderLinuxDYLD::DynamicLoaderLinuxDYLD(Process *process)
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
index 003ed9a6493..67958c97d79 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.cpp
@@ -63,9 +63,19 @@ DynamicLoaderMacOSXDYLD::GetImageInfo (const FileSpec &file_spec, const lldb_pri
// allows the lldb to instantiate an instance of this class.
//----------------------------------------------------------------------
DynamicLoader *
-DynamicLoaderMacOSXDYLD::CreateInstance (Process* process)
+DynamicLoaderMacOSXDYLD::CreateInstance (Process* process, bool force)
{
- return new DynamicLoaderMacOSXDYLD (process);
+ bool create = force;
+ if (!create)
+ {
+ const llvm::Triple &triple_ref = process->GetTarget().GetArchitecture().GetTriple();
+ if (triple_ref.getOS() == llvm::Triple::Darwin && triple_ref.getVendor() == llvm::Triple::Apple)
+ create = true;
+ }
+
+ if (create)
+ return new DynamicLoaderMacOSXDYLD (process);
+ return NULL;
}
//----------------------------------------------------------------------
diff --git a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
index eee6bc1bacc..d5575101496 100644
--- a/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
+++ b/lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h
@@ -44,7 +44,7 @@ public:
GetPluginDescriptionStatic();
static lldb_private::DynamicLoader *
- CreateInstance (lldb_private::Process *process);
+ CreateInstance (lldb_private::Process *process, bool force);
DynamicLoaderMacOSXDYLD (lldb_private::Process *process);
diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
index fa5b5b70ec3..9939fe7d988 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
+++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.cpp
@@ -106,12 +106,6 @@ Error
ProcessLinux::WillLaunch(Module* module)
{
Error error;
-
- m_dyld_ap.reset(DynamicLoader::FindPlugin(this, "dynamic-loader.linux-dyld"));
- if (m_dyld_ap.get() == NULL)
- error.SetErrorString("unable to find the dynamic loader named "
- "'dynamic-loader.linux-dyld'");
-
return error;
}
@@ -146,8 +140,6 @@ ProcessLinux::DoLaunch(Module *module,
void
ProcessLinux::DidLaunch()
{
- if (m_dyld_ap.get() != NULL)
- m_dyld_ap->DidLaunch();
}
Error
@@ -405,12 +397,6 @@ ProcessLinux::GetByteOrder() const
return m_byte_order;
}
-DynamicLoader *
-ProcessLinux::GetDynamicLoader()
-{
- return m_dyld_ap.get();
-}
-
//------------------------------------------------------------------------------
// ProcessInterface protocol.
diff --git a/lldb/source/Plugins/Process/Linux/ProcessLinux.h b/lldb/source/Plugins/Process/Linux/ProcessLinux.h
index 6fe05526647..18e5aa712d0 100644
--- a/lldb/source/Plugins/Process/Linux/ProcessLinux.h
+++ b/lldb/source/Plugins/Process/Linux/ProcessLinux.h
@@ -138,9 +138,6 @@ public:
virtual lldb::addr_t
GetImageInfoAddress();
- virtual lldb_private::DynamicLoader *
- GetDynamicLoader();
-
//------------------------------------------------------------------
// PluginInterface protocol
//------------------------------------------------------------------
@@ -186,9 +183,6 @@ private:
lldb_private::Mutex m_message_mutex;
std::queue<ProcessMessage> m_message_queue;
- /// Dynamic loader plugin associated with this process.
- std::auto_ptr<lldb_private::DynamicLoader> m_dyld_ap;
-
/// Updates the loaded sections provided by the executable.
///
/// FIXME: It would probably be better to delegate this task to the
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
index 5318014d3a7..e4be2730584 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
@@ -234,8 +234,7 @@ ProcessMacOSX::ProcessMacOSX(Target& target, Listener &listener) :
m_stdout_data (),
m_exception_messages (),
m_exception_messages_mutex (Mutex::eMutexTypeRecursive),
- m_arch_spec (),
- m_dynamic_loader_ap ()
+ m_arch_spec ()
{
}
@@ -414,14 +413,7 @@ ProcessMacOSX::DoAttachToProcessWithID (lldb::pid_t attach_pid)
Error
ProcessMacOSX::WillLaunchOrAttach ()
{
- Error error;
- // TODO: this is hardcoded for macosx right now. We need this to be more dynamic
- m_dynamic_loader_ap.reset(DynamicLoader::FindPlugin(this, "dynamic-loader.macosx-dyld"));
-
- if (m_dynamic_loader_ap.get() == NULL)
- error.SetErrorString("unable to find the dynamic loader named 'dynamic-loader.macosx-dyld'");
-
- return error;
+ return Error();
}
@@ -434,11 +426,7 @@ ProcessMacOSX::WillLaunch (Module* module)
void
ProcessMacOSX::DidLaunchOrAttach ()
{
- if (GetID() == LLDB_INVALID_PROCESS_ID)
- {
- m_dynamic_loader_ap.reset();
- }
- else
+ if (GetID() != LLDB_INVALID_PROCESS_ID)
{
Module * exe_module = GetTarget().GetExecutableModule ().get();
assert (exe_module);
@@ -455,16 +443,12 @@ ProcessMacOSX::DidLaunch ()
{
ProcessMacOSXLog::LogIf (PD_LOG_PROCESS, "ProcessMacOSX::DidLaunch()");
DidLaunchOrAttach ();
- if (m_dynamic_loader_ap.get())
- m_dynamic_loader_ap->DidLaunch();
}
void
ProcessMacOSX::DidAttach ()
{
DidLaunchOrAttach ();
- if (m_dynamic_loader_ap.get())
- m_dynamic_loader_ap->DidAttach();
}
Error
@@ -870,12 +854,6 @@ ProcessMacOSX::GetImageInfoAddress()
return Task().GetDYLDAllImageInfosAddress();
}
-DynamicLoader *
-ProcessMacOSX::GetDynamicLoader()
-{
- return m_dynamic_loader_ap.get();
-}
-
//------------------------------------------------------------------
// Process Memory
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
index c0a80c58715..f2ab6cfcdd9 100644
--- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
+++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
@@ -222,9 +222,6 @@ public:
virtual lldb_private::Error
DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc);
- virtual lldb_private::DynamicLoader *
- GetDynamicLoader ();
-
static void
AddArchCreateCallback(const lldb_private::ArchSpec& arch_spec,
ProcessMacOSX::CreateArchCalback callback);
@@ -244,7 +241,6 @@ protected:
MachException::Message::collection m_exception_messages; // A collection of exception messages caught when listening to the exception port
lldb_private::Mutex m_exception_messages_mutex; // Multithreaded protection for m_exception_messages
lldb_private::ArchSpec m_arch_spec;
- std::auto_ptr<lldb_private::DynamicLoader> m_dynamic_loader_ap;
//----------------------------------------------------------------------
// Child process control
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index cba0ca162fe..df3e09a9988 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -101,7 +101,6 @@ ProcessGDBRemote::CanDebug(Target &target)
//----------------------------------------------------------------------
ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
Process (target, listener),
- m_dynamic_loader_ap (),
m_flags (0),
m_stdio_mutex (Mutex::eMutexTypeRecursive),
m_gdb_comm(),
@@ -132,8 +131,6 @@ ProcessGDBRemote::ProcessGDBRemote(Target& target, Listener &listener) :
//----------------------------------------------------------------------
ProcessGDBRemote::~ProcessGDBRemote()
{
- m_dynamic_loader_ap.reset();
-
if (IS_VALID_LLDB_HOST_THREAD(m_debugserver_thread))
{
Host::ThreadCancel (m_debugserver_thread, NULL);
@@ -410,13 +407,7 @@ Error
ProcessGDBRemote::WillLaunchOrAttach ()
{
Error error;
- // TODO: this is hardcoded for macosx right now. We need this to be more dynamic
- m_dynamic_loader_ap.reset(DynamicLoader::FindPlugin(this, "dynamic-loader.macosx-dyld"));
-
- if (m_dynamic_loader_ap.get() == NULL)
- error.SetErrorString("unable to find the dynamic loader named 'dynamic-loader.macosx-dyld'");
m_stdio_communication.Clear ();
-
return error;
}
@@ -628,11 +619,7 @@ ProcessGDBRemote::DidLaunchOrAttach ()
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_PROCESS));
if (log)
log->Printf ("ProcessGDBRemote::DidLaunch()");
- if (GetID() == LLDB_INVALID_PROCESS_ID)
- {
- m_dynamic_loader_ap.reset();
- }
- else
+ if (GetID() != LLDB_INVALID_PROCESS_ID)
{
m_dispatch_queue_offsets_addr = LLDB_INVALID_ADDRESS;
@@ -673,8 +660,6 @@ void
ProcessGDBRemote::DidLaunch ()
{
DidLaunchOrAttach ();
- if (m_dynamic_loader_ap.get())
- m_dynamic_loader_ap->DidLaunch();
}
Error
@@ -816,8 +801,6 @@ void
ProcessGDBRemote::DidAttach ()
{
DidLaunchOrAttach ();
- if (m_dynamic_loader_ap.get())
- m_dynamic_loader_ap->DidAttach();
}
Error
@@ -1540,12 +1523,6 @@ ProcessGDBRemote::GetImageInfoAddress()
return LLDB_INVALID_ADDRESS;
}
-DynamicLoader *
-ProcessGDBRemote::GetDynamicLoader()
-{
- return m_dynamic_loader_ap.get();
-}
-
//------------------------------------------------------------------
// Process Memory
//------------------------------------------------------------------
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
index 3e61ac6b840..7d5a361e98b 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
@@ -219,9 +219,6 @@ public:
virtual lldb_private::Error
DisableWatchpoint (lldb_private::WatchpointLocation *wp_loc);
- virtual lldb_private::DynamicLoader *
- GetDynamicLoader ();
-
virtual bool
StartNoticingNewThreads();
@@ -328,8 +325,6 @@ protected:
eBroadcastBitAsyncThreadShouldExit = (1 << 1)
};
-
- std::auto_ptr<lldb_private::DynamicLoader> m_dynamic_loader_ap;
lldb_private::Flags m_flags; // Process specific flags (see eFlags enums)
lldb_private::Mutex m_stdio_mutex; // Multithreaded protection for stdio
GDBRemoteCommunication m_gdb_comm;
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp
index cf019e61328..fb6614d3f67 100644
--- a/lldb/source/Target/Process.cpp
+++ b/lldb/source/Target/Process.cpp
@@ -845,12 +845,6 @@ Process::UnloadImage (uint32_t image_token)
return error;
}
-DynamicLoader *
-Process::GetDynamicLoader()
-{
- return NULL;
-}
-
const ABI *
Process::GetABI()
{
@@ -1503,6 +1497,7 @@ Process::Launch
{
Error error;
m_abi_sp.reset();
+ m_dyld_ap.reset();
m_process_input_reader.reset();
Module *exe_module = m_target.GetExecutableModule().get();
@@ -1569,8 +1564,13 @@ Process::Launch
if (state == eStateStopped || state == eStateCrashed)
{
+
DidLaunch ();
+ m_dyld_ap.reset (DynamicLoader::FindPlugin(this, false));
+ if (m_dyld_ap.get())
+ m_dyld_ap->DidLaunch();
+
// This delays passing the stopped event to listeners till DidLaunch gets
// a chance to complete...
HandlePrivateEvent (event_sp);
@@ -1609,25 +1609,7 @@ Process::AttachCompletionHandler::PerformAction (lldb::EventSP &event_sp)
// lldb_private::Process subclasses must set the process must set
// the new process ID.
assert (m_process->GetID() != LLDB_INVALID_PROCESS_ID);
- m_process->DidAttach ();
- // Figure out which one is the executable, and set that in our target:
- ModuleList &modules = m_process->GetTarget().GetImages();
-
- size_t num_modules = modules.GetSize();
- for (int i = 0; i < num_modules; i++)
- {
- ModuleSP module_sp = modules.GetModuleAtIndex(i);
- if (module_sp->IsExecutable())
- {
- ModuleSP exec_module = m_process->GetTarget().GetExecutableModule();
- if (!exec_module || exec_module != module_sp)
- {
-
- m_process->GetTarget().SetExecutableModule (module_sp, false);
- }
- break;
- }
- }
+ m_process->CompleteAttach ();
return eEventActionSuccess;
}
@@ -1671,6 +1653,8 @@ Process::Attach (lldb::pid_t attach_pid)
GetTarget().SetArchitecture(attach_spec);
}
+ m_dyld_ap.reset();
+
Error error (WillAttachToProcessWithID(attach_pid));
if (error.Success())
{
@@ -1716,6 +1700,8 @@ Process::Attach (const char *process_name, bool wait_for_launch)
GetTarget().SetArchitecture(attach_spec);
}
}
+
+ m_dyld_ap.reset();
Error error (WillAttachToProcessWithName(process_name, wait_for_launch));
if (error.Success())
@@ -1743,6 +1729,36 @@ Process::Attach (const char *process_name, bool wait_for_launch)
return error;
}
+void
+Process::CompleteAttach ()
+{
+ // Let the process subclass figure out at much as it can about the process
+ // before we go looking for a dynamic loader plug-in.
+ DidAttach();
+
+ // We have complete the attach, now it is time to find the dynamic loader
+ // plug-in
+ m_dyld_ap.reset (DynamicLoader::FindPlugin(this, false));
+ if (m_dyld_ap.get())
+ m_dyld_ap->DidAttach();
+
+ // Figure out which one is the executable, and set that in our target:
+ ModuleList &modules = m_target.GetImages();
+
+ size_t num_modules = modules.GetSize();
+ for (int i = 0; i < num_modules; i++)
+ {
+ ModuleSP module_sp (modules.GetModuleAtIndex(i));
+ if (module_sp->IsExecutable())
+ {
+ ModuleSP target_exe_module_sp (m_target.GetExecutableModule());
+ if (target_exe_module_sp != module_sp)
+ m_target.SetExecutableModule (module_sp, false);
+ break;
+ }
+ }
+}
+
Error
Process::ConnectRemote (const char *remote_url)
{
OpenPOWER on IntegriCloud