[Lldb-commits] [lldb] r154724 - in /lldb/trunk/source: Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Plugins/Process/POSIX/ProcessPOSIX.cpp lldb.cpp

Johnny Chen johnny.chen at apple.com
Fri Apr 13 17:54:42 PDT 2012


Author: johnny
Date: Fri Apr 13 19:54:42 2012
New Revision: 154724

URL: http://llvm.org/viewvc/llvm-project?rev=154724&view=rev
Log:
Patch from Viktor Kutuzov <vkutuzov at accesssoftek.com>:

Hello everyone,
 
please find the attached patch for TOT and lldb-platform-work branch, which provides the following changes:
 - fixed a crash in the ProcessPOSIX constructor when an executable module object is not yet created.
 - added support for the multi instanciated FreeBSD platform objects (the local host and remote as example).
 - enabled the remote gdb plugin on FreeBSD.

Modified:
    lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
    lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
    lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
    lldb/trunk/source/lldb.cpp

Modified: lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp?rev=154724&r1=154723&r2=154724&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Fri Apr 13 19:54:42 2012
@@ -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);
 }
 
 //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=154724&r1=154723&r2=154724&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original)
+++ lldb/trunk/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Fri Apr 13 19:54:42 2012
@@ -120,10 +120,6 @@
 ProcessFreeBSD::ProcessFreeBSD(Target& target, Listener &listener)
     : ProcessPOSIX(target, listener)
 {
-    // FIXME: Putting this code in the ctor and saving the byte order in a
-    // member variable is a hack to avoid const qual issues in GetByteOrder.
-    ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
-    m_byte_order = obj_file->GetByteOrder();
 }
 
 void

Modified: lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp?rev=154724&r1=154723&r2=154724&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Fri Apr 13 19:54:42 2012
@@ -66,6 +66,7 @@
 
 ProcessPOSIX::ProcessPOSIX(Target& target, Listener &listener)
     : Process(target, listener),
+      m_byte_order(lldb::endian::InlHostByteOrder()),
       m_monitor(NULL),
       m_module(NULL),
       m_in_limbo(false),
@@ -73,8 +74,9 @@
 {
     // FIXME: Putting this code in the ctor and saving the byte order in a
     // member variable is a hack to avoid const qual issues in GetByteOrder.
-    ObjectFile *obj_file = GetTarget().GetExecutableModule()->GetObjectFile();
-    m_byte_order = obj_file->GetByteOrder();
+	lldb::ModuleSP module = GetTarget().GetExecutableModule();
+	if (module != NULL && module->GetObjectFile() != NULL)
+		m_byte_order = module->GetObjectFile()->GetByteOrder();
 }
 
 ProcessPOSIX::~ProcessPOSIX()

Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=154724&r1=154723&r2=154724&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Fri Apr 13 19:54:42 2012
@@ -63,6 +63,7 @@
 #endif
 
 #if defined (__FreeBSD__)
+#include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
 #include "Plugins/Process/POSIX/ProcessPOSIX.h"
 #include "Plugins/Process/FreeBSD/ProcessFreeBSD.h"
 #endif
@@ -133,6 +134,7 @@
 #endif
 #if defined (__FreeBSD__)
         ProcessFreeBSD::Initialize();
+        ProcessGDBRemote::Initialize();
 #endif
         //----------------------------------------------------------------------
         // Platform agnostic plugins
@@ -207,6 +209,7 @@
 
 #if defined (__FreeBSD__)
     ProcessFreeBSD::Terminate();
+    ProcessGDBRemote::Terminate();
 #endif
     
     DynamicLoaderStatic::Terminate();





More information about the lldb-commits mailing list