summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/OperatingSystem/Python
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2013-05-01 21:54:04 +0000
committerGreg Clayton <gclayton@apple.com>2013-05-01 21:54:04 +0000
commit160c9d81e07fec2d6299a9f31bb004f1b97419a6 (patch)
tree01aef16f7f4a45a2eb3c37b5083eda3c8e9cc429 /lldb/source/Plugins/OperatingSystem/Python
parent5ed5181178f256f99954f2662547658a49335088 (diff)
downloadbcm5719-llvm-160c9d81e07fec2d6299a9f31bb004f1b97419a6.tar.gz
bcm5719-llvm-160c9d81e07fec2d6299a9f31bb004f1b97419a6.zip
<rdar://problem/13700260>
<rdar://problem/13723772> Modified the lldb_private::Thread to work much better with the OperatingSystem plug-ins. Operating system plug-ins can now return have a "core" key/value pair in each thread dictionary for the OperatingSystemPython plug-ins which allows the core threads to be contained with memory threads. It also allows these memory threads to be stepped, resumed, and controlled just as if they were the actual backing threads themselves. A few things are introduced: - lldb_private::Thread now has a GetProtocolID() method which returns the thread protocol ID for a given thread. The protocol ID (Thread::GetProtocolID()) is usually the same as the thread id (Thread::GetID()), but it can differ when a memory thread has its own id, but is backed by an actual API thread. - Cleaned up the Thread::WillResume() code to do the mandatory parts in Thread::ShouldResume(), and let the thread subclasses override the Thread::WillResume() which is now just a notification. - Cleaned up ClearStackFrames() implementations so that fewer thread subclasses needed to override them - Changed the POSIXThread class a bit since it overrode Thread::WillResume(). It is doing the wrong thing by calling "Thread::SetResumeState()" on its own, this shouldn't be done by thread subclasses, but the current code might rely on it so I left it in with a TODO comment with an explanation. llvm-svn: 180886
Diffstat (limited to 'lldb/source/Plugins/OperatingSystem/Python')
-rw-r--r--lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp46
1 files changed, 40 insertions, 6 deletions
diff --git a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
index a7aaedb9a0c..fc05d6e18ec 100644
--- a/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
+++ b/lldb/source/Plugins/OperatingSystem/Python/OperatingSystemPython.cpp
@@ -247,8 +247,8 @@ OperatingSystemPython::CreateThreadFromThreadInfo (PythonDictionary &thread_dict
PythonString core_pystr("core");
PythonString name_pystr("name");
PythonString queue_pystr("queue");
- PythonString state_pystr("state");
- PythonString stop_reason_pystr("stop_reason");
+ //PythonString state_pystr("state");
+ //PythonString stop_reason_pystr("stop_reason");
PythonString reg_data_addr_pystr ("register_data_addr");
const uint32_t core_number = thread_dict.GetItemForKeyAsInteger (core_pystr, UINT32_MAX);
@@ -258,7 +258,21 @@ OperatingSystemPython::CreateThreadFromThreadInfo (PythonDictionary &thread_dict
//const char *state = thread_dict.GetItemForKeyAsString (state_pystr);
//const char *stop_reason = thread_dict.GetItemForKeyAsString (stop_reason_pystr);
+ // See if a thread already exists for "tid"
thread_sp = old_thread_list.FindThreadByID (tid, false);
+ if (thread_sp)
+ {
+ // A thread already does exist for "tid", make sure it was an operating system
+ // plug-in generated thread.
+ if (!IsOperatingSystemPluginThread(thread_sp))
+ {
+ // We have thread ID overlap between the protocol threads and the
+ // operating system threads, clear the thread so we create an
+ // operating system thread for this.
+ thread_sp.reset();
+ }
+ }
+
if (!thread_sp)
{
if (did_create_ptr)
@@ -273,7 +287,19 @@ OperatingSystemPython::CreateThreadFromThreadInfo (PythonDictionary &thread_dict
if (core_number < core_thread_list.GetSize(false))
{
- thread_sp->SetBackingThread(core_thread_list.GetThreadAtIndex(core_number, false));
+ ThreadSP core_thread_sp (core_thread_list.GetThreadAtIndex(core_number, false));
+ if (core_thread_sp)
+ {
+ ThreadSP backing_core_thread_sp (core_thread_sp->GetBackingThread());
+ if (backing_core_thread_sp)
+ {
+ thread_sp->SetBackingThread(backing_core_thread_sp);
+ }
+ else
+ {
+ thread_sp->SetBackingThread(core_thread_sp);
+ }
+ }
}
}
}
@@ -292,7 +318,10 @@ OperatingSystemPython::CreateRegisterContextForThread (Thread *thread, addr_t re
{
RegisterContextSP reg_ctx_sp;
if (!m_interpreter || !m_python_object_sp || !thread)
- return RegisterContextSP();
+ return reg_ctx_sp;
+
+ if (!IsOperatingSystemPluginThread(thread->shared_from_this()))
+ return reg_ctx_sp;
// First thing we have to do is get the API lock, and the run lock. We're going to change the thread
// content of the process, and we're going to use python, which requires the API lock to do it.
@@ -308,7 +337,10 @@ OperatingSystemPython::CreateRegisterContextForThread (Thread *thread, addr_t re
// The registers data is in contiguous memory, just create the register
// context using the address provided
if (log)
- log->Printf ("OperatingSystemPython::CreateRegisterContextForThread (tid = 0x%" PRIx64 ", reg_data_addr = 0x%" PRIx64 ") creating memory register context", thread->GetID(), reg_data_addr);
+ log->Printf ("OperatingSystemPython::CreateRegisterContextForThread (tid = 0x%" PRIx64 ", 0x%" PRIx64 ", reg_data_addr = 0x%" PRIx64 ") creating memory register context",
+ thread->GetID(),
+ thread->GetProtocolID(),
+ reg_data_addr);
reg_ctx_sp.reset (new RegisterContextMemory (*thread, 0, *GetDynamicRegisterInfo (), reg_data_addr));
}
else
@@ -316,7 +348,9 @@ OperatingSystemPython::CreateRegisterContextForThread (Thread *thread, addr_t re
// No register data address is provided, query the python plug-in to let
// it make up the data as it sees fit
if (log)
- log->Printf ("OperatingSystemPython::CreateRegisterContextForThread (tid = 0x%" PRIx64 ") fetching register data from python", thread->GetID());
+ log->Printf ("OperatingSystemPython::CreateRegisterContextForThread (tid = 0x%" PRIx64 ", 0x%" PRIx64 ") fetching register data from python",
+ thread->GetID(),
+ thread->GetProtocolID());
PythonString reg_context_data(m_interpreter->OSPlugin_RegisterContextData (m_python_object_sp, thread->GetID()));
if (reg_context_data)
OpenPOWER on IntegriCloud