diff options
| author | Todd Fiala <todd.fiala@gmail.com> | 2014-09-29 22:57:05 +0000 |
|---|---|---|
| committer | Todd Fiala <todd.fiala@gmail.com> | 2014-09-29 22:57:05 +0000 |
| commit | e2109e732382ee5a8cc1e57cd54d9ecd2cfbb97a (patch) | |
| tree | e12daf04b8f86d9cdbe6a15e2eb701c797cc2f07 /lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp | |
| parent | 6bddb8c3a57ad79849f97c5775479e00bafb0c7e (diff) | |
| download | bcm5719-llvm-e2109e732382ee5a8cc1e57cd54d9ecd2cfbb97a.tar.gz bcm5719-llvm-e2109e732382ee5a8cc1e57cd54d9ecd2cfbb97a.zip | |
thread state coordinator: added a thread resume request and related tests.
The thread resume block is executed in the normal flow of thread
state queued event processing. The tests verify that it is executed
when we track the thread to be stopped and skipped when we track
it to already be running.
llvm-svn: 218638
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp')
| -rw-r--r-- | lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp index b6d1382577d..cd5ad6df3da 100644 --- a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp +++ b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp @@ -260,6 +260,48 @@ private: //===----------------------------------------------------------------------===// +class ThreadStateCoordinator::EventRequestResume : public ThreadStateCoordinator::EventBase +{ +public: + EventRequestResume (lldb::tid_t tid, const ThreadIDFunc &request_thread_resume_func): + EventBase (), + m_tid (tid), + m_request_thread_resume_func (request_thread_resume_func) + { + } + + bool + ProcessEvent(ThreadStateCoordinator &coordinator) override + { + // Tell the thread to resume if we don't already think it is running. + auto find_it = coordinator.m_tid_stop_map.find (m_tid); + if (find_it == coordinator.m_tid_stop_map.end ()) + { + // Skip the resume call - we think it is already running because we don't know anything about the thread. + coordinator.Log ("EventRequestResume::%s skipping resume request because we don't know about tid %" PRIu64 " and we therefore assume it is running.", __FUNCTION__, m_tid); + return true; + } + else if (!find_it->second) + { + // Skip the resume call - we have tracked it to be running. + coordinator.Log ("EventRequestResume::%s skipping resume request because tid %" PRIu64 " is already running according to our state tracking.", __FUNCTION__, m_tid); + return true; + } + + // Request a resume. We expect this to be synchronous and the system + // to reflect it is running after this completes. + m_request_thread_resume_func (m_tid); + return true; + } + +private: + + const lldb::tid_t m_tid; + ThreadIDFunc m_request_thread_resume_func; +}; + +//===----------------------------------------------------------------------===// + ThreadStateCoordinator::ThreadStateCoordinator (const LogFunc &log_func) : m_log_func (log_func), m_event_queue (), @@ -415,6 +457,12 @@ ThreadStateCoordinator::NotifyThreadStop (lldb::tid_t tid) } void +ThreadStateCoordinator::RequestThreadResume (lldb::tid_t tid, const ThreadIDFunc &request_thread_resume_func) +{ + EnqueueEvent (EventBaseSP (new EventRequestResume (tid, request_thread_resume_func))); +} + +void ThreadStateCoordinator::NotifyThreadCreate (lldb::tid_t tid) { EnqueueEvent (EventBaseSP (new EventThreadCreate (tid))); |

