diff options
author | Jim Ingham <jingham@apple.com> | 2010-08-09 23:31:02 +0000 |
---|---|---|
committer | Jim Ingham <jingham@apple.com> | 2010-08-09 23:31:02 +0000 |
commit | 5aee162f978eac7ffb6363d25b193e51edfbc0b1 (patch) | |
tree | affe5547d828a14a967f9b5deff564248940554b /lldb/source/Target/Process.cpp | |
parent | 394a69ed528c403248c6354baeedaf0533b33afc (diff) | |
download | bcm5719-llvm-5aee162f978eac7ffb6363d25b193e51edfbc0b1.tar.gz bcm5719-llvm-5aee162f978eac7ffb6363d25b193e51edfbc0b1.zip |
Change Target & Process so they can really be initialized with an invalid architecture.
Arrange that this then gets properly set on attach, or when a "file" is set.
Add a completer for "process attach -n".
Caveats: there isn't currently a way to handle multiple processes with the same name. That
will have to wait on a way to pass annotations along with the completion strings.
llvm-svn: 110624
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 9f5c42a73f6..148eabe1ea3 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1048,6 +1048,24 @@ Process::CompleteAttach () if (state == eStateStopped || state == eStateCrashed) { DidAttach (); + // Figure out which one is the executable, and set that in our target: + ModuleList &modules = 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 = GetTarget().GetExecutableModule(); + if (!exec_module || exec_module != module_sp) + { + + GetTarget().SetExecutableModule (module_sp, false); + } + break; + } + } // This delays passing the stopped event to listeners till DidLaunch gets // a chance to complete... @@ -1073,6 +1091,16 @@ Process::Attach (lldb::pid_t attach_pid) m_target_triple.Clear(); m_abi_sp.reset(); + // Find the process and its architecture. Make sure it matches the architecture + // of the current Target, and if not adjust it. + + ArchSpec attach_spec = GetArchSpecForExistingProcess (attach_pid); + if (attach_spec != GetTarget().GetArchitecture()) + { + // Set the architecture on the target. + GetTarget().SetArchitecture(attach_spec); + } + Error error (WillAttachToProcessWithID(attach_pid)); if (error.Success()) { @@ -1102,6 +1130,16 @@ Process::Attach (const char *process_name, bool wait_for_launch) { m_target_triple.Clear(); m_abi_sp.reset(); + + // Find the process and its architecture. Make sure it matches the architecture + // of the current Target, and if not adjust it. + + ArchSpec attach_spec = GetArchSpecForExistingProcess (process_name); + if (attach_spec != GetTarget().GetArchitecture()) + { + // Set the architecture on the target. + GetTarget().SetArchitecture(attach_spec); + } Error error (WillAttachToProcessWithName(process_name, wait_for_launch)); if (error.Success()) @@ -1863,3 +1901,22 @@ Process::GetObjCObjectPrinter() return m_objc_object_printer; } +uint32_t +Process::ListProcessesMatchingName (const char *name, StringList &matches, std::vector<lldb::pid_t> &pids) +{ + return 0; +} + +ArchSpec +Process::GetArchSpecForExistingProcess (lldb::pid_t pid) +{ + return Host::GetArchSpecForExistingProcess (pid); +} + +ArchSpec +Process::GetArchSpecForExistingProcess (const char *process_name) +{ + return Host::GetArchSpecForExistingProcess (process_name); +} + + |