summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/MacOSX-Kernel
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/MacOSX-Kernel
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/MacOSX-Kernel')
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp27
-rw-r--r--lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h10
2 files changed, 20 insertions, 17 deletions
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
index f9b1055644b..1ed1cb0aab3 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.cpp
@@ -44,6 +44,8 @@
using namespace lldb;
using namespace lldb_private;
+static const lldb::tid_t g_kernel_tid = 1;
+
const char *
ProcessKDP::GetPluginNameStatic()
{
@@ -116,7 +118,8 @@ ProcessKDP::ProcessKDP(Target& target, Listener &listener) :
m_async_thread (LLDB_INVALID_HOST_THREAD),
m_dyld_plugin_name (),
m_kernel_load_addr (LLDB_INVALID_ADDRESS),
- m_command_sp()
+ m_command_sp(),
+ m_kernel_thread_wp()
{
m_async_broadcaster.SetEventName (eBroadcastBitAsyncThreadShouldExit, "async thread should exit");
m_async_broadcaster.SetEventName (eBroadcastBitAsyncContinue, "async thread continue");
@@ -374,7 +377,8 @@ ProcessKDP::DoResume ()
bool resume = false;
// With KDP there is only one thread we can tell what to do
- ThreadSP kernel_thread_sp (GetKernelThread(m_thread_list, m_thread_list));
+ ThreadSP kernel_thread_sp (m_thread_list.FindThreadByProtocolID(g_kernel_tid));
+
if (kernel_thread_sp)
{
const StateType thread_resume_state = kernel_thread_sp->GetTemporaryResumeState();
@@ -446,15 +450,17 @@ ProcessKDP::DoResume ()
}
lldb::ThreadSP
-ProcessKDP::GetKernelThread(ThreadList &old_thread_list, ThreadList &new_thread_list)
+ProcessKDP::GetKernelThread()
{
// KDP only tells us about one thread/core. Any other threads will usually
// be the ones that are read from memory by the OS plug-ins.
- const lldb::tid_t kernel_tid = 1;
- ThreadSP thread_sp (old_thread_list.FindThreadByID (kernel_tid, false));
+
+ ThreadSP thread_sp (m_kernel_thread_wp.lock());
if (!thread_sp)
- thread_sp.reset(new ThreadKDP (*this, kernel_tid));
- new_thread_list.AddThread(thread_sp);
+ {
+ thread_sp.reset(new ThreadKDP (*this, g_kernel_tid));
+ m_kernel_thread_wp = thread_sp;
+ }
return thread_sp;
}
@@ -471,7 +477,10 @@ ProcessKDP::UpdateThreadList (ThreadList &old_thread_list, ThreadList &new_threa
// Even though there is a CPU mask, it doesn't mean we can see each CPU
// indivudually, there is really only one. Lets call this thread 1.
- GetKernelThread (old_thread_list, new_thread_list);
+ ThreadSP thread_sp (old_thread_list.FindThreadByProtocolID(g_kernel_tid));
+ if (!thread_sp)
+ thread_sp = GetKernelThread ();
+ new_thread_list.AddThread(thread_sp);
return new_thread_list.GetSize(false) > 0;
}
@@ -795,7 +804,7 @@ ProcessKDP::AsyncThread (void *arg)
is_running = true;
if (process->m_comm.WaitForPacketWithTimeoutMicroSeconds (exc_reply_packet, 1 * USEC_PER_SEC))
{
- ThreadSP thread_sp (process->GetKernelThread(process->GetThreadList(), process->GetThreadList()));
+ ThreadSP thread_sp (process->GetKernelThread());
if (thread_sp)
{
lldb::RegisterContextSP reg_ctx_sp (thread_sp->GetRegisterContext());
diff --git a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
index 9de262322ae..1dff43f1090 100644
--- a/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
+++ b/lldb/source/Plugins/Process/MacOSX-Kernel/ProcessKDP.h
@@ -225,12 +225,6 @@ protected:
bool
ProcessIDIsValid ( ) const;
- // static void
- // STDIOReadThreadBytesReceived (void *baton, const void *src, size_t src_len);
-
- // void
- // AppendSTDOUT (const char* s, size_t len);
-
void
Clear ( );
@@ -245,8 +239,7 @@ protected:
};
lldb::ThreadSP
- GetKernelThread (lldb_private::ThreadList &old_thread_list,
- lldb_private::ThreadList &new_thread_list);
+ GetKernelThread ();
//------------------------------------------------------------------
/// Broadcaster event bits definitions.
@@ -257,6 +250,7 @@ protected:
std::string m_dyld_plugin_name;
lldb::addr_t m_kernel_load_addr;
lldb::CommandObjectSP m_command_sp;
+ lldb::ThreadWP m_kernel_thread_wp;
bool
OpenPOWER on IntegriCloud