summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-05-04 01:38:48 +0000
committerGreg Clayton <gclayton@apple.com>2013-05-04 01:38:48 +0000
commit1b7746e383ca68d09974947eeca6c17bb132a46a (patch)
tree53186b955d465615e149dbb60b4c29ca17135d8b /lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
parentcd410d04dbeb373f0762b167b2a202746e8a8eaf (diff)
downloadbcm5719-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/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp')
-rw-r--r--lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp51
1 files changed, 18 insertions, 33 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 06e15ab1f40..0302f9312b7 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -1281,14 +1281,14 @@ ProcessGDBRemote::DoResume ()
void
ProcessGDBRemote::ClearThreadIDList ()
{
- Mutex::Locker locker(m_thread_list.GetMutex());
+ Mutex::Locker locker(m_thread_list_real.GetMutex());
m_thread_ids.clear();
}
bool
ProcessGDBRemote::UpdateThreadIDList ()
{
- Mutex::Locker locker(m_thread_list.GetMutex());
+ Mutex::Locker locker(m_thread_list_real.GetMutex());
bool sequence_mutex_unavailable = false;
m_gdb_comm.GetCurrentThreadIDs (m_thread_ids, sequence_mutex_unavailable);
if (sequence_mutex_unavailable)
@@ -1323,12 +1323,6 @@ ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new
{
tid_t tid = m_thread_ids[i];
ThreadSP thread_sp (old_thread_list_copy.RemoveThreadByProtocolID(tid, false));
- if (thread_sp)
- {
- ThreadSP backing_thread_sp (thread_sp->GetBackingThread());
- if (backing_thread_sp && backing_thread_sp->GetProtocolID() == tid)
- thread_sp = backing_thread_sp;
- }
if (!thread_sp)
thread_sp.reset (new ThreadGDBRemote (*this, tid));
new_thread_list.AddThread(thread_sp);
@@ -1385,7 +1379,6 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
std::vector<addr_t> exc_data;
addr_t thread_dispatch_qaddr = LLDB_INVALID_ADDRESS;
ThreadSP thread_sp;
- ThreadSP backing_thread_sp;
ThreadGDBRemote *gdb_thread = NULL;
while (stop_packet.GetNameColonValue(name, value))
@@ -1404,31 +1397,24 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
{
// thread in big endian hex
lldb::tid_t tid = Args::StringToUInt64 (value.c_str(), LLDB_INVALID_THREAD_ID, 16);
- // m_thread_list does have its own mutex, but we need to
- // hold onto the mutex between the call to m_thread_list.FindThreadByID(...)
- // and the m_thread_list.AddThread(...) so it doesn't change on us
- Mutex::Locker locker (m_thread_list.GetMutex ());
- thread_sp = m_thread_list.FindThreadByProtocolID(tid, false);
+ // m_thread_list_real does have its own mutex, but we need to
+ // hold onto the mutex between the call to m_thread_list_real.FindThreadByID(...)
+ // and the m_thread_list_real.AddThread(...) so it doesn't change on us
+ Mutex::Locker locker (m_thread_list_real.GetMutex ());
+ thread_sp = m_thread_list_real.FindThreadByProtocolID(tid, false);
- if (thread_sp)
- {
- backing_thread_sp = thread_sp->GetBackingThread();
- if (backing_thread_sp)
- gdb_thread = static_cast<ThreadGDBRemote *> (backing_thread_sp.get());
- else
- gdb_thread = static_cast<ThreadGDBRemote *> (thread_sp.get());
- }
- else
+ if (!thread_sp)
{
// Create the thread if we need to
thread_sp.reset (new ThreadGDBRemote (*this, tid));
- gdb_thread = static_cast<ThreadGDBRemote *> (thread_sp.get());
- m_thread_list.AddThread(thread_sp);
+ m_thread_list_real.AddThread(thread_sp);
}
+ gdb_thread = static_cast<ThreadGDBRemote *> (thread_sp.get());
+
}
else if (name.compare("threads") == 0)
{
- Mutex::Locker locker(m_thread_list.GetMutex());
+ Mutex::Locker locker(m_thread_list_real.GetMutex());
m_thread_ids.clear();
// A comma separated list of all threads in the current
// process that includes the thread for this stop reply
@@ -1508,6 +1494,9 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
if (thread_sp)
{
+ // Clear the stop info just in case we don't set it to anything
+ thread_sp->SetStopInfo (StopInfoSP());
+
gdb_thread->SetThreadDispatchQAddr (thread_dispatch_qaddr);
gdb_thread->SetName (thread_name.empty() ? NULL : thread_name.c_str());
if (exc_type != 0)
@@ -1610,11 +1599,6 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
if (!handled)
thread_sp->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
}
- else
- {
- StopInfoSP invalid_stop_info_sp;
- thread_sp->SetStopInfo (invalid_stop_info_sp);
- }
if (!description.empty())
{
@@ -1647,7 +1631,7 @@ ProcessGDBRemote::SetThreadStopInfo (StringExtractor& stop_packet)
void
ProcessGDBRemote::RefreshStateAfterStop ()
{
- Mutex::Locker locker(m_thread_list.GetMutex());
+ Mutex::Locker locker(m_thread_list_real.GetMutex());
m_thread_ids.clear();
// Set the thread stop info. It might have a "threads" key whose value is
// a list of all thread IDs in the current process, so m_thread_ids might
@@ -1662,7 +1646,7 @@ ProcessGDBRemote::RefreshStateAfterStop ()
// Let all threads recover from stopping and do any clean up based
// on the previous thread state (if any).
- m_thread_list.RefreshStateAfterStop();
+ m_thread_list_real.RefreshStateAfterStop();
}
@@ -2330,6 +2314,7 @@ void
ProcessGDBRemote::Clear()
{
m_flags = 0;
+ m_thread_list_real.Clear();
m_thread_list.Clear();
}
OpenPOWER on IntegriCloud