diff options
author | Greg Clayton <gclayton@apple.com> | 2011-02-16 04:46:07 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-02-16 04:46:07 +0000 |
commit | 93d3c8339c1dc843c3dbd2f82bcf4954a1844d63 (patch) | |
tree | 350e02f7a068638852e5aab7224454042498c4d9 /lldb/source/Target/Process.cpp | |
parent | 108b2d56bf41636f17f8528fbb320f1450103c9b (diff) | |
download | bcm5719-llvm-93d3c8339c1dc843c3dbd2f82bcf4954a1844d63.tar.gz bcm5719-llvm-93d3c8339c1dc843c3dbd2f82bcf4954a1844d63.zip |
The DynamicLoader plug-in instance now lives up in lldb_private::Process where
it should live and the lldb_private::Process takes care of managing the
auto pointer to the dynamic loader instance.
Also, now that the ArchSpec contains the target triple, we are able to
correctly set the Target architecture in DidLaunch/DidAttach in the subclasses,
and then the lldb_private::Process will find the dynamic loader plug-in
by letting the dynamic loader plug-ins inspect the arch/triple in the target.
So now the ProcessGDBRemote plug-in is another step closer to be purely
process/platform agnostic.
I updated the ProcessMacOSX and the ProcessLinux plug-ins accordingly.
llvm-svn: 125650
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 66 |
1 files changed, 41 insertions, 25 deletions
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) { |