summaryrefslogtreecommitdiffstats
path: root/lldb/source/Plugins/Process/Linux
diff options
context:
space:
mode:
authorTodd Fiala <todd.fiala@gmail.com>2014-10-02 19:44:32 +0000
committerTodd Fiala <todd.fiala@gmail.com>2014-10-02 19:44:32 +0000
commitb72209102f864145144e185b583dd68916e8e45b (patch)
treedc5a752ef86e047e88bec1270ac521592b613e0a /lldb/source/Plugins/Process/Linux
parentee7902d3b239aae0507e055369768caa2eef6bcb (diff)
downloadbcm5719-llvm-b72209102f864145144e185b583dd68916e8e45b.tar.gz
bcm5719-llvm-b72209102f864145144e185b583dd68916e8e45b.zip
thread state coordinator: add tests and impl to error on creation/death issues.
Added tests and impl to make sure the following errors are reported: * Notifying a created thread that we are already tracking. * Notifying a thread death for a thread we don't know about. llvm-svn: 218900
Diffstat (limited to 'lldb/source/Plugins/Process/Linux')
-rw-r--r--lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp32
-rw-r--r--lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.h4
2 files changed, 29 insertions, 7 deletions
diff --git a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
index b6b9412db15..5d6bede742c 100644
--- a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
+++ b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.cpp
@@ -337,7 +337,7 @@ public:
EventLoopResult
ProcessEvent(ThreadStateCoordinator &coordinator) override
{
- coordinator.ThreadWasCreated (m_tid, m_is_stopped);
+ coordinator.ThreadWasCreated (m_tid, m_is_stopped, m_error_function);
return eventLoopResultContinue;
}
@@ -364,7 +364,7 @@ public:
EventLoopResult
ProcessEvent(ThreadStateCoordinator &coordinator) override
{
- coordinator.ThreadDidDie (m_tid);
+ coordinator.ThreadDidDie (m_tid, m_error_function);
return eventLoopResultContinue;
}
@@ -568,8 +568,19 @@ ThreadStateCoordinator::ThreadDidStop (lldb::tid_t tid, ErrorFunction &error_fun
}
void
-ThreadStateCoordinator::ThreadWasCreated (lldb::tid_t tid, bool is_stopped)
+ThreadStateCoordinator::ThreadWasCreated (lldb::tid_t tid, bool is_stopped, ErrorFunction &error_function)
{
+ // Ensure we don't already know about the thread.
+ auto find_it = m_tid_stop_map.find (tid);
+ if (find_it != m_tid_stop_map.end ())
+ {
+ // We already know about this thread. This is an error condition.
+ std::ostringstream error_message;
+ error_message << "error: notified tid " << tid << " created but we already know about this thread";
+ error_function (error_message.str ());
+ return;
+ }
+
// Add the new thread to the stop map.
m_tid_stop_map[tid] = is_stopped;
@@ -583,12 +594,23 @@ ThreadStateCoordinator::ThreadWasCreated (lldb::tid_t tid, bool is_stopped)
}
void
-ThreadStateCoordinator::ThreadDidDie (lldb::tid_t tid)
+ThreadStateCoordinator::ThreadDidDie (lldb::tid_t tid, ErrorFunction &error_function)
{
+ // Ensure we know about the thread.
+ auto find_it = m_tid_stop_map.find (tid);
+ if (find_it == m_tid_stop_map.end ())
+ {
+ // We don't know about this thread. This is an error condition.
+ std::ostringstream error_message;
+ error_message << "error: notified tid " << tid << " died but tid is unknown";
+ error_function (error_message.str ());
+ return;
+ }
+
// Update the global list of known thread states. While this one is stopped, it is also dead.
// So stop tracking it. We assume the user of this coordinator will not keep trying to add
// dependencies on a thread after it is known to be dead.
- m_tid_stop_map.erase (tid);
+ m_tid_stop_map.erase (find_it);
// If we have a pending notification, remove this from the set.
EventCallAfterThreadsStop *const call_after_event = GetPendingThreadStopNotification ();
diff --git a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.h b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.h
index 4e318b53d6e..b9a845c3e57 100644
--- a/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.h
+++ b/lldb/source/Plugins/Process/Linux/ThreadStateCoordinator.h
@@ -150,10 +150,10 @@ namespace lldb_private
ThreadDidStop (lldb::tid_t tid, ErrorFunction &error_function);
void
- ThreadWasCreated (lldb::tid_t tid, bool is_stopped);
+ ThreadWasCreated (lldb::tid_t tid, bool is_stopped, ErrorFunction &error_function);
void
- ThreadDidDie (lldb::tid_t tid);
+ ThreadDidDie (lldb::tid_t tid, ErrorFunction &error_function);
void
ResetNow ();
OpenPOWER on IntegriCloud