diff options
author | Greg Clayton <gclayton@apple.com> | 2013-05-04 01:38:48 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-05-04 01:38:48 +0000 |
commit | 1b7746e383ca68d09974947eeca6c17bb132a46a (patch) | |
tree | 53186b955d465615e149dbb60b4c29ca17135d8b /lldb/source/Target/Process.cpp | |
parent | cd410d04dbeb373f0762b167b2a202746e8a8eaf (diff) | |
download | bcm5719-llvm-1b7746e383ca68d09974947eeca6c17bb132a46a.tar.gz bcm5719-llvm-1b7746e383ca68d09974947eeca6c17bb132a46a.zip |
After recent OperatingsSystem plug-in changes, the lldb_private::Process and lldb_private::Thread subclasses were changed and the API was not respected properly.
This checkin aims to fix this. The process now has two thread lists: a real thread list for threads that are created by the lldb_private::Process subclass, and the user visible threads. The user visible threads are the same as the real threas when no OS plug-in in used. But when an OS plug-in is used, the user thread can be a combination of real and "memory" threads. Real threads can be placed inside of memory threads so that a thread appears to be different, but is still controlled by the actual real thread. When the thread list needs updating, the lldb_private::Process class will call the: lldb_private::Process::UpdateThreadList() function with the old real thread list, and the function is expected to fill in the new real thread list with the current state of the process. After this function, the process will check if there is an OS plug-in being used, and if so, it will give the old user thread list, the new real thread list and the OS plug-in will create the new user thread list from both of these lists. If there is no OS plug-in, the real thread list is the user thread list.
These changes keep the lldb_private::Process subclasses clean and no changes are required.
llvm-svn: 181091
Diffstat (limited to 'lldb/source/Target/Process.cpp')
-rw-r--r-- | lldb/source/Target/Process.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 227d4c1296c..fda71060d47 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1016,6 +1016,8 @@ Process::Process(Target &target, Listener &listener) : m_thread_id_to_index_id_map (), m_exit_status (-1), m_exit_string (), + m_thread_mutex (Mutex::eMutexTypeRecursive), + m_thread_list_real (this), m_thread_list (this), m_notifications (), m_image_tokens (), @@ -1140,6 +1142,7 @@ Process::Finalize() m_abi_sp.reset(); m_os_ap.reset(); m_dyld_ap.reset(); + m_thread_list_real.Destroy(); m_thread_list.Destroy(); std::vector<Notifications> empty_notifications; m_notifications.swap(empty_notifications); @@ -1537,10 +1540,12 @@ Process::UpdateThreadListIfNeeded () // m_thread_list does have its own mutex, but we need to // hold onto the mutex between the call to UpdateThreadList(...) // and the os->UpdateThreadList(...) so it doesn't change on us + ThreadList &old_thread_list = m_thread_list; + ThreadList real_thread_list(this); ThreadList new_thread_list(this); // Always update the thread list with the protocol specific // thread list, but only update if "true" is returned - if (UpdateThreadList (m_thread_list, new_thread_list)) + if (UpdateThreadList (m_thread_list_real, real_thread_list)) { // Don't call into the OperatingSystem to update the thread list if we are shutting down, since // that may call back into the SBAPI's, requiring the API lock which is already held by whoever is @@ -1552,16 +1557,23 @@ Process::UpdateThreadListIfNeeded () { // Clear any old backing threads where memory threads might have been // backed by actual threads from the lldb_private::Process subclass - size_t num_old_threads = m_thread_list.GetSize(false); + size_t num_old_threads = old_thread_list.GetSize(false); for (size_t i=0; i<num_old_threads; ++i) - m_thread_list.GetThreadAtIndex(i, false)->ClearBackingThread(); + old_thread_list.GetThreadAtIndex(i, false)->ClearBackingThread(); // Now let the OperatingSystem plug-in update the thread list - os->UpdateThreadList (m_thread_list, new_thread_list); + os->UpdateThreadList (old_thread_list, // Old list full of threads created by OS plug-in + real_thread_list, // The actual thread list full of threads created by each lldb_private::Process subclass + new_thread_list); // The new thread list that we will show to the user that gets filled in + } + else + { + // No OS plug-in, the new thread list is the same as the real thread list + new_thread_list = real_thread_list; } - m_thread_list.Update (new_thread_list); - m_thread_list.SetStopID (stop_id); } + m_thread_list.Update (new_thread_list); + m_thread_list.SetStopID (stop_id); } } } |