summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
diff options
context:
space:
mode:
authorChaoren Lin <chaorenl@google.com>2015-02-03 01:50:42 +0000
committerChaoren Lin <chaorenl@google.com>2015-02-03 01:50:42 +0000
commitfa03ad2ebc7306bf2a952f9d5c5ca3d39cfff63c (patch)
tree4376308c4b5a235ee2ba213e1bd2751782e9665c /lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
parent56f981bfceaeeee00ad4097d29723cfb05e59bdf (diff)
downloadbcm5719-llvm-fa03ad2ebc7306bf2a952f9d5c5ca3d39cfff63c.tar.gz
bcm5719-llvm-fa03ad2ebc7306bf2a952f9d5c5ca3d39cfff63c.zip
Get initial thread state coordinator integration working.
* Fixed bug in run loop where run loop return enum was being treated erroneously like an int, causing the TSC event loop to terminate prematurely. * Added an explicit scope in NativeProcessLinux::Resume() for the threads lock lifetime. (This was likely unnecessary but is more explicit.) * Fixed a bug in ThreadStateCoordinator where resume execution was not updating the internal state about the thread assumed to be running now. I'll add a test and upstream this in a moment. * Added a verbose logging mechanism to event processing within ThreadStateCoordinator. It is currently enabled when the 'log enable lldb thread' is true upon inferior launch/attach. llvm-svn: 227909
Diffstat (limited to 'lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp')
-rw-r--r--lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp92
1 files changed, 90 insertions, 2 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
index 779e2494b1e..128173d4f45 100644
--- a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
+++ b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
@@ -35,6 +35,9 @@ public:
{
}
+ virtual std::string
+ GetDescription () = 0;
+
// Return false if the coordinator should terminate running.
virtual EventLoopResult
ProcessEvent (ThreadStateCoordinator &coordinator) = 0;
@@ -55,6 +58,12 @@ public:
{
return eventLoopResultStop;
}
+
+ std::string
+ GetDescription () override
+ {
+ return "EventStopCoordinator";
+ }
};
//===----------------------------------------------------------------------===//
@@ -190,6 +199,14 @@ public:
m_request_thread_stop_function (tid);
}
+ std::string
+ GetDescription () override
+ {
+ std::ostringstream description;
+ description << "EventCallAfterThreadsStop (triggering_tid=" << m_triggering_tid << ", request_stop_on_all_unstopped_threads=" << m_request_stop_on_all_unstopped_threads << ")";
+ return description.str ();
+ }
+
private:
void
@@ -291,6 +308,12 @@ public:
coordinator.ResetNow ();
return eventLoopResultContinue;
}
+
+ std::string
+ GetDescription () override
+ {
+ return "EventReset";
+ }
};
//===----------------------------------------------------------------------===//
@@ -313,6 +336,14 @@ public:
return eventLoopResultContinue;
}
+ std::string
+ GetDescription () override
+ {
+ std::ostringstream description;
+ description << "EventThreadStopped (tid=" << m_tid << ")";
+ return description.str ();
+ }
+
private:
const lldb::tid_t m_tid;
@@ -341,6 +372,14 @@ public:
return eventLoopResultContinue;
}
+ std::string
+ GetDescription () override
+ {
+ std::ostringstream description;
+ description << "EventThreadCreate (tid=" << m_tid << ", " << (m_is_stopped ? "stopped" : "running") << ")";
+ return description.str ();
+ }
+
private:
const lldb::tid_t m_tid;
@@ -368,6 +407,14 @@ public:
return eventLoopResultContinue;
}
+ std::string
+ GetDescription () override
+ {
+ std::ostringstream description;
+ description << "EventThreadDeath (tid=" << m_tid << ")";
+ return description.str ();
+ }
+
private:
const lldb::tid_t m_tid;
@@ -450,6 +497,14 @@ public:
return eventLoopResultContinue;
}
+ std::string
+ GetDescription () override
+ {
+ std::ostringstream description;
+ description << "EventRequestResume (tid=" << m_tid << ")";
+ return description.str ();
+ }
+
private:
const lldb::tid_t m_tid;
@@ -464,7 +519,8 @@ ThreadStateCoordinator::ThreadStateCoordinator (const LogFunction &log_function)
m_event_queue (),
m_queue_condition (),
m_queue_mutex (),
- m_tid_stop_map ()
+ m_tid_stop_map (),
+ m_log_event_processing (false)
{
}
@@ -711,7 +767,39 @@ ThreadStateCoordinator::StopCoordinator ()
ThreadStateCoordinator::EventLoopResult
ThreadStateCoordinator::ProcessNextEvent ()
{
- return DequeueEventWithWait()->ProcessEvent (*this);
+ // Dequeue the next event, synchronous.
+ if (m_log_event_processing)
+ Log ("ThreadStateCoordinator::%s about to dequeue next event in blocking mode", __FUNCTION__);
+
+ EventBaseSP event_sp = DequeueEventWithWait();
+ assert (event_sp && "event should never be null");
+ if (!event_sp)
+ {
+ Log ("ThreadStateCoordinator::%s error: event_sp was null, signaling exit of event loop.", __FUNCTION__);
+ return eventLoopResultStop;
+ }
+
+ if (m_log_event_processing)
+ {
+ Log ("ThreadStateCoordinator::%s about to process event: %s", __FUNCTION__, event_sp->GetDescription ().c_str ());
+ }
+
+ // Process the event.
+ const EventLoopResult result = event_sp->ProcessEvent (*this);
+
+ if (m_log_event_processing)
+ {
+ Log ("ThreadStateCoordinator::%s event processing returned value %s", __FUNCTION__,
+ result == eventLoopResultContinue ? "eventLoopResultContinue" : "eventLoopResultStop");
+ }
+
+ return result;
+}
+
+void
+ThreadStateCoordinator::LogEnableEventProcessing (bool enabled)
+{
+ m_log_event_processing = enabled;
}
ThreadStateCoordinator::EventCallAfterThreadsStop *
OpenPOWER on IntegriCloud