[Lldb-commits] [lldb] r154599 - in /lldb/branches/lldb-platform-work: lib/Makefile source/Commands/CommandObjectPlatform.cpp source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp source/Plugins/Platform/Makefile source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp source/Plugins/Process/FreeBSD/ProcessFreeBSD.h source/Plugins/Process/POSIX/ProcessPOSIX.cpp source/Plugins/Process/POSIX/ProcessPOSIX.h source/lldb.cpp

Enrico Granata egranata at apple.com
Thu Apr 12 11:23:01 PDT 2012


Author: enrico
Date: Thu Apr 12 13:23:01 2012
New Revision: 154599

URL: http://llvm.org/viewvc/llvm-project?rev=154599&view=rev
Log:
Patch by Viktor Kutuzov <vkutuzov at accesssoftek.com> to make the platform-work branch more FreeBSD-friendly

Modified:
    lldb/branches/lldb-platform-work/lib/Makefile
    lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Platform/Makefile
    lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
    lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
    lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.h
    lldb/branches/lldb-platform-work/source/lldb.cpp

Modified: lldb/branches/lldb-platform-work/lib/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/lib/Makefile?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/lib/Makefile (original)
+++ lldb/branches/lldb-platform-work/lib/Makefile Thu Apr 12 13:23:01 2012
@@ -65,7 +65,8 @@
 	LLVMMCDisassembler.a \
 	lldbPluginPlatformMacOSX.a \
 	lldbPluginPlatformLinux.a \
-	lldbPluginPlatformFreeBSD.a
+	lldbPluginPlatformFreeBSD.a \
+	lldbPluginPlatformPOSIX.a
 
 include $(LLDB_LEVEL)/../../Makefile.config
 

Modified: lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Commands/CommandObjectPlatform.cpp Thu Apr 12 13:23:01 2012
@@ -1493,6 +1493,44 @@
     DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatformProcess);
 };
 
+//----------------------------------------------------------------------
+// "platform install" - install a target to a remote end
+//----------------------------------------------------------------------
+class CommandObjectPlatformInstall : public CommandObject
+{
+public:
+    CommandObjectPlatformInstall (CommandInterpreter &interpreter) :
+    CommandObject (interpreter,
+                   "platform target-install",
+                   "Install a target (bundle or executable file) to the remote end.",
+                   "platform target-install <local-thing> <remote-sandbox>",
+                   0)
+    {
+    }
+    
+    virtual
+    ~CommandObjectPlatformInstall ()
+    {
+    }
+    
+    virtual bool
+    Execute (Args& args, CommandReturnObject &result)
+    {
+        if (args.GetArgumentCount() != 2)
+        {
+            result.AppendError("platform target-install takes two arguments");
+            result.SetStatus(eReturnStatusFailed);
+            return false;
+        }
+        std::string local_thing(args.GetArgumentAtIndex(0));
+        std::string remote_sandbox(args.GetArgumentAtIndex(1));
+        result.AppendWarningWithFormat("error in installing %s into %s", local_thing.c_str(), remote_sandbox.c_str());
+        result.AppendError("platform target-install is unimplemented - use put-file and mkdir as required");
+        result.SetStatus(eReturnStatusFailed);
+        return false;
+    }
+};
+
 class CommandObjectPlatformFile : public CommandObjectMultiword
 {
 public:
@@ -1509,7 +1547,6 @@
         LoadSubCommand ("close", CommandObjectSP (new CommandObjectPlatformFClose  (interpreter)));
         LoadSubCommand ("read", CommandObjectSP (new CommandObjectPlatformFRead  (interpreter)));
         LoadSubCommand ("write", CommandObjectSP (new CommandObjectPlatformFWrite  (interpreter)));
-        
     }
     
     virtual
@@ -1539,6 +1576,7 @@
     LoadSubCommand ("connect", CommandObjectSP (new CommandObjectPlatformConnect  (interpreter)));
     LoadSubCommand ("disconnect", CommandObjectSP (new CommandObjectPlatformDisconnect  (interpreter)));
     LoadSubCommand ("process", CommandObjectSP (new CommandObjectPlatformProcess  (interpreter)));
+    LoadSubCommand ("target-install", CommandObjectSP (new CommandObjectPlatformInstall  (interpreter)));
 #ifdef LLDB_CONFIGURATION_DEBUG
     LoadSubCommand ("shell", CommandObjectSP (new CommandObjectPlatformShell  (interpreter)));
     LoadSubCommand ("mkdir", CommandObjectSP (new CommandObjectPlatformMkDir  (interpreter)));

Modified: lldb/branches/lldb-platform-work/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp Thu Apr 12 13:23:01 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/branches/lldb-platform-work/source/Plugins/Platform/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Platform/Makefile?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Platform/Makefile (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Platform/Makefile Thu Apr 12 13:23:01 2012
@@ -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

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp Thu Apr 12 13:23:01 2012
@@ -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
 }

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/FreeBSD/ProcessFreeBSD.h Thu Apr 12 13:23:01 2012
@@ -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);
 
     //------------------------------------------------------------------

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.cpp?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.cpp (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.cpp Thu Apr 12 13:23:01 2012
@@ -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

Modified: lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.h?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.h (original)
+++ lldb/branches/lldb-platform-work/source/Plugins/Process/POSIX/ProcessPOSIX.h Thu Apr 12 13:23:01 2012
@@ -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

Modified: lldb/branches/lldb-platform-work/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/source/lldb.cpp?rev=154599&r1=154598&r2=154599&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/source/lldb.cpp (original)
+++ lldb/branches/lldb-platform-work/source/lldb.cpp Thu Apr 12 13:23:01 2012
@@ -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"





More information about the lldb-commits mailing list