Enable debugging of multithreaded programs on Windows.

llvm-svn: 237637
diff --git a/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp b/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp
index dfc4924..0959fc2 100644
--- a/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp
+++ b/lldb/source/Plugins/Process/Windows/DebuggerThread.cpp
@@ -283,9 +283,9 @@
 {
     bool first_chance = (info.dwFirstChance != 0);
 
-    m_active_exception.reset(new ExceptionRecord(info.ExceptionRecord));
+    m_active_exception.reset(new ExceptionRecord(info.ExceptionRecord, thread_id));
     WINLOG_IFANY(WINDOWS_LOG_EVENT | WINDOWS_LOG_EXCEPTION,
-                 "HandleExceptionEvent encountered %s chance exception 0x%x on thread %u",
+                 "HandleExceptionEvent encountered %s chance exception 0x%x on thread 0x%x",
                  first_chance ? "first" : "second", info.ExceptionRecord.ExceptionCode, thread_id);
 
     ExceptionResult result = m_debug_delegate->OnDebugException(first_chance,
@@ -308,9 +308,11 @@
 DebuggerThread::HandleCreateThreadEvent(const CREATE_THREAD_DEBUG_INFO &info, DWORD thread_id)
 {
     WINLOG_IFANY(WINDOWS_LOG_EVENT|WINDOWS_LOG_THREAD,
-        "HandleCreateThreadEvent Thread %u spawned in process %I64u",
-        m_process.GetProcessId(), thread_id);
-
+        "HandleCreateThreadEvent Thread 0x%x spawned in process %I64u",
+        thread_id, m_process.GetProcessId());
+    HostThread thread(info.hThread);
+    thread.GetNativeThread().SetOwnsHandle(false);
+    m_debug_delegate->OnCreateThread(thread);
     return DBG_CONTINUE;
 }
 
@@ -347,7 +349,7 @@
     WINLOG_IFANY(WINDOWS_LOG_EVENT|WINDOWS_LOG_THREAD,
         "HandleExitThreadEvent Thread %u exited with code %u in process %I64u",
         thread_id, info.dwExitCode, m_process.GetProcessId());
-
+    m_debug_delegate->OnExitThread(thread_id, info.dwExitCode);
     return DBG_CONTINUE;
 }
 
@@ -358,9 +360,9 @@
         "HandleExitProcessEvent process %I64u exited with code %u",
         m_process.GetProcessId(), info.dwExitCode);
 
-    FreeProcessHandles();
-
     m_debug_delegate->OnExitProcess(info.dwExitCode);
+
+    FreeProcessHandles();
     return DBG_CONTINUE;
 }