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/MacOSX-Kernel/ProcessKDP.cpp b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index 401fd9a..a841220 100644
--- a/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -185,7 +185,7 @@
kernel_arch.SetArchitecture(eArchTypeMachO, cpu, sub);
m_target.SetArchitecture(kernel_arch);
SetID (1);
- UpdateThreadListIfNeeded ();
+ GetThreadList ();
SetPrivateState (eStateStopped);
StreamSP async_strm_sp(m_target.GetDebugger().GetAsyncOutputStream());
if (async_strm_sp)
@@ -289,34 +289,28 @@
}
uint32_t
-ProcessKDP::UpdateThreadListIfNeeded ()
+ProcessKDP::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_thread_list)
{
// locker will keep a mutex locked until it goes out of scope
LogSP log (ProcessKDPLog::GetLogIfAllCategoriesSet (KDP_LOG_THREAD));
if (log && log->GetMask().Test(KDP_LOG_VERBOSE))
log->Printf ("ProcessKDP::%s (pid = %i)", __FUNCTION__, GetID());
- Mutex::Locker locker (m_thread_list.GetMutex ());
- const uint32_t stop_id = GetStopID();
- if (m_thread_list.GetSize(false) == 0)
+ // We currently are making only one thread per core and we
+ // actually don't know about actual threads. Eventually we
+ // want to get the thread list from memory and note which
+ // threads are on CPU as those are the only ones that we
+ // will be able to resume.
+ const uint32_t cpu_mask = m_comm.GetCPUMask();
+ for (uint32_t cpu_mask_bit = 1; cpu_mask_bit & cpu_mask; cpu_mask_bit <<= 1)
{
- // We currently are making only one thread per core and we
- // actually don't know about actual threads. Eventually we
- // want to get the thread list from memory and note which
- // threads are on CPU as those are the only ones that we
- // will be able to resume.
- ThreadList curr_thread_list (this);
- curr_thread_list.SetStopID(stop_id);
- const uint32_t cpu_mask = m_comm.GetCPUMask();
- for (uint32_t cpu_mask_bit = 1; cpu_mask_bit & cpu_mask; cpu_mask_bit <<= 1)
- {
- // The thread ID is currently the CPU mask bit
- ThreadSP thread_sp (new ThreadKDP (*this, cpu_mask_bit));
- curr_thread_list.AddThread(thread_sp);
- }
- m_thread_list = curr_thread_list;
+ lldb::tid_t tid = cpu_mask_bit;
+ ThreadSP thread_sp (old_thread_list.FindThreadByID (tid, false));
+ if (!thread_sp)
+ thread_sp.reset(new ThreadKDP (*this, tid));
+ new_thread_list.AddThread(thread_sp);
}
- return GetThreadList().GetSize(false);
+ return new_thread_list.GetSize(false);
}