Added a new plug-in type: lldb_private::OperatingSystem. The operating system
plug-ins are add on plug-ins for the lldb_private::Process class that can add
thread contexts that are read from memory. It is common in kernels to have
a lot of threads that are not currently executing on any cores (JTAG debugging
also follows this sort of thing) and are context switched out whose state is
stored in memory data structures. Clients can now subclass the OperatingSystem
plug-ins and then make sure their Create functions correcltly only enable
themselves when the right binary/target triple are being debugged. The
operating system plug-ins get a chance to attach themselves to processes just
after launching or attaching and are given a lldb_private::Process object
pointer which can be inspected to see if the main executable, target triple,
or any shared libraries match a case where the OS plug-in should be used.
Currently the OS plug-ins can create new threads, define the register contexts
for these threads (which can all be different if desired), and populate and
manage the thread info (stop reason, registers in the register context) as
the debug session goes on.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@138228 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index 558a02a..0c02ff6 100644
--- a/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -390,7 +390,7 @@
{
// We have a valid process
SetID (pid);
- UpdateThreadListIfNeeded ();
+ GetThreadList();
if (m_gdb_comm.SendPacketAndWaitForResponse("?", 1, m_last_stop_packet, false))
{
const StateType state = SetThreadStopInfo (m_last_stop_packet);
@@ -1062,43 +1062,32 @@
}
uint32_t
-ProcessGDBRemote::UpdateThreadListIfNeeded ()
+ProcessGDBRemote::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list)
{
// locker will keep a mutex locked until it goes out of scope
LogSP log (ProcessGDBRemoteLog::GetLogIfAllCategoriesSet (GDBR_LOG_THREAD));
if (log && log->GetMask().Test(GDBR_LOG_VERBOSE))
log->Printf ("ProcessGDBRemote::%s (pid = %i)", __FUNCTION__, GetID());
+ // Update the thread list's stop id immediately so we don't recurse into this function.
- Mutex::Locker locker (m_thread_list.GetMutex ());
- const uint32_t stop_id = GetStopID();
- if (m_thread_list.GetSize(false) == 0 || stop_id != m_thread_list.GetStopID())
+ std::vector<lldb::tid_t> thread_ids;
+ bool sequence_mutex_unavailable = false;
+ const size_t num_thread_ids = m_gdb_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable);
+ if (num_thread_ids > 0)
{
- // Update the thread list's stop id immediately so we don't recurse into this function.
- ThreadList curr_thread_list (this);
- curr_thread_list.SetStopID(stop_id);
-
- std::vector<lldb::tid_t> thread_ids;
- bool sequence_mutex_unavailable = false;
- const size_t num_thread_ids = m_gdb_comm.GetCurrentThreadIDs (thread_ids, sequence_mutex_unavailable);
- if (num_thread_ids > 0)
+ for (size_t i=0; i<num_thread_ids; ++i)
{
- for (size_t i=0; i<num_thread_ids; ++i)
- {
- tid_t tid = thread_ids[i];
- ThreadSP thread_sp (GetThreadList().FindThreadByID (tid, false));
- if (!thread_sp)
- thread_sp.reset (new ThreadGDBRemote (*this, tid));
- curr_thread_list.AddThread(thread_sp);
- }
- }
-
- if (sequence_mutex_unavailable == false)
- {
- m_thread_list = curr_thread_list;
- SetThreadStopInfo (m_last_stop_packet);
+ tid_t tid = thread_ids[i];
+ ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false));
+ if (!thread_sp)
+ thread_sp.reset (new ThreadGDBRemote (*this, tid));
+ new_thread_list.AddThread(thread_sp);
}
}
- return GetThreadList().GetSize(false);
+
+ if (sequence_mutex_unavailable == false)
+ SetThreadStopInfo (m_last_stop_packet);
+ return new_thread_list.GetSize(false);
}
@@ -1318,7 +1307,7 @@
}
}
if (!handled)
- gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
+ gdb_thread->SetStopInfo (StopInfo::CreateStopReasonWithSignal (*thread_sp, signo));
}
else
{