Add accessors on process to get & set the selected thread by IndexID (useful since that's the one that "thread list" shows and it won't get reused even if the underlying system thread ID gets reused.

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160187 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/API/SBProcess.cpp b/source/API/SBProcess.cpp
index b764e55..801daa4 100644
--- a/source/API/SBProcess.cpp
+++ b/source/API/SBProcess.cpp
@@ -405,6 +405,26 @@
     return ret_val;
 }
 
+bool
+SBProcess::SetSelectedThreadByIndexID (uint32_t index_id)
+{
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+
+    bool ret_val = false;
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
+        ret_val = process_sp->GetThreadList().SetSelectedThreadByIndexID (index_id);
+    }
+
+    if (log)
+        log->Printf ("SBProcess(%p)::SetSelectedThreadByID (tid=0x%x) => %s", 
+                     process_sp.get(), index_id, (ret_val ? "true" : "false"));
+
+    return ret_val;
+}
+
 SBThread
 SBProcess::GetThreadAtIndex (size_t index)
 {
@@ -725,6 +745,33 @@
     return sb_thread;
 }
 
+SBThread
+SBProcess::GetThreadByIndexID (uint32_t index_id)
+{
+    SBThread sb_thread;
+    ThreadSP thread_sp;
+    ProcessSP process_sp(GetSP());
+    if (process_sp)
+    {
+        Mutex::Locker api_locker (process_sp->GetTarget().GetAPIMutex());
+        Process::StopLocker stop_locker;
+        const bool can_update = stop_locker.TryLock(&process_sp->GetRunLock());
+        thread_sp = process_sp->GetThreadList().FindThreadByIndexID (index_id, can_update);
+        sb_thread.SetThread (thread_sp);
+    }
+
+    LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
+    if (log)
+    {
+        log->Printf ("SBProcess(%p)::GetThreadByID (tid=0x%x) => SBThread (%p)", 
+                     process_sp.get(), 
+                     index_id,
+                     thread_sp.get());
+    }
+
+    return sb_thread;
+}
+
 StateType
 SBProcess::GetStateFromEvent (const SBEvent &event)
 {