Index: lib/Makefile
===================================================================
--- lib/Makefile	(revision 154566)
+++ lib/Makefile	(working copy)
@@ -65,7 +65,8 @@
 	LLVMMCDisassembler.a \
 	lldbPluginPlatformMacOSX.a \
 	lldbPluginPlatformLinux.a \
-	lldbPluginPlatformFreeBSD.a
+	lldbPluginPlatformFreeBSD.a \
+	lldbPluginPlatformPOSIX.a
 
 include $(LLDB_LEVEL)/../../Makefile.config
 
Index: source/Plugins/Platform/POSIX/Makefile
===================================================================
--- source/Plugins/Platform/POSIX/Makefile	(revision 0)
+++ source/Plugins/Platform/POSIX/Makefile	(working copy)
@@ -0,0 +1,14 @@
+##===- source/Plugins/Platform/Linux/Makefile --------------*- Makefile -*-===##
+#
+#                     The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+
+LLDB_LEVEL := ../../../..
+LIBRARYNAME := lldbPluginPlatformPOSIX
+BUILD_ARCHIVE = 1
+
+include $(LLDB_LEVEL)/Makefile
Index: source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
===================================================================
--- source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp	(revision 154566)
+++ source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp	(working copy)
@@ -27,6 +27,10 @@
 Platform *
 PlatformFreeBSD::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
 {
+    // The only time we create an instance is when we are creating a remote
+    // freebsd platform
+    const bool is_host = false;
+
     bool create = force;
     if (create == false && arch && arch->IsValid())
     {
@@ -36,7 +40,7 @@
             create = true;
     }
     if (create)
-        return new PlatformFreeBSD (true);
+        return new PlatformFreeBSD (is_host);
     return NULL;
 
 }
@@ -65,29 +69,30 @@
         return "Remote FreeBSD user platform plug-in.";
 }
 
+static uint32_t g_initialize_count = 0;
+
 void
 PlatformFreeBSD::Initialize ()
 {
-    static bool g_initialized = false;
-
-    if (!g_initialized)
+    if (g_initialize_count++ == 0)
     {
 #if defined (__FreeBSD__)
-        PlatformSP default_platform_sp (CreateInstance());
+    	// Force a host flag to true for the default platform object.
+        PlatformSP default_platform_sp (new PlatformFreeBSD(true));
         default_platform_sp->SetSystemArchitecture (Host::GetArchitecture());
         Platform::SetDefaultPlatform (default_platform_sp);
 #endif
         PluginManager::RegisterPlugin(PlatformFreeBSD::GetShortPluginNameStatic(false),
                                       PlatformFreeBSD::GetDescriptionStatic(false),
                                       PlatformFreeBSD::CreateInstance);
-        g_initialized = true;
     }
 }
 
 void
 PlatformFreeBSD::Terminate ()
 {
-    PluginManager::UnregisterPlugin (PlatformFreeBSD::CreateInstance);
+    if (g_initialize_count > 0 && --g_initialize_count == 0)
+    	PluginManager::UnregisterPlugin (PlatformFreeBSD::CreateInstance);
 }
 
 //------------------------------------------------------------------
Index: source/Plugins/Platform/Makefile
===================================================================
--- source/Plugins/Platform/Makefile	(revision 154566)
+++ source/Plugins/Platform/Makefile	(working copy)
@@ -1,26 +1,26 @@
 ##===- source/Plugins/Platform/Makefile --------------------*- Makefile -*-===##
-# 
+#
 #                     The LLVM Compiler Infrastructure
 #
 # This file is distributed under the University of Illinois Open Source
 # License. See LICENSE.TXT for details.
-# 
+#
 ##===----------------------------------------------------------------------===##
 
 LLDB_LEVEL := ../../..
 
 include $(LLDB_LEVEL)/../../Makefile.config
 
-DIRS := gdb-server MacOSX Linux FreeBSD
+DIRS := gdb-server MacOSX Linux FreeBSD POSIX
 
 # ifeq ($(HOST_OS),Darwin)
 #   DIRS += MacOSX
 # endif
-# 
+#
 # ifeq ($(HOST_OS),Linux)
 #   DIRS += Linux
 # endif
-# 
+#
 # ifeq ($(HOST_OS),FreeBSD)
 #   DIRS += FreeBSD
 # endif
Index: source/Plugins/Process/POSIX/ProcessPOSIX.cpp
===================================================================
--- source/Plugins/Process/POSIX/ProcessPOSIX.cpp	(revision 154566)
+++ source/Plugins/Process/POSIX/ProcessPOSIX.cpp	(working copy)
@@ -482,20 +482,14 @@
     return DisableSoftwareBreakpoint(bp_site);
 }
 
-uint32_t
-ProcessPOSIX::UpdateThreadListIfNeeded()
-{
-    // Do not allow recursive updates.
-    return m_thread_list.GetSize(false);
-}
-
-uint32_t
+bool
 ProcessPOSIX::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
 {
     LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("ProcessPOSIX::%s() (pid = %i)", __FUNCTION__, GetID());
 
+    bool has_updated = false;
     // Update the process thread list with this new thread.
     // FIXME: We should be using tid, not pid.
     assert(m_monitor);
@@ -503,13 +497,14 @@
     if (!thread_sp) {
         ProcessSP me = this->shared_from_this();
         thread_sp.reset(new POSIXThread(me, GetID()));
+        has_updated = true;
     }
 
     if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
         log->Printf ("ProcessPOSIX::%s() updated pid = %i", __FUNCTION__, GetID());
     new_thread_list.AddThread(thread_sp);
 
-    return new_thread_list.GetSize(false);
+    return has_updated; // the list has been updated
 }
 
 ByteOrder
Index: source/Plugins/Process/POSIX/ProcessPOSIX.h
===================================================================
--- source/Plugins/Process/POSIX/ProcessPOSIX.h	(revision 154566)
+++ source/Plugins/Process/POSIX/ProcessPOSIX.h	(working copy)
@@ -102,11 +102,9 @@
     virtual lldb_private::Error
     DisableBreakpoint(lldb_private::BreakpointSite *bp_site);
 
-    virtual uint32_t
-    UpdateThreadListIfNeeded();
-
-    virtual uint32_t
-    UpdateThreadList(lldb_private::ThreadList &old_thread_list, 
+    // This method returns true if the list was actually updated or false otherwise.
+    virtual bool
+    UpdateThreadList(lldb_private::ThreadList &old_thread_list,
                      lldb_private::ThreadList &new_thread_list) = 0;
 
     virtual lldb::ByteOrder
Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
===================================================================
--- source/Plugins/Process/FreeBSD/ProcessFreeBSD.h	(revision 154566)
+++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.h	(working copy)
@@ -54,7 +54,7 @@
     ProcessFreeBSD(lldb_private::Target& target,
                    lldb_private::Listener &listener);
 
-    virtual uint32_t
+    virtual bool
     UpdateThreadList(lldb_private::ThreadList &old_thread_list, lldb_private::ThreadList &new_thread_list);
 
     //------------------------------------------------------------------
Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
===================================================================
--- source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp	(revision 154566)
+++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp	(working copy)
@@ -131,11 +131,31 @@
 {
 }
 
-uint32_t
+bool
 ProcessFreeBSD::UpdateThreadList(ThreadList &old_thread_list, ThreadList &new_thread_list)
 {
-    // XXX haxx
-    new_thread_list = old_thread_list;
-  
-    return 0;
+    LogSP log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_THREAD));
+    if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+        log->Printf ("ProcessFreeBSD::%s() (pid = %i)", __FUNCTION__, GetID());
+
+    bool has_updated = false;
+
+    const tid_t tid = Host::GetCurrentThreadID();
+    const lldb::pid_t pid = GetID();
+    // Update the process thread list with this new thread.
+    // FIXME: We should be using tid, not pid.
+    assert(m_monitor);
+    ThreadSP thread_sp (old_thread_list.FindThreadByID (pid, false));
+    if (!thread_sp) {
+        ProcessSP me = this->shared_from_this();
+        thread_sp.reset(new POSIXThread(me, pid));
+        has_updated = true;
+    }
+
+    if (log && log->GetMask().Test(POSIX_LOG_VERBOSE))
+        log->Printf ("ProcessFreeBSD::%s() updated tid = %i", __FUNCTION__, pid);
+
+    new_thread_list.AddThread(thread_sp);
+
+    return has_updated; // the list has been updated
 }
Index: source/lldb.cpp
===================================================================
--- source/lldb.cpp	(revision 154566)
+++ source/lldb.cpp	(working copy)
@@ -40,6 +40,7 @@
 #include "Plugins/DynamicLoader/POSIX-DYLD/DynamicLoaderPOSIXDYLD.h"
 #include "Plugins/Platform/FreeBSD/PlatformFreeBSD.h"
 #include "Plugins/Platform/Linux/PlatformLinux.h"
+#include "Plugins/Platform/POSIX/PlatformPOSIX.h"
 #if defined (__APPLE__)
 #include "Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h"
 #include "Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h"
