[Lldb-commits] [lldb] r127934 - in /lldb/trunk: include/lldb/ include/lldb/Core/ include/lldb/Host/ include/lldb/Interpreter/ include/lldb/Symbol/ include/lldb/Target/ lldb.xcodeproj/ source/ source/Breakpoint/ source/Commands/ source/Core/ source/Host/macosx/ source/Interpreter/ source/Plugins/Disassembler/llvm/ source/Plugins/ObjectFile/Mach-O/ source/Plugins/Platform/MacOSX/ source/Plugins/Process/MacOSX-User/source/ source/Plugins/Process/gdb-remote/ source/Symbol/ source/Target/

Greg Clayton gclayton at apple.com
Fri Mar 18 18:12:22 PDT 2011


Author: gclayton
Date: Fri Mar 18 20:12:21 2011
New Revision: 127934

URL: http://llvm.org/viewvc/llvm-project?rev=127934&view=rev
Log:
Added more platform support. There are now some new commands:

platform status -- gets status information for the selected platform
platform create <platform-name> -- creates a new instance of a remote platform
platform list -- list all available platforms
platform select -- select a platform instance as the current platform (not working yet)

When using "platform create" it will create a remote platform and make it the
selected platform. For instances for iPhone OS debugging on Mac OS X one can 
do:

(lldb) platform create remote-ios --sdk-version=4.0
Remote platform: iOS platform
SDK version: 4.0
SDK path: "/Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0"
Not connected to a remote device.
(lldb) file ~/Documents/a.out
Current executable set to '~/Documents/a.out' (armv6).
(lldb) image list
[  0] /Volumes/work/gclayton/Documents/devb/attach/a.out
[  1] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/dyld
[  2] /Developer/Platforms/iPhoneOS.platform/DeviceSupport/4.0/Symbols/usr/lib/libSystem.B.dylib


Note that this is all happening prior to running _or_ connecting to a remote
platform. Once connected to a remote platform the OS version might change which
means we will need to update our dependecies. Also once we run, we will need
to match up the actualy binaries with the actualy UUID's to files in the
SDK, or download and cache them locally.

This is just the start of the remote platforms, but this modification is the
first iteration in getting the platforms really doing something.



Added:
    lldb/trunk/source/Commands/CommandObjectPlatform.cpp
    lldb/trunk/source/Commands/CommandObjectPlatform.h
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
Modified:
    lldb/trunk/include/lldb/Core/Address.h
    lldb/trunk/include/lldb/Core/ArchSpec.h
    lldb/trunk/include/lldb/Core/Debugger.h
    lldb/trunk/include/lldb/Host/Host.h
    lldb/trunk/include/lldb/Interpreter/Args.h
    lldb/trunk/include/lldb/Symbol/ObjectFile.h
    lldb/trunk/include/lldb/Target/Platform.h
    lldb/trunk/include/lldb/Target/Process.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/include/lldb/lldb-enumerations.h
    lldb/trunk/include/lldb/lldb-forward.h
    lldb/trunk/lldb.xcodeproj/project.pbxproj
    lldb/trunk/source/Breakpoint/Breakpoint.cpp
    lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp
    lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp
    lldb/trunk/source/Commands/CommandObjectFrame.cpp
    lldb/trunk/source/Commands/CommandObjectProcess.cpp
    lldb/trunk/source/Core/Address.cpp
    lldb/trunk/source/Core/ArchSpec.cpp
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/PluginManager.cpp
    lldb/trunk/source/Host/macosx/Host.mm
    lldb/trunk/source/Interpreter/Args.cpp
    lldb/trunk/source/Interpreter/CommandInterpreter.cpp
    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
    lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
    lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
    lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
    lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
    lldb/trunk/source/Symbol/ObjectFile.cpp
    lldb/trunk/source/Target/Platform.cpp
    lldb/trunk/source/Target/Process.cpp
    lldb/trunk/source/Target/Target.cpp
    lldb/trunk/source/Target/TargetList.cpp
    lldb/trunk/source/lldb.cpp

Modified: lldb/trunk/include/lldb/Core/Address.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Address.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Address.h (original)
+++ lldb/trunk/include/lldb/Core/Address.h Fri Mar 18 20:12:21 2011
@@ -246,6 +246,9 @@
           DumpStyle fallback_style = DumpStyleInvalid,
           uint32_t addr_byte_size = UINT32_MAX) const;
 
+    lldb::AddressClass
+    GetAddressClass () const;
+    
     //------------------------------------------------------------------
     /// Get the file address.
     ///

Modified: lldb/trunk/include/lldb/Core/ArchSpec.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ArchSpec.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ArchSpec.h (original)
+++ lldb/trunk/include/lldb/Core/ArchSpec.h Fri Mar 18 20:12:21 2011
@@ -43,6 +43,9 @@
         eCore_arm_armv5t,
         eCore_arm_armv6,
         eCore_arm_armv7,
+        eCore_arm_armv7f,
+        eCore_arm_armv7k,
+        eCore_arm_armv7s,
         eCore_arm_xscale,        
         
         eCore_ppc_generic,

Modified: lldb/trunk/include/lldb/Core/Debugger.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/Debugger.h (original)
+++ lldb/trunk/include/lldb/Core/Debugger.h Fri Mar 18 20:12:21 2011
@@ -24,6 +24,7 @@
 #include "lldb/Core/UserID.h"
 #include "lldb/Core/UserSettingsController.h"
 #include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Platform.h"
 #include "lldb/Target/TargetList.h"
 
 namespace lldb_private {
@@ -320,16 +321,29 @@
     }
 
     CommandInterpreter &
-    GetCommandInterpreter ();
+    GetCommandInterpreter ()
+    {
+        assert (m_command_interpreter_ap.get());
+        return *m_command_interpreter_ap;
+    }
 
     Listener &
-    GetListener ();
+    GetListener ()
+    {
+        return m_listener;
+    }
 
     SourceManager &
-    GetSourceManager ();
+    GetSourceManager ()
+    {
+        return m_source_manager;
+    }
 
     lldb::TargetSP
-    GetSelectedTarget ();
+    GetSelectedTarget ()
+    {
+        return m_target_list.GetSelectedTarget ();
+    }
 
     ExecutionContext
     GetSelectedExecutionContext();
@@ -344,8 +358,17 @@
     /// @return
     ///     A global shared target list.
     //------------------------------------------------------------------
-    TargetList&
-    GetTargetList ();
+    TargetList &
+    GetTargetList ()
+    {
+        return m_target_list;
+    }
+
+    PlatformList &
+    GetPlatformList ()
+    {
+        return m_platform_list;
+    }
 
     void
     DispatchInputInterrupt ();
@@ -410,13 +433,17 @@
     CheckIfTopInputReaderIsDone ();
     
     void
-    DisconnectInput();
+    DisconnectInput()
+    {
+        m_input_comm.Clear ();
+    }
 
     Communication m_input_comm;
     StreamFile m_input_file;
     StreamFile m_output_file;
     StreamFile m_error_file;
     TargetList m_target_list;
+    PlatformList m_platform_list;
     Listener m_listener;
     SourceManager m_source_manager;
     std::auto_ptr<CommandInterpreter> m_command_interpreter_ap;

Modified: lldb/trunk/include/lldb/Host/Host.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Host/Host.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Host/Host.h (original)
+++ lldb/trunk/include/lldb/Host/Host.h Fri Mar 18 20:12:21 2011
@@ -96,6 +96,11 @@
     static lldb::ByteOrder
     GetByteOrder ();
 
+    static bool
+    GetOSVersion (uint32_t &major, 
+                  uint32_t &minor, 
+                  uint32_t &update);
+
     //------------------------------------------------------------------
     /// Gets the host architecture.
     ///

Modified: lldb/trunk/include/lldb/Interpreter/Args.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Args.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/Args.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Args.h Fri Mar 18 20:12:21 2011
@@ -357,6 +357,9 @@
     static Error
     StringToFormat (const char *s, lldb::Format &format);
 
+    static const char *
+    StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t &update);
+
     // This one isn't really relevant to Arguments per se, but we're using the Args as a
     // general strings container, so...
     void

Modified: lldb/trunk/include/lldb/Symbol/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ObjectFile.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ObjectFile.h (original)
+++ lldb/trunk/include/lldb/Symbol/ObjectFile.h Fri Mar 18 20:12:21 2011
@@ -143,6 +143,23 @@
     GetAddressByteSize ()  const = 0;
 
     //------------------------------------------------------------------
+    /// Get the address type given a file address in an object file.
+    ///
+    /// Many binary file formats know what kinds
+    /// This is primarily for ARM binaries, though it can be applied to
+    /// any executable file format that supports different opcode types
+    /// within the same binary. ARM binaries support having both ARM and
+    /// Thumb within the same executable container. We need to be able
+    /// to get
+    /// @return
+    ///     The size of an address in bytes for the currently selected
+    ///     architecture (and object for archives). Returns zero if no
+    ///     architecture or object has been selected.
+    //------------------------------------------------------------------
+    virtual lldb::AddressClass
+    GetAddressClass (lldb::addr_t file_addr);
+
+    //------------------------------------------------------------------
     /// Extract the dependent modules from an object file.
     ///
     /// If an object file has information about which other images it

Modified: lldb/trunk/include/lldb/Target/Platform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Platform.h (original)
+++ lldb/trunk/include/lldb/Target/Platform.h Fri Mar 18 20:12:21 2011
@@ -58,44 +58,19 @@
         static void
         SetDefaultPlatform (const lldb::PlatformSP &platform_sp);
 
-        //------------------------------------------------------------------
-        /// Select the active platform.
-        ///
-        /// In order to debug remotely, other platform's can be remotely
-        /// connected to and set as the selected platform for any subsequent
-        /// debugging. This allows connection to remote targets and allows
-        /// the ability to discover process info, launch and attach to remote
-        /// processes.
-        //------------------------------------------------------------------
-        static lldb::PlatformSP
-        GetSelectedPlatform ();
-
-        static void
-        SetSelectedPlatform (const lldb::PlatformSP &platform_sp);
-
-        //------------------------------------------------------------------
-        /// Connect to a remote platform
-        ///
-        /// When connecting to a remote platform, the name of that platform
-        /// (the short plug-in name) is required, along with a URL that the
-        /// platform plug-in can use to remotely attach.
-        //------------------------------------------------------------------
         static lldb::PlatformSP
-        ConnectRemote (const char *platform_name, 
-                       const char *remote_connect_url, 
-                       Error &error);
+        Create (const char *platform_name, Error &error);
 
         static uint32_t
         GetNumConnectedRemotePlatforms ();
         
         static lldb::PlatformSP
         GetConnectedRemotePlatformAtIndex (uint32_t idx);
-        
 
         //------------------------------------------------------------------
         /// Default Constructor
         //------------------------------------------------------------------
-        Platform ();
+        Platform (bool is_host_platform);
 
         //------------------------------------------------------------------
         /// Destructor.
@@ -130,6 +105,44 @@
                            const ArchSpec &arch,
                            lldb::ModuleSP &module_sp);
 
+        bool
+        GetOSVersion (uint32_t &major, 
+                      uint32_t &minor, 
+                      uint32_t &update);
+           
+        bool
+        SetOSVersion (uint32_t major, 
+                      uint32_t minor, 
+                      uint32_t update);
+
+        virtual const char *
+        GetDescription () = 0;
+
+        //------------------------------------------------------------------
+        /// Report the current status for this platform. 
+        ///
+        /// The returned string usually involves returning the OS version
+        /// (if available), and any SDK directory that might be being used
+        /// for local file caching, and if connected a quick blurb about
+        /// what this platform is connected to.
+        //------------------------------------------------------------------        
+        virtual void
+        GetStatus (Stream &strm) = 0;
+
+        //------------------------------------------------------------------
+        // Subclasses must be able to fetch the current OS version
+        //
+        // Remote classes must be connected for this to succeed. Local 
+        // subclasses don't need to override this function as it will just
+        // call the Host::GetOSVersion().
+        //------------------------------------------------------------------
+protected:
+        virtual bool
+        FetchRemoteOSVersion ()
+        {
+            return false;
+        }
+        
         //------------------------------------------------------------------
         /// Locate a file for a platform.
         ///
@@ -149,6 +162,7 @@
         /// @return
         ///     An error object.
         //------------------------------------------------------------------
+public:
         virtual Error
         GetFile (const FileSpec &platform_file, FileSpec &local_file);
 
@@ -176,6 +190,10 @@
         virtual bool
         GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) = 0;
 
+        virtual size_t
+        GetSoftwareBreakpointTrapOpcode (Target &target,
+                                         BreakpointSite *bp_site) = 0;
+
         //------------------------------------------------------------------
         /// Launch a new process.
         ///
@@ -291,10 +309,57 @@
             return m_remote_url;
         }
 
-    protected:
+        bool
+        IsHost () const
+        {
+            return m_is_host;    // Is this the default host platform?
+        }
+
+        bool
+        IsRemote () const
+        {
+            return !m_is_host;
+        }
         
-        std::string m_remote_url;
+        bool
+        IsConnected () const
+        {
+            return m_is_connected;
+        }
         
+        const ArchSpec &
+        GetSystemArchitecture();
+
+        void
+        SetSystemArchitecture (const ArchSpec &arch)
+        {
+            m_system_arch = arch;
+            if (IsHost())
+                m_os_version_set_while_connected = m_system_arch.IsValid();
+        }
+
+        // Remote Platform subclasses need to override this function
+        virtual ArchSpec
+        FetchRemoteSystemArchitecture ()
+        {
+            return ArchSpec(); // Return an invalid architecture
+        }
+
+    protected:
+        bool m_is_host;
+        bool m_is_connected;
+        // Set to true when we are able to actually set the OS version while 
+        // being connected. For remote platforms, we might set the version ahead
+        // of time before we actually connect and this version might change when
+        // we actually connect to a remote platform. For the host platform this
+        // will be set to the once we call Host::GetOSVersion().
+        bool m_os_version_set_while_connected;
+        bool m_system_arch_set_while_connected;
+        std::string m_remote_url;
+        uint32_t m_major_os_version;
+        uint32_t m_minor_os_version;
+        uint32_t m_update_os_version;
+        ArchSpec m_system_arch; // The architecture of the kernel or the remote platform
     private:
         DISALLOW_COPY_AND_ASSIGN (Platform);
     };
@@ -314,10 +379,12 @@
         }
         
         void
-        Append (const lldb::PlatformSP &platform_sp)
+        Append (const lldb::PlatformSP &platform_sp, bool set_selected)
         {
             Mutex::Locker locker (m_mutex);
             m_platforms.push_back (platform_sp);
+            if (set_selected)
+                m_selected_platform_sp = m_platforms.back();
         }
 
         size_t
@@ -339,10 +406,50 @@
             return platform_sp;
         }
 
+        //------------------------------------------------------------------
+        /// Select the active platform.
+        ///
+        /// In order to debug remotely, other platform's can be remotely
+        /// connected to and set as the selected platform for any subsequent
+        /// debugging. This allows connection to remote targets and allows
+        /// the ability to discover process info, launch and attach to remote
+        /// processes.
+        //------------------------------------------------------------------
+        lldb::PlatformSP
+        GetSelectedPlatform ()
+        {
+            Mutex::Locker locker (m_mutex);
+            if (!m_selected_platform_sp && !m_platforms.empty())
+                m_selected_platform_sp = m_platforms.front();
+            
+            return m_selected_platform_sp;
+        }
+
+        void
+        SetSelectedPlatform (const lldb::PlatformSP &platform_sp)
+        {
+            if (platform_sp)
+            {
+                Mutex::Locker locker (m_mutex);
+                const size_t num_platforms = m_platforms.size();
+                for (size_t idx=0; idx<num_platforms; ++idx)
+                {
+                    if (m_platforms[idx].get() == platform_sp.get())
+                    {
+                        m_selected_platform_sp = m_platforms[idx];
+                        return;
+                    }
+                }
+                m_platforms.push_back (platform_sp);
+                m_selected_platform_sp = m_platforms.back();
+            }
+        }
+
     protected:
         typedef std::vector<lldb::PlatformSP> collection;
         mutable Mutex m_mutex;
         collection m_platforms;
+        lldb::PlatformSP m_selected_platform_sp;
 
     private:
         DISALLOW_COPY_AND_ASSIGN (PlatformList);

Modified: lldb/trunk/include/lldb/Target/Process.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Process.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Process.h (original)
+++ lldb/trunk/include/lldb/Target/Process.h Fri Mar 18 20:12:21 2011
@@ -1726,8 +1726,8 @@
     //----------------------------------------------------------------------
     // Process Breakpoints
     //----------------------------------------------------------------------
-    virtual size_t
-    GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site) = 0;
+    size_t
+    GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site);
 
     virtual Error
     EnableBreakpoint (BreakpointSite *bp_site) = 0;

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Fri Mar 18 20:12:21 2011
@@ -101,7 +101,6 @@
         m_execution_os_type = execution_os_type;
     }
     
-
 protected:
 
     void
@@ -175,7 +174,7 @@
     ///
     /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*)
     //------------------------------------------------------------------
-    Target(Debugger &debugger);
+    Target(Debugger &debugger, const lldb::PlatformSP &platform_sp);
 
 public:
     ~Target();
@@ -641,6 +640,12 @@
         return (*pos).second;
     }
     
+    lldb::PlatformSP
+    GetPlatform ()
+    {
+        return m_platform_sp;
+    }
+
     //------------------------------------------------------------------
     // Target::SettingsController
     //------------------------------------------------------------------
@@ -694,6 +699,7 @@
     // Member variables.
     //------------------------------------------------------------------
     Debugger &      m_debugger;
+    lldb::PlatformSP m_platform_sp;     ///< The platform for this target.
     Mutex           m_mutex;            ///< An API mutex that is used by the lldb::SB* classes make the SB interface thread safe
     ArchSpec        m_arch_spec;
     ModuleList      m_images;           ///< The list of images for this process (shared libraries and anything dynamically loaded).

Modified: lldb/trunk/include/lldb/lldb-enumerations.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-enumerations.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-enumerations.h (original)
+++ lldb/trunk/include/lldb/lldb-enumerations.h Fri Mar 18 20:12:21 2011
@@ -77,6 +77,21 @@
     eAddressTypeHost  ///< Address is an address in the process that is running this code
 } AddressType;
 
+    //----------------------------------------------------------------------
+    // Address Types
+    //----------------------------------------------------------------------
+typedef enum AddressClass
+{
+    eAddressClassInvalid,
+    eAddressClassUnknown,
+    eAddressClassCode,
+    eAddressClassCodeAlternateISA,
+    eAddressClassData,
+    eAddressClassDataConst,
+    eAddressClassDebug,
+    eAddressClassRuntime
+} AddressClass;
+
 //----------------------------------------------------------------------
 // Byte ordering definitions
 //----------------------------------------------------------------------

Modified: lldb/trunk/include/lldb/lldb-forward.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/lldb-forward.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/include/lldb/lldb-forward.h (original)
+++ lldb/trunk/include/lldb/lldb-forward.h Fri Mar 18 20:12:21 2011
@@ -65,7 +65,6 @@
 class   DataBuffer;
 class   DataExtractor;
 class   Debugger;
-class   Debugger;
 class   Declaration;
 class   Disassembler;
 class   DynamicLoader;

Modified: lldb/trunk/lldb.xcodeproj/project.pbxproj
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/lldb.xcodeproj/project.pbxproj?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/lldb.xcodeproj/project.pbxproj (original)
+++ lldb/trunk/lldb.xcodeproj/project.pbxproj Fri Mar 18 20:12:21 2011
@@ -80,6 +80,10 @@
 		266A42D6128E3FFB0090CF7C /* ClangNamespaceDecl.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266A42D5128E3FFB0090CF7C /* ClangNamespaceDecl.cpp */; };
 		266A42D8128E40040090CF7C /* ClangNamespaceDecl.h in Headers */ = {isa = PBXBuildFile; fileRef = 266A42D7128E40040090CF7C /* ClangNamespaceDecl.h */; };
 		266F5CBC12FC846200DFCE33 /* Config.h in Headers */ = {isa = PBXBuildFile; fileRef = 266F5CBB12FC846200DFCE33 /* Config.h */; };
+		2675F7001332BE690067997B /* PlatformRemoteiOS.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2675F6FE1332BE690067997B /* PlatformRemoteiOS.cpp */; };
+		2675F7011332BE690067997B /* PlatformRemoteiOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 2675F6FF1332BE690067997B /* PlatformRemoteiOS.h */; };
+		26879CE61333F5750012C1F8 /* CommandObjectPlatform.h in Headers */ = {isa = PBXBuildFile; fileRef = 26879CE51333F5750012C1F8 /* CommandObjectPlatform.h */; };
+		26879CE81333F58B0012C1F8 /* CommandObjectPlatform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26879CE71333F58B0012C1F8 /* CommandObjectPlatform.cpp */; };
 		268A683F1321B53B000E3FB8 /* DynamicLoaderStatic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 268A683D1321B53B000E3FB8 /* DynamicLoaderStatic.cpp */; };
 		268A68401321B53B000E3FB8 /* DynamicLoaderStatic.h in Headers */ = {isa = PBXBuildFile; fileRef = 268A683E1321B53B000E3FB8 /* DynamicLoaderStatic.h */; };
 		268DA872130095D000C9483A /* Terminal.h in Headers */ = {isa = PBXBuildFile; fileRef = 268DA871130095D000C9483A /* Terminal.h */; };
@@ -611,12 +615,16 @@
 		266F5CBB12FC846200DFCE33 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Config.h; path = include/lldb/Host/Config.h; sourceTree = "<group>"; };
 		2672D8461189055500FF4019 /* CommandObjectFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectFrame.cpp; path = source/Commands/CommandObjectFrame.cpp; sourceTree = "<group>"; };
 		2672D8471189055500FF4019 /* CommandObjectFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectFrame.h; path = source/Commands/CommandObjectFrame.h; sourceTree = "<group>"; };
+		2675F6FE1332BE690067997B /* PlatformRemoteiOS.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformRemoteiOS.cpp; sourceTree = "<group>"; };
+		2675F6FF1332BE690067997B /* PlatformRemoteiOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformRemoteiOS.h; sourceTree = "<group>"; };
 		2676A093119C93C8008A98EF /* StringExtractorGDBRemote.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StringExtractorGDBRemote.cpp; path = source/Utility/StringExtractorGDBRemote.cpp; sourceTree = "<group>"; };
 		2676A094119C93C8008A98EF /* StringExtractorGDBRemote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = StringExtractorGDBRemote.h; path = source/Utility/StringExtractorGDBRemote.h; sourceTree = "<group>"; };
 		2682F16A115EDA0D00CCFF99 /* PseudoTerminal.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PseudoTerminal.cpp; path = source/Utility/PseudoTerminal.cpp; sourceTree = "<group>"; };
 		2682F16B115EDA0D00CCFF99 /* PseudoTerminal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PseudoTerminal.h; path = include/lldb/Utility/PseudoTerminal.h; sourceTree = "<group>"; };
 		2682F284115EF3A700CCFF99 /* SBError.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = SBError.cpp; path = source/API/SBError.cpp; sourceTree = "<group>"; };
 		2682F286115EF3BD00CCFF99 /* SBError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SBError.h; path = include/lldb/API/SBError.h; sourceTree = "<group>"; };
+		26879CE51333F5750012C1F8 /* CommandObjectPlatform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CommandObjectPlatform.h; path = source/Commands/CommandObjectPlatform.h; sourceTree = "<group>"; };
+		26879CE71333F58B0012C1F8 /* CommandObjectPlatform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommandObjectPlatform.cpp; path = source/Commands/CommandObjectPlatform.cpp; sourceTree = "<group>"; };
 		2689B0A4113EE3CD00A4AEDB /* Symbols.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Symbols.h; path = include/lldb/Host/Symbols.h; sourceTree = "<group>"; };
 		2689B0B5113EE47E00A4AEDB /* Symbols.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Symbols.cpp; path = source/Host/macosx/Symbols.cpp; sourceTree = "<group>"; };
 		268A683D1321B53B000E3FB8 /* DynamicLoaderStatic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DynamicLoaderStatic.cpp; sourceTree = "<group>"; };
@@ -1935,6 +1943,8 @@
 				264AD83711095BA600E0B039 /* CommandObjectLog.cpp */,
 				26BC7D1D10F1B76300F91463 /* CommandObjectMemory.h */,
 				26BC7E3610F1B84700F91463 /* CommandObjectMemory.cpp */,
+				26879CE51333F5750012C1F8 /* CommandObjectPlatform.h */,
+				26879CE71333F58B0012C1F8 /* CommandObjectPlatform.cpp */,
 				26BC7D1F10F1B76300F91463 /* CommandObjectProcess.h */,
 				26BC7E3810F1B84700F91463 /* CommandObjectProcess.cpp */,
 				26BC7D2010F1B76300F91463 /* CommandObjectQuit.h */,
@@ -2169,6 +2179,8 @@
 			children = (
 				26C5577B132575AD008FD8FE /* PlatformMacOSX.cpp */,
 				26C5577C132575AD008FD8FE /* PlatformMacOSX.h */,
+				2675F6FE1332BE690067997B /* PlatformRemoteiOS.cpp */,
+				2675F6FF1332BE690067997B /* PlatformRemoteiOS.h */,
 			);
 			path = MacOSX;
 			sourceTree = "<group>";
@@ -2415,6 +2427,8 @@
 				264A43BC1320B3B4005B4096 /* Platform.h in Headers */,
 				268A68401321B53B000E3FB8 /* DynamicLoaderStatic.h in Headers */,
 				26C557811325781D008FD8FE /* PlatformMacOSX.h in Headers */,
+				2675F7011332BE690067997B /* PlatformRemoteiOS.h in Headers */,
+				26879CE61333F5750012C1F8 /* CommandObjectPlatform.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2924,6 +2938,8 @@
 				264A43BE1320BCEB005B4096 /* Platform.cpp in Sources */,
 				268A683F1321B53B000E3FB8 /* DynamicLoaderStatic.cpp in Sources */,
 				26C557801325781A008FD8FE /* PlatformMacOSX.cpp in Sources */,
+				2675F7001332BE690067997B /* PlatformRemoteiOS.cpp in Sources */,
+				26879CE81333F58B0012C1F8 /* CommandObjectPlatform.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -3104,7 +3120,7 @@
 					"$(LLVM_BUILD_DIR)",
 				);
 				LLVM_BUILD_DIR = "$(SRCROOT)/llvm";
-				LLVM_CONFIGURATION = Release;
+				LLVM_CONFIGURATION = "Debug+Asserts";
 				OTHER_CFLAGS = (
 					"-DFOR_DYLD=0",
 					"-DSUPPORT_REMOTE_UNWINDING",
@@ -3161,7 +3177,7 @@
 					"$(LLVM_BUILD_DIR)",
 				);
 				LLVM_BUILD_DIR = "$(SRCROOT)/llvm";
-				LLVM_CONFIGURATION = Release;
+				LLVM_CONFIGURATION = "Debug+Asserts";
 				OTHER_CFLAGS = (
 					"-DFOR_DYLD=0",
 					"-DSUPPORT_REMOTE_UNWINDING",
@@ -3284,7 +3300,7 @@
 					"$(LLVM_BUILD_DIR)",
 				);
 				LLVM_BUILD_DIR = "$(DERIVED_FILE_DIR)/llvm.build";
-				LLVM_CONFIGURATION = Release;
+				LLVM_CONFIGURATION = "Debug+Asserts";
 				OTHER_CFLAGS = (
 					"-DFOR_DYLD=0",
 					"-DSUPPORT_REMOTE_UNWINDING",

Modified: lldb/trunk/source/Breakpoint/Breakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/Breakpoint.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/Breakpoint.cpp (original)
+++ lldb/trunk/source/Breakpoint/Breakpoint.cpp Fri Mar 18 20:12:21 2011
@@ -412,7 +412,7 @@
         // Verbose mode does a debug dump of the breakpoint
         Dump (s);
         s->EOL ();
-        s->Indent();
+            //s->Indent();
         GetOptions()->GetDescription(s, level);
         break;
 

Modified: lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocationList.cpp Fri Mar 18 20:12:21 2011
@@ -133,7 +133,7 @@
 BreakpointLocationList::Dump (Stream *s) const
 {
     s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
-    s->Indent();
+    //s->Indent();
     Mutex::Locker locker (m_mutex);
     s->Printf("BreakpointLocationList with %zu BreakpointLocations:\n", m_locations.size());
     s->IndentMore();

Modified: lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointSiteList.cpp Fri Mar 18 20:12:21 2011
@@ -168,7 +168,7 @@
 BreakpointSiteList::Dump (Stream *s) const
 {
     s->Printf("%.*p: ", (int)sizeof(void*) * 2, this);
-    s->Indent();
+    //s->Indent();
     s->Printf("BreakpointSiteList with %u BreakpointSites:\n", (uint32_t)m_bp_site_list.size());
     s->IndentMore();
     collection::const_iterator pos;

Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Fri Mar 18 20:12:21 2011
@@ -319,7 +319,8 @@
             case 'L':   show_location= true;  break;
             case 'c':   show_decl    = true;  break;
             case 'D':   debug        = true;  break;
-            case 'f':   flat_output  = true;  break;
+            case 'f':   error = Args::StringToFormat(option_arg, format); break;
+            case 'F':   flat_output  = true;  break;
             case 'd':
                 max_depth = Args::StringToUInt32 (option_arg, UINT32_MAX, 0, &success);
                 if (!success)
@@ -367,6 +368,7 @@
             flat_output   = false;
             max_depth     = UINT32_MAX;
             ptr_depth     = 0;
+            format        = eFormatDefault;
             globals.clear();
         }
 
@@ -393,6 +395,7 @@
              flat_output:1;
         uint32_t max_depth; // The depth to print when dumping concrete (not pointers) aggreate values
         uint32_t ptr_depth; // The default depth that is dumped when we find pointers
+        lldb::Format format; // The format to use when dumping variables or children of variables
         std::vector<ConstString> globals;
         // Instance variables to hold the values for command options.
     };
@@ -491,6 +494,9 @@
 
                                     if (valobj_sp)
                                     {
+                                        if (m_options.format != eFormatDefault)
+                                            valobj_sp->SetFormat (m_options.format);
+
                                         if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
                                         {
                                             var_sp->GetDeclaration ().DumpStopContext (&s, false);
@@ -550,6 +556,9 @@
                                             valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp);
                                             if (valobj_sp)
                                             {
+                                                if (m_options.format != eFormatDefault)
+                                                    valobj_sp->SetFormat (m_options.format);
+                                                
                                                 if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
                                                 {
                                                     var_sp->GetDeclaration ().DumpStopContext (&s, false);
@@ -593,6 +602,9 @@
                             valobj_sp = exe_ctx.frame->GetValueForVariableExpressionPath (name_cstr, expr_path_options, error);
                             if (valobj_sp)
                             {
+                                if (m_options.format != eFormatDefault)
+                                    valobj_sp->SetFormat (m_options.format);
+                                
                                 if (m_options.show_decl && var_sp->GetDeclaration ().GetFile())
                                 {
                                     var_sp->GetDeclaration ().DumpStopContext (&s, false);
@@ -672,6 +684,9 @@
                                 valobj_sp = exe_ctx.frame->GetValueObjectForFrameVariable (var_sp);
                                 if (valobj_sp)
                                 {
+                                    if (m_options.format != eFormatDefault)
+                                        valobj_sp->SetFormat (m_options.format);
+                                    
                                     // When dumping all variables, don't print any variables
                                     // that are not in scope to avoid extra unneeded output
                                     if (valobj_sp->IsInScope (exe_ctx.frame))
@@ -726,7 +741,8 @@
 { LLDB_OPT_SET_1, false, "objc",       'o', no_argument,       NULL, 0, eArgTypeNone,    "When looking up a variable by name, print as an Objective-C object."},
 { LLDB_OPT_SET_1, false, "ptr-depth",  'p', required_argument, NULL, 0, eArgTypeCount,   "The number of pointers to be traversed when dumping values (default is zero)."},
 { LLDB_OPT_SET_1, false, "regex",      'r', no_argument,       NULL, 0, eArgTypeRegularExpression,    "The <variable-name> argument for name lookups are regular expressions."},
-{ LLDB_OPT_SET_1, false, "flat",       'f', no_argument,       NULL, 0, eArgTypeNone,    "Display results in a flat format that uses expression paths for each variable or member."},
+{ LLDB_OPT_SET_1, false, "flat",       'F', no_argument,       NULL, 0, eArgTypeNone,    "Display results in a flat format that uses expression paths for each variable or member."},
+{ LLDB_OPT_SET_1, false, "format",     'f', required_argument, NULL, 0, eArgTypeExprFormat,  "Specify the format that the variable output should use."},
 { 0, false, NULL, 0, 0, NULL, NULL, eArgTypeNone, NULL }
 };
 #pragma mark CommandObjectMultiwordFrame

Added: lldb/trunk/source/Commands/CommandObjectPlatform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.cpp?rev=127934&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.cpp (added)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.cpp Fri Mar 18 20:12:21 2011
@@ -0,0 +1,306 @@
+//===-- CommandObjectPlatform.cpp -------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "CommandObjectPlatform.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Core/DataExtractor.h"
+#include "lldb/Core/Debugger.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Interpreter/Args.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
+#include "lldb/Interpreter/CommandReturnObject.h"
+#include "lldb/Target/ExecutionContext.h"
+#include "lldb/Target/Platform.h"
+
+using namespace lldb;
+using namespace lldb_private;
+
+//----------------------------------------------------------------------
+// "platform create <platform-name>"
+//----------------------------------------------------------------------
+class CommandObjectPlatformCreate : public CommandObject
+{
+public:
+    CommandObjectPlatformCreate (CommandInterpreter &interpreter) :
+        CommandObject (interpreter, 
+                       "platform create",
+                       "Create a platform instance by name and select it as the current platform.",
+                       "platform create <platform-name>",
+                       0)
+    {
+    }
+
+    virtual
+    ~CommandObjectPlatformCreate ()
+    {
+    }
+
+    virtual bool
+    Execute (Args& args, CommandReturnObject &result)
+    {
+        Error error;
+        if (args.GetArgumentCount() == 1)
+        {
+            PlatformSP platform_sp (Platform::Create (args.GetArgumentAtIndex (0), error));
+            
+            if (platform_sp)
+            {
+                m_interpreter.GetDebugger().GetPlatformList().Append (platform_sp, true);
+                if (m_options.os_version_major != UINT32_MAX)
+                {
+                    platform_sp->SetOSVersion (m_options.os_version_major,
+                                               m_options.os_version_minor,
+                                               m_options.os_version_update);
+                }
+                
+                platform_sp->GetStatus (result.GetOutputStream());
+            }
+        }
+        else
+        {
+            result.AppendError ("command not implemented");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        return result.Succeeded();
+    }
+    
+    virtual Options *
+    GetOptions ()
+    {
+        return &m_options;
+    }
+
+protected:
+
+    class CommandOptions : public Options
+    {
+    public:
+
+        CommandOptions () :
+            os_version_major (UINT32_MAX),
+            os_version_minor (UINT32_MAX),
+            os_version_update (UINT32_MAX)
+        {
+        }
+
+        virtual
+        ~CommandOptions ()
+        {
+        }
+
+        virtual Error
+        SetOptionValue (int option_idx, const char *option_arg)
+        {
+            Error error;
+            char short_option = (char) m_getopt_table[option_idx].val;
+
+            switch (short_option)
+            {
+            case 'v':
+                if (Args::StringToVersion (option_arg, 
+                                           os_version_major,
+                                           os_version_minor,
+                                           os_version_update) == option_arg)
+                {
+                    error.SetErrorStringWithFormat ("invalid version string '%s'", option_arg);
+                }
+                break;
+
+            default:
+                error.SetErrorStringWithFormat ("Unrecognized option '%c'.\n", short_option);
+                break;
+            }
+
+            return error;
+        }
+
+        void
+        ResetOptionValues ()
+        {
+            os_version_major = UINT32_MAX;
+            os_version_minor = UINT32_MAX;
+            os_version_update = UINT32_MAX;
+        }
+
+        const lldb::OptionDefinition*
+        GetDefinitions ()
+        {
+            return g_option_table;
+        }
+
+        // Options table: Required for subclasses of Options.
+
+        static lldb::OptionDefinition g_option_table[];
+
+        // Instance variables to hold the values for command options.
+
+        uint32_t os_version_major;
+        uint32_t os_version_minor;
+        uint32_t os_version_update;
+    };
+    CommandOptions m_options;
+};
+
+lldb::OptionDefinition
+CommandObjectPlatformCreate::CommandOptions::g_option_table[] =
+{
+    { LLDB_OPT_SET_ALL, false, "sdk-version", 'v', required_argument, NULL, 0, eArgTypeNone, "Specify the initial SDK version to use prior to connecting." },
+    { 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
+};
+
+//----------------------------------------------------------------------
+// "platform list"
+//----------------------------------------------------------------------
+class CommandObjectPlatformList : public CommandObject
+{
+public:
+    CommandObjectPlatformList (CommandInterpreter &interpreter) :
+        CommandObject (interpreter,
+                       "platform list",
+                       "List all platforms that are available.",
+                       NULL,
+                       0)
+    {
+    }
+
+    virtual
+    ~CommandObjectPlatformList ()
+    {
+    }
+
+    virtual bool
+    Execute (Args& args, CommandReturnObject &result)
+    {
+        Stream &ostrm = result.GetOutputStream();
+        ostrm.Printf("Available platforms:\n");
+        
+        PlatformSP host_platform_sp (Platform::GetDefaultPlatform());
+        ostrm.Printf ("%s: %s\n", 
+                      host_platform_sp->GetShortPluginName(), 
+                      host_platform_sp->GetDescription());
+
+        uint32_t idx;
+        for (idx = 0; 1; ++idx)
+        {
+            const char *plugin_name = PluginManager::GetPlatformPluginNameAtIndex (idx);
+            if (plugin_name == NULL)
+                break;
+            const char *plugin_desc = PluginManager::GetPlatformPluginDescriptionAtIndex (idx);
+            if (plugin_desc == NULL)
+                break;
+            ostrm.Printf("%s: %s\n", plugin_name, plugin_desc);
+        }
+        
+        if (idx == 0)
+        {
+            result.AppendError ("no platforms are available");
+            result.SetStatus (eReturnStatusFailed);
+        }
+        return result.Succeeded();
+    }
+};
+
+//----------------------------------------------------------------------
+// "platform status"
+//----------------------------------------------------------------------
+class CommandObjectPlatformStatus : public CommandObject
+{
+public:
+    CommandObjectPlatformStatus (CommandInterpreter &interpreter) :
+        CommandObject (interpreter,
+                       "platform status",
+                       "Display status for the currently selected platform.",
+                       NULL,
+                       0)
+    {
+    }
+
+    virtual
+    ~CommandObjectPlatformStatus ()
+    {
+    }
+
+    virtual bool
+    Execute (Args& args, CommandReturnObject &result)
+    {
+        Stream &ostrm = result.GetOutputStream();      
+        
+        PlatformSP selected_platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
+        if (selected_platform_sp)
+        {
+            selected_platform_sp->GetStatus (ostrm);
+            result.SetStatus (eReturnStatusSuccessFinishResult);            
+        }
+        else
+        {
+            result.AppendError ("no platform us currently selected");
+            result.SetStatus (eReturnStatusFailed);            
+        }
+        return result.Succeeded();
+    }
+};
+
+
+//----------------------------------------------------------------------
+// "platform select <platform-name>"
+//----------------------------------------------------------------------
+class CommandObjectPlatformSelect : public CommandObject
+{
+public:
+    CommandObjectPlatformSelect (CommandInterpreter &interpreter) :
+        CommandObject (interpreter, 
+                       "platform select",
+                       "Select a platform by name to be the currently selected platform.",
+                       "platform select <platform-name>",
+                       0)
+    {
+    }
+
+    virtual
+    ~CommandObjectPlatformSelect ()
+    {
+    }
+
+    virtual bool
+    Execute (Args& args, CommandReturnObject &result)
+    {
+        result.AppendError ("command not implemented");
+        result.SetStatus (eReturnStatusFailed);
+        return result.Succeeded();
+    }
+};
+
+
+
+//----------------------------------------------------------------------
+// CommandObjectPlatform constructor
+//----------------------------------------------------------------------
+CommandObjectPlatform::CommandObjectPlatform(CommandInterpreter &interpreter) :
+    CommandObjectMultiword (interpreter,
+                            "platform",
+                            "A set of commands to manage and create platforms.",
+                            "platform [create|list|status|select] ...")
+{
+    LoadSubCommand ("create", CommandObjectSP (new CommandObjectPlatformCreate  (interpreter)));
+    LoadSubCommand ("list"  , CommandObjectSP (new CommandObjectPlatformList    (interpreter)));
+    LoadSubCommand ("select", CommandObjectSP (new CommandObjectPlatformSelect  (interpreter)));
+    LoadSubCommand ("status", CommandObjectSP (new CommandObjectPlatformStatus  (interpreter)));
+}
+
+
+//----------------------------------------------------------------------
+// Destructor
+//----------------------------------------------------------------------
+CommandObjectPlatform::~CommandObjectPlatform()
+{
+}

Added: lldb/trunk/source/Commands/CommandObjectPlatform.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectPlatform.h?rev=127934&view=auto
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectPlatform.h (added)
+++ lldb/trunk/source/Commands/CommandObjectPlatform.h Fri Mar 18 20:12:21 2011
@@ -0,0 +1,45 @@
+//===-- CommandObjectPlatform.h ---------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_CommandObjectPlatform_h_
+#define liblldb_CommandObjectPlatform_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Interpreter/CommandObjectMultiword.h"
+
+namespace lldb_private {
+
+//-------------------------------------------------------------------------
+// CommandObjectPlatform
+//-------------------------------------------------------------------------
+
+class CommandObjectPlatform : public CommandObjectMultiword
+{
+public:
+    //------------------------------------------------------------------
+    // Constructors and Destructors
+    //------------------------------------------------------------------
+    CommandObjectPlatform(CommandInterpreter &interpreter);
+
+    virtual
+    ~CommandObjectPlatform();
+
+private:
+    //------------------------------------------------------------------
+    // For CommandObjectPlatform only
+    //------------------------------------------------------------------
+    DISALLOW_COPY_AND_ASSIGN (CommandObjectPlatform);
+};
+
+} // namespace lldb_private
+
+#endif  // liblldb_CommandObjectPlatform_h_

Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Fri Mar 18 20:12:21 2011
@@ -523,7 +523,7 @@
                 const char *partial_name = NULL;
                 partial_name = input.GetArgumentAtIndex(opt_arg_pos);
 
-                PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+                PlatformSP platform_sp (interpeter.GetDebugger().GetPlatformList().GetSelectedPlatform ());
                 if (platform_sp)
                 {
                     ProcessInfoList process_infos;
@@ -703,7 +703,7 @@
                     if (attach_pid == LLDB_INVALID_PROCESS_ID && wait_name != NULL)
                     {
                         ProcessInfoList process_infos;
-                        PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+                        PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform ());
                         if (platform_sp)
                         {
                             platform_sp->FindProcessesByName (wait_name, eNameMatchEquals, process_infos);

Modified: lldb/trunk/source/Core/Address.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Address.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Core/Address.cpp (original)
+++ lldb/trunk/source/Core/Address.cpp Fri Mar 18 20:12:21 2011
@@ -808,3 +808,16 @@
         }
     }
 }
+
+lldb::AddressClass
+Address::GetAddressClass () const
+{
+    Module *module = GetModule();
+    if (module)
+    {
+        ObjectFile *obj_file = module->GetObjectFile();
+        if (obj_file)
+            return obj_file->GetAddressClass (GetFileAddress());
+    }
+    return eAddressClassUnknown;
+}

Modified: lldb/trunk/source/Core/ArchSpec.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ArchSpec.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Core/ArchSpec.cpp (original)
+++ lldb/trunk/source/Core/ArchSpec.cpp Fri Mar 18 20:12:21 2011
@@ -49,6 +49,9 @@
     { eByteOrderLittle, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv5t      , "armv5t"    },
     { eByteOrderLittle, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv6       , "armv6"     },
     { eByteOrderLittle, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7       , "armv7"     },
+    { eByteOrderLittle, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7f      , "armv7f"    },
+    { eByteOrderLittle, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7k      , "armv7k"    },
+    { eByteOrderLittle, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_armv7s      , "armv7s"    },
     { eByteOrderLittle, 4, llvm::Triple::arm    , ArchSpec::eCore_arm_xscale      , "xscale"    },
     
     { eByteOrderLittle, 4, llvm::Triple::ppc    , ArchSpec::eCore_ppc_generic     , "ppc"       },
@@ -112,6 +115,9 @@
     { ArchSpec::eCore_arm_armv5       , llvm::MachO::CPUTypeARM       , 7       },
     { ArchSpec::eCore_arm_xscale      , llvm::MachO::CPUTypeARM       , 8       },
     { ArchSpec::eCore_arm_armv7       , llvm::MachO::CPUTypeARM       , 9       },
+    { ArchSpec::eCore_arm_armv7f      , llvm::MachO::CPUTypeARM       , 10      },
+    { ArchSpec::eCore_arm_armv7k      , llvm::MachO::CPUTypeARM       , 12      },
+    { ArchSpec::eCore_arm_armv7s      , llvm::MachO::CPUTypeARM       , 11      },
     { ArchSpec::eCore_ppc_generic     , llvm::MachO::CPUTypePowerPC   , CPU_ANY },
     { ArchSpec::eCore_ppc_generic     , llvm::MachO::CPUTypePowerPC   , 0       },
     { ArchSpec::eCore_ppc_ppc601      , llvm::MachO::CPUTypePowerPC   , 1       },

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Fri Mar 18 20:12:21 2011
@@ -225,6 +225,7 @@
     m_output_file (),
     m_error_file (),
     m_target_list (),
+    m_platform_list (),
     m_listener ("lldb.Debugger"),
     m_source_manager (),
     m_command_interpreter_ap (new CommandInterpreter (*this, eScriptLanguageDefault, false)),
@@ -234,6 +235,10 @@
 {
     m_input_comm.SetCloseOnEOF(false);
     m_command_interpreter_ap->Initialize ();
+    // Always add our default platform to the platform list
+    PlatformSP default_platform_sp (Platform::GetDefaultPlatform());
+    assert (default_platform_sp.get());
+    m_platform_list.Append (default_platform_sp, true);
 }
 
 Debugger::~Debugger ()
@@ -262,11 +267,6 @@
     m_command_interpreter_ap->SetSynchronous (!async_execution);
 }
 
-void
-Debugger::DisconnectInput()
-{
-    m_input_comm.Clear ();
-}
     
 void
 Debugger::SetInputFileHandle (FILE *fh, bool tranfer_ownership)
@@ -311,26 +311,6 @@
         err_file.SetStream (stderr, false);
 }
 
-CommandInterpreter &
-Debugger::GetCommandInterpreter ()
-{
-    assert (m_command_interpreter_ap.get());
-    return *m_command_interpreter_ap;
-}
-
-Listener &
-Debugger::GetListener ()
-{
-    return m_listener;
-}
-
-
-TargetSP
-Debugger::GetSelectedTarget ()
-{
-    return m_target_list.GetSelectedTarget ();
-}
-
 ExecutionContext
 Debugger::GetSelectedExecutionContext ()
 {
@@ -360,19 +340,6 @@
 
 }
 
-SourceManager &
-Debugger::GetSourceManager ()
-{
-    return m_source_manager;
-}
-
-
-TargetList&
-Debugger::GetTargetList ()
-{
-    return m_target_list;
-}
-
 InputReaderSP 
 Debugger::GetCurrentInputReader ()
 {

Modified: lldb/trunk/source/Core/PluginManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/PluginManager.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Core/PluginManager.cpp (original)
+++ lldb/trunk/source/Core/PluginManager.cpp Fri Mar 18 20:12:21 2011
@@ -226,50 +226,19 @@
 
 typedef std::vector<ABIInstance> ABIInstances;
 
-static bool
-AccessABIInstances (PluginAction action, ABIInstance &instance, uint32_t index)
+static Mutex &
+GetABIInstancesMutex ()
 {
-    static ABIInstances g_plugin_instances;
-
-    switch (action)
-    {
-        case ePluginRegisterInstance:
-            if (instance.create_callback)
-            {
-                g_plugin_instances.push_back (instance);
-                return true;
-            }
-            break;
-
-        case ePluginUnregisterInstance:
-            if (instance.create_callback)
-            {
-                ABIInstances::iterator pos, end = g_plugin_instances.end();
-                for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-                {
-                    if (pos->create_callback == instance.create_callback)
-                    {
-                        g_plugin_instances.erase(pos);
-                        return true;
-                    }
-                }
-            }
-            break;
-
-        case ePluginGetInstanceAtIndex:
-            if (index < g_plugin_instances.size())
-            {
-                instance = g_plugin_instances[index];
-                return true;
-            }
-            break;
-
-        default:
-            break;
-    }
-    return false;
+    static Mutex g_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_instances_mutex;
 }
 
+static ABIInstances &
+GetABIInstances ()
+{
+    static ABIInstances g_instances;
+    return g_instances;
+}
 
 bool
 PluginManager::RegisterPlugin
@@ -287,7 +256,9 @@
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessABIInstances (ePluginRegisterInstance, instance, 0);
+        Mutex::Locker locker (GetABIInstancesMutex ());
+        GetABIInstances ().push_back (instance);
+        return true;
     }
     return false;
 }
@@ -297,9 +268,18 @@
 {
     if (create_callback)
     {
-        ABIInstance instance;
-        instance.create_callback = create_callback;
-        return AccessABIInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetABIInstancesMutex ());
+        ABIInstances &instances = GetABIInstances ();
+
+        ABIInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -307,9 +287,11 @@
 ABICreateInstance
 PluginManager::GetABICreateCallbackAtIndex (uint32_t idx)
 {
-    ABIInstance instance;
-    if (AccessABIInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetABIInstancesMutex ());
+    ABIInstances &instances = GetABIInstances ();
+
+    if (idx < instances.size())
+        return instances[idx].create_callback;
     return NULL;
 }
 
@@ -318,12 +300,15 @@
 {
     if (name && name[0])
     {
-        ABIInstance instance;
+        Mutex::Locker locker (GetABIInstancesMutex ());
         std::string ss_name(name);
-        for (uint32_t idx = 0; AccessABIInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        ABIInstances &instances = GetABIInstances ();
+
+        ABIInstances::iterator pos, end = instances.end();
+        for (pos = instances.begin(); pos != end; ++ pos)
         {
-            if (instance.name == ss_name)
-                return instance.create_callback;
+            if (pos->name == ss_name)
+                return pos->create_callback;
         }
     }
     return NULL;
@@ -1212,50 +1197,19 @@
 
 typedef std::vector<PlatformInstance> PlatformInstances;
 
-static bool
-AccessPlatformInstances (PluginAction action, PlatformInstance &instance, uint32_t index)
+static Mutex &
+GetPlatformInstancesMutex ()
 {
-    static PlatformInstances g_plugin_instances;
-    
-    switch (action)
-    {
-        case ePluginRegisterInstance:
-            if (instance.create_callback)
-            {
-                g_plugin_instances.push_back (instance);
-                return true;
-            }
-            break;
-            
-        case ePluginUnregisterInstance:
-            if (instance.create_callback)
-            {
-                PlatformInstances::iterator pos, end = g_plugin_instances.end();
-                for (pos = g_plugin_instances.begin(); pos != end; ++ pos)
-                {
-                    if (pos->create_callback == instance.create_callback)
-                    {
-                        g_plugin_instances.erase(pos);
-                        return true;
-                    }
-                }
-            }
-            break;
-            
-        case ePluginGetInstanceAtIndex:
-            if (index < g_plugin_instances.size())
-            {
-                instance = g_plugin_instances[index];
-                return true;
-            }
-            break;
-            
-        default:
-            break;
-    }
-    return false;
+    static Mutex g_platform_instances_mutex (Mutex::eMutexTypeRecursive);
+    return g_platform_instances_mutex;
 }
 
+static PlatformInstances &
+GetPlatformInstances ()
+{
+    static PlatformInstances g_platform_instances;
+    return g_platform_instances;
+}
 
 bool
 PluginManager::RegisterPlugin (const char *name,
@@ -1264,13 +1218,16 @@
 {
     if (create_callback)
     {
+        Mutex::Locker locker (GetPlatformInstancesMutex ());
+        
         PlatformInstance instance;
         assert (name && name[0]);
         instance.name = name;
         if (description && description[0])
             instance.description = description;
         instance.create_callback = create_callback;
-        return AccessPlatformInstances (ePluginRegisterInstance, instance, 0);
+        GetPlatformInstances ().push_back (instance);
+        return true;
     }
     return false;
 }
@@ -1278,18 +1235,20 @@
 const char *
 PluginManager::GetPlatformPluginNameAtIndex (uint32_t idx)
 {
-    PlatformInstance instance;
-    if (AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.name.c_str();
+    Mutex::Locker locker (GetPlatformInstancesMutex ());
+    PlatformInstances &platform_instances = GetPlatformInstances ();
+    if (idx < platform_instances.size())
+        return platform_instances[idx].name.c_str();
     return NULL;
 }
 
 const char *
 PluginManager::GetPlatformPluginDescriptionAtIndex (uint32_t idx)
 {
-    PlatformInstance instance;
-    if (AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.description.c_str();
+    Mutex::Locker locker (GetPlatformInstancesMutex ());
+    PlatformInstances &platform_instances = GetPlatformInstances ();
+    if (idx < platform_instances.size())
+        return platform_instances[idx].description.c_str();
     return NULL;
 }
 
@@ -1298,9 +1257,18 @@
 {
     if (create_callback)
     {
-        PlatformInstance instance;
-        instance.create_callback = create_callback;
-        return AccessPlatformInstances (ePluginUnregisterInstance, instance, 0);
+        Mutex::Locker locker (GetPlatformInstancesMutex ());
+        PlatformInstances &platform_instances = GetPlatformInstances ();
+
+        PlatformInstances::iterator pos, end = platform_instances.end();
+        for (pos = platform_instances.begin(); pos != end; ++ pos)
+        {
+            if (pos->create_callback == create_callback)
+            {
+                platform_instances.erase(pos);
+                return true;
+            }
+        }
     }
     return false;
 }
@@ -1308,9 +1276,10 @@
 PlatformCreateInstance
 PluginManager::GetPlatformCreateCallbackAtIndex (uint32_t idx)
 {
-    PlatformInstance instance;
-    if (AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx))
-        return instance.create_callback;
+    Mutex::Locker locker (GetPlatformInstancesMutex ());
+    PlatformInstances &platform_instances = GetPlatformInstances ();
+    if (idx < platform_instances.size())
+        return platform_instances[idx].create_callback;
     return NULL;
 }
 
@@ -1319,12 +1288,15 @@
 {
     if (name && name[0])
     {
-        PlatformInstance instance;
+        Mutex::Locker locker (GetPlatformInstancesMutex ());
         std::string ss_name(name);
-        for (uint32_t idx = 0; AccessPlatformInstances (ePluginGetInstanceAtIndex, instance, idx); ++idx)
+        PlatformInstances &platform_instances = GetPlatformInstances ();
+
+        PlatformInstances::iterator pos, end = platform_instances.end();
+        for (pos = platform_instances.begin(); pos != end; ++ pos)
         {
-            if (instance.name == ss_name)
-                return instance.create_callback;
+            if (pos->name == ss_name)
+                return pos->create_callback;
         }
     }
     return NULL;

Modified: lldb/trunk/source/Host/macosx/Host.mm
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/macosx/Host.mm?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Host/macosx/Host.mm (original)
+++ lldb/trunk/source/Host/macosx/Host.mm Fri Mar 18 20:12:21 2011
@@ -830,3 +830,48 @@
     return i;
         
 }
+
+
+bool
+Host::GetOSVersion 
+(
+    uint32_t &major, 
+    uint32_t &minor, 
+    uint32_t &update
+)
+{
+    
+    SInt32 version;
+    
+    OSErr err = ::Gestalt (gestaltSystemVersion, &version);
+    if (err != noErr) 
+        return false;
+
+    if (version < 0x1040)
+    {
+        major = ((version & 0xF000) >> 12) * 10 + ((version & 0x0F00) >> 8);
+        minor = (version & 0x00F0) >> 4;
+        update = (version & 0x000F);
+    }
+    else
+    {
+        if (::Gestalt (gestaltSystemVersionMajor, &version) != noErr)
+            return false;
+        major = version;
+
+        if (::Gestalt (gestaltSystemVersionMinor, &version) == noErr)
+            minor = version;
+        else
+            minor = 0;
+
+        if (::Gestalt (gestaltSystemVersionBugFix, &version) == noErr)
+            update = version;
+        else
+            update = 0;
+    }
+    
+    return true;
+
+}
+
+

Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Fri Mar 18 20:12:21 2011
@@ -754,6 +754,47 @@
     return fail_value;
 }
 
+const char *
+Args::StringToVersion (const char *s, uint32_t &major, uint32_t &minor, uint32_t &update)
+{
+    major = UINT32_MAX;
+    minor = UINT32_MAX;
+    update = UINT32_MAX;
+
+    if (s && s[0])
+    {
+        char *pos = NULL;
+        uint32_t uval32;
+        uval32 = ::strtoul (s, &pos, 0);
+        if (pos == s)
+            return s;
+        major = uval32;
+        if (*pos == '\0')
+        {
+            return pos;   // Decoded major and got end of string
+        }
+        else if (*pos == '.')
+        {
+            const char *minor_cstr = pos + 1;
+            uval32 = ::strtoul (minor_cstr, &pos, 0);
+            if (pos == minor_cstr)
+                return pos; // Didn't get any digits for the minor version...
+            minor = uval32;
+            if (*pos == '.')
+            {
+                const char *update_cstr = pos + 1;
+                uval32 = ::strtoul (update_cstr, &pos, 0);
+                if (pos == update_cstr)
+                    return pos;
+                update = uval32;
+            }
+            return pos;
+        }
+    }
+    return 0;
+}
+
+
 int32_t
 Args::StringToOptionEnum (const char *s, lldb::OptionEnumValueElement *enum_values, int32_t fail_value, bool *success_ptr)
 {    

Modified: lldb/trunk/source/Interpreter/CommandInterpreter.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandInterpreter.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/CommandInterpreter.cpp (original)
+++ lldb/trunk/source/Interpreter/CommandInterpreter.cpp Fri Mar 18 20:12:21 2011
@@ -25,6 +25,7 @@
 #include "../Commands/CommandObjectImage.h"
 #include "../Commands/CommandObjectLog.h"
 #include "../Commands/CommandObjectMemory.h"
+#include "../Commands/CommandObjectPlatform.h"
 #include "../Commands/CommandObjectProcess.h"
 #include "../Commands/CommandObjectQuit.h"
 #include "lldb/Interpreter/CommandObjectRegexCommand.h"
@@ -166,6 +167,7 @@
     m_command_dict["image"]     = CommandObjectSP (new CommandObjectImage (*this));
     m_command_dict["log"]       = CommandObjectSP (new CommandObjectLog (*this));
     m_command_dict["memory"]    = CommandObjectSP (new CommandObjectMemory (*this));
+    m_command_dict["platform"]  = CommandObjectSP (new CommandObjectPlatform (*this));
     m_command_dict["process"]   = CommandObjectSP (new CommandObjectMultiwordProcess (*this));
     m_command_dict["quit"]      = CommandObjectSP (new CommandObjectQuit (*this));
     m_command_dict["register"]  = CommandObjectSP (new CommandObjectRegister (*this));

Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp Fri Mar 18 20:12:21 2011
@@ -31,8 +31,8 @@
 using namespace lldb_private;
 
 
-static
-int DataExtractorByteReader(uint8_t *byte, uint64_t address, void *arg)
+static int 
+DataExtractorByteReader(uint8_t *byte, uint64_t address, void *arg)
 {
     DataExtractor &extractor = *((DataExtractor *)arg);
 
@@ -66,7 +66,7 @@
     uint64_t instructionPointer = ((RegisterReaderArg*)arg)->instructionPointer;
     EDDisassemblerRef disassembler = ((RegisterReaderArg*)arg)->disassembler;
 
-    if(EDRegisterIsProgramCounter(disassembler, regID)) {
+    if (EDRegisterIsProgramCounter(disassembler, regID)) {
         *value = instructionPointer;
         return 0;
     }
@@ -371,13 +371,26 @@
 
 DisassemblerLLVM::DisassemblerLLVM(const ArchSpec &arch) :
     Disassembler (arch),
-    m_disassembler (NULL)
+    m_disassembler (NULL),
+    m_disassembler_thumb (NULL) // For ARM only
 {
     const std::string &arch_triple = arch.GetTriple().str();
     if (!arch_triple.empty())
     {
         if (EDGetDisassembler(&m_disassembler, arch_triple.c_str(), SyntaxForArchSpec (arch)))
             m_disassembler = NULL;
+        llvm::Triple::ArchType llvm_arch = arch.GetTriple().getArch();
+        if (llvm_arch == llvm::Triple::arm)
+        {
+            if (EDGetDisassembler(&m_disassembler_thumb, "thumb-apple-darwin", kEDAssemblySyntaxARMUAL))
+                m_disassembler_thumb = NULL;
+        }
+        else if (llvm_arch == llvm::Triple::thumb)
+        {
+            m_disassembler_thumb = m_disassembler;
+            if (EDGetDisassembler(&m_disassembler, "arm-apple-darwin-unknown", kEDAssemblySyntaxARMUAL))
+                m_disassembler = NULL;
+        }
     }
 }
 
@@ -405,7 +418,18 @@
     {
         Address inst_addr (base_addr);
         inst_addr.Slide(data_offset);
-        InstructionSP inst_sp (new InstructionLLVM(m_disassembler, inst_addr));
+
+        bool use_thumb = false;
+        // If we have a thumb disassembler, then we have an ARM architecture
+        // so we need to check what the instruction address class is to make
+        // sure we shouldn't be disassembling as thumb...
+        if (m_disassembler_thumb)
+        {
+            if (inst_addr.GetAddressClass () == eAddressClassCodeAlternateISA)
+                use_thumb = true;
+        }
+        InstructionSP inst_sp (new InstructionLLVM (use_thumb ? m_disassembler_thumb : m_disassembler, 
+                                                    inst_addr));
 
         size_t inst_byte_size = inst_sp->Extract (data, data_offset);
 

Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h (original)
+++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h Fri Mar 18 20:12:21 2011
@@ -100,6 +100,7 @@
     }
 
     EDDisassemblerRef m_disassembler;
+    EDDisassemblerRef m_disassembler_thumb;
 };
 
 #endif  // liblldb_DisassemblerLLVM_h_

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Fri Mar 18 20:12:21 2011
@@ -29,6 +29,7 @@
 using namespace lldb_private;
 using namespace llvm::MachO;
 
+#define MACHO_NLIST_ARM_SYMBOL_IS_THUMB 0x0008
 
 void
 ObjectFileMachO::Initialize()
@@ -201,6 +202,108 @@
     return m_data.GetAddressByteSize ();
 }
 
+lldb::AddressClass
+ObjectFileMachO::GetAddressClass (lldb::addr_t file_addr)
+{
+    Symtab *symtab = GetSymtab();
+    if (symtab)
+    {
+        Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr);
+        if (symbol)
+        {
+            const AddressRange *range_ptr = symbol->GetAddressRangePtr();
+            if (range_ptr)
+            {
+                const Section *section = range_ptr->GetBaseAddress().GetSection();
+                if (section)
+                {
+                    const lldb::SectionType section_type = section->GetType();
+                    switch (section_type)
+                    {
+                    case eSectionTypeInvalid:               return eAddressClassUnknown;
+                    case eSectionTypeCode:
+                        if (m_header.cputype == llvm::MachO::CPUTypeARM)
+                        {
+                            // For ARM we have a bit in the n_desc field of the symbol
+                            // that tells us ARM/Thumb which is bit 0x0008.
+                            if (symbol->GetFlags() & MACHO_NLIST_ARM_SYMBOL_IS_THUMB)
+                                return eAddressClassCodeAlternateISA;
+                        }
+                        return eAddressClassCode;
+
+                    case eSectionTypeContainer:             return eAddressClassUnknown;
+                    case eSectionTypeData:                  return eAddressClassData;
+                    case eSectionTypeDataCString:           return eAddressClassDataConst;
+                    case eSectionTypeDataCStringPointers:   return eAddressClassData;
+                    case eSectionTypeDataSymbolAddress:     return eAddressClassData;
+                    case eSectionTypeData4:                 return eAddressClassData;
+                    case eSectionTypeData8:                 return eAddressClassData;
+                    case eSectionTypeData16:                return eAddressClassData;
+                    case eSectionTypeDataPointers:          return eAddressClassData;
+                    case eSectionTypeZeroFill:              return eAddressClassData;
+                    case eSectionTypeDataObjCMessageRefs:   return eAddressClassDataConst;
+                    case eSectionTypeDataObjCCFStrings:     return eAddressClassDataConst;
+                    case eSectionTypeDebug:                 return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugAbbrev:      return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugAranges:     return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugFrame:       return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugInfo:        return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugLine:        return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugLoc:         return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugMacInfo:     return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugPubNames:    return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugPubTypes:    return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugRanges:      return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugStr:         return eAddressClassDebug;
+                    case eSectionTypeEHFrame:               return eAddressClassRuntime;
+                    case eSectionTypeOther:                 return eAddressClassUnknown;
+                    }
+                }
+            }
+            
+            const lldb::SymbolType symbol_type = symbol->GetType();
+            switch (symbol_type)
+            {
+            case eSymbolTypeAny:            return eAddressClassUnknown;
+            case eSymbolTypeAbsolute:       return eAddressClassUnknown;
+            case eSymbolTypeExtern:         return eAddressClassUnknown;
+                    
+            case eSymbolTypeCode:
+            case eSymbolTypeTrampoline:
+                if (m_header.cputype == llvm::MachO::CPUTypeARM)
+                {
+                    // For ARM we have a bit in the n_desc field of the symbol
+                    // that tells us ARM/Thumb which is bit 0x0008.
+                    if (symbol->GetFlags() & MACHO_NLIST_ARM_SYMBOL_IS_THUMB)
+                        return eAddressClassCodeAlternateISA;
+                }
+                return eAddressClassCode;
+
+            case eSymbolTypeData:           return eAddressClassData;
+            case eSymbolTypeRuntime:        return eAddressClassRuntime;
+            case eSymbolTypeException:      return eAddressClassRuntime;
+            case eSymbolTypeSourceFile:     return eAddressClassDebug;
+            case eSymbolTypeHeaderFile:     return eAddressClassDebug;
+            case eSymbolTypeObjectFile:     return eAddressClassDebug;
+            case eSymbolTypeCommonBlock:    return eAddressClassDebug;
+            case eSymbolTypeBlock:          return eAddressClassDebug;
+            case eSymbolTypeLocal:          return eAddressClassData;
+            case eSymbolTypeParam:          return eAddressClassData;
+            case eSymbolTypeVariable:       return eAddressClassData;
+            case eSymbolTypeVariableType:   return eAddressClassDebug;
+            case eSymbolTypeLineEntry:      return eAddressClassDebug;
+            case eSymbolTypeLineHeader:     return eAddressClassDebug;
+            case eSymbolTypeScopeBegin:     return eAddressClassDebug;
+            case eSymbolTypeScopeEnd:       return eAddressClassDebug;
+            case eSymbolTypeAdditional:     return eAddressClassUnknown;
+            case eSymbolTypeCompiler:       return eAddressClassDebug;
+            case eSymbolTypeInstrumentation:return eAddressClassDebug;
+            case eSymbolTypeUndefined:      return eAddressClassUnknown;
+            }
+        }
+    }
+    return eAddressClassUnknown;
+}
 
 Symtab *
 ObjectFileMachO::GetSymtab()

Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h (original)
+++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h Fri Mar 18 20:12:21 2011
@@ -74,6 +74,9 @@
     virtual size_t
     GetAddressByteSize ()  const;
 
+    virtual lldb::AddressClass
+    GetAddressClass (lldb::addr_t file_addr);
+
     virtual lldb_private::Symtab *
     GetSymtab();
 

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp Fri Mar 18 20:12:21 2011
@@ -10,16 +10,20 @@
 #include "PlatformMacOSX.h"
 
 // C Includes
+#include <sys/sysctl.h>
+
 // C++ Includes
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/Error.h"
+#include "lldb/Breakpoint/BreakpointLocation.h"
 #include "lldb/Core/Module.h"
 #include "lldb/Core/ModuleList.h"
 #include "lldb/Core/StreamString.h"
 #include "lldb/Host/FileSpec.h"
 #include "lldb/Host/Host.h"
 #include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
 
 using namespace lldb;
 using namespace lldb_private;
@@ -29,6 +33,7 @@
 {
 #if defined (__APPLE__)
     PlatformSP default_platform_sp (new PlatformMacOSX());
+    default_platform_sp->SetSystemArchitecture (Host::GetArchitecture());
     Platform::SetDefaultPlatform (default_platform_sp);
 #endif
 }
@@ -38,7 +43,6 @@
 {
 }
 
-
 Error
 PlatformMacOSX::ResolveExecutable (const FileSpec &exe_file,
                                    const ArchSpec &exe_arch,
@@ -142,11 +146,58 @@
 }
 
 
+void
+PlatformMacOSX::GetStatus (Stream &strm)
+{
+    char sysctlstring[1024];
+    size_t datalen;
+    int mib[CTL_MAXNAME];
+
+    uint32_t major = UINT32_MAX;
+    uint32_t minor = UINT32_MAX;
+    uint32_t update = UINT32_MAX;
+    strm.PutCString("Host platform: Mac OS X Native\n");
+    if (GetOSVersion(major, minor, update))
+    {
+        strm.Printf("OS version: %u", major);
+        if (minor != UINT32_MAX)
+            strm.Printf(".%u", minor);
+        if (update != UINT32_MAX)
+            strm.Printf(".%u", update);
+
+
+        mib[0] = CTL_KERN;
+        mib[1] = KERN_OSVERSION;
+        datalen = sizeof(sysctlstring);
+        if (::sysctl (mib, 2, sysctlstring, &datalen, NULL, 0) == 0)
+        {
+            sysctlstring[datalen] = '\0';
+            strm.Printf(" (%s)", sysctlstring);
+        }
+
+        strm.EOL();
+    }
+        
+    mib[0] = CTL_KERN;
+    mib[1] = KERN_VERSION;
+    datalen = sizeof(sysctlstring);
+    if (::sysctl (mib, 2, sysctlstring, &datalen, NULL, 0) == 0)
+    {
+        sysctlstring[datalen] = '\0';
+        strm.Printf("Kernel version: %s\n", sysctlstring);
+    }
+}
+
+
 //------------------------------------------------------------------
 /// Default Constructor
 //------------------------------------------------------------------
 PlatformMacOSX::PlatformMacOSX () :
-    Platform()
+#if defined (__APPLE__)
+    Platform(true)  // This is the local host platform
+#else
+    Platform(false) // This is a remote platform
+#endif
 {
 }
 
@@ -197,3 +248,65 @@
     }
     return false;
 }
+
+size_t
+PlatformMacOSX::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
+{
+    const uint8_t *trap_opcode = NULL;
+    uint32_t trap_opcode_size = 0;
+        
+    llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
+    switch (machine)
+    {
+    case llvm::Triple::x86:
+    case llvm::Triple::x86_64:
+        {
+            static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
+            trap_opcode = g_i386_breakpoint_opcode;
+            trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
+        }
+        break;
+        
+    case llvm::Triple::arm:
+        {
+            static const uint8_t g_arm_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
+            static const uint8_t g_thumb_breakpooint_opcode[] = { 0xFE, 0xDE };
+
+            lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
+            if (bp_loc_sp)
+            {
+                const AddressClass addr_class = bp_loc_sp->GetAddress().GetAddressClass ();
+                if (addr_class == eAddressClassCodeAlternateISA)
+                {
+                    trap_opcode = g_thumb_breakpooint_opcode;
+                    trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
+                    break;
+                }
+            }
+            trap_opcode = g_arm_breakpoint_opcode;
+            trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+        }
+        break;
+        
+    case llvm::Triple::ppc:
+    case llvm::Triple::ppc64:
+        {
+            static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
+            trap_opcode = g_ppc_breakpoint_opcode;
+            trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
+        }
+        break;
+        
+    default:
+        assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()");
+        break;
+    }
+    
+    if (trap_opcode && trap_opcode_size)
+    {
+        if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
+            return trap_opcode_size;
+    }
+    return 0;
+
+}

Modified: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h (original)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformMacOSX.h Fri Mar 18 20:12:21 2011
@@ -45,7 +45,7 @@
         virtual const char *
         GetShortPluginName()
         {
-            return "platform.macosx";
+            return "local-macosx";
         }
         
         virtual uint32_t
@@ -63,6 +63,15 @@
                            const ArchSpec &arch,
                            lldb::ModuleSP &module_sp);
 
+        virtual const char *
+        GetDescription ()
+        {
+            return "The native host platform on MacOSX.";
+        }
+
+        virtual void
+        GetStatus (Stream &strm);
+
         virtual Error
         GetFile (const FileSpec &platform_file, FileSpec &local_file);
 
@@ -77,9 +86,10 @@
         virtual bool
         GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch);
 
-    protected:
-        
-        
+        virtual size_t
+        GetSoftwareBreakpointTrapOpcode (Target &target, 
+                                         BreakpointSite *bp_site);
+
     private:
         DISALLOW_COPY_AND_ASSIGN (PlatformMacOSX);
 

Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp?rev=127934&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp (added)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp Fri Mar 18 20:12:21 2011
@@ -0,0 +1,613 @@
+//===-- Platform.cpp --------------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "PlatformRemoteiOS.h"
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Breakpoint/BreakpointLocation.h"
+#include "lldb/Core/ArchSpec.h"
+#include "lldb/Core/Error.h"
+#include "lldb/Core/Module.h"
+#include "lldb/Core/ModuleList.h"
+#include "lldb/Core/PluginManager.h"
+#include "lldb/Core/StreamString.h"
+#include "lldb/Host/FileSpec.h"
+#include "lldb/Host/Host.h"
+#include "lldb/Target/Process.h"
+#include "lldb/Target/Target.h"
+
+using namespace lldb;
+using namespace lldb_private;
+    
+void
+PlatformRemoteiOS::Initialize ()
+{
+    static bool g_initialized = false;
+
+    if (g_initialized == false)
+    {
+        g_initialized = true;
+        PluginManager::RegisterPlugin (GetShortPluginNameStatic(),
+                                       GetDescriptionStatic(),
+                                       CreateInstance);
+    }
+}
+
+Platform* 
+PlatformRemoteiOS::CreateInstance ()
+{
+    return new PlatformRemoteiOS ();
+}
+
+void
+PlatformRemoteiOS::Terminate ()
+{
+}
+
+const char *
+PlatformRemoteiOS::GetPluginNameStatic ()
+{
+    return "PlatformRemoteiOS";
+}
+
+const char *
+PlatformRemoteiOS::GetShortPluginNameStatic()
+{
+    return "remote-ios";
+}
+
+const char *
+PlatformRemoteiOS::GetDescriptionStatic()
+{
+    return "Remote iOS platform plug-in.";
+}
+
+
+void
+PlatformRemoteiOS::GetStatus (Stream &strm)
+{
+    uint32_t major = UINT32_MAX;
+    uint32_t minor = UINT32_MAX;
+    uint32_t update = UINT32_MAX;
+    const char *sdk_directory = GetDeviceSupportDirectoryForOSVersion();
+    strm.PutCString ("Remote platform: iOS platform\n");
+    if (GetOSVersion(major, minor, update))
+    {
+        strm.Printf("SDK version: %u", major);
+        if (minor != UINT32_MAX)
+            strm.Printf(".%u", minor);
+        if (update != UINT32_MAX)
+            strm.Printf(".%u", update);
+        strm.EOL();
+    }
+
+    if (!m_build_update.empty())
+        strm.Printf("SDK update: %s\n", m_build_update.c_str());
+
+    if (sdk_directory)
+        strm.Printf ("SDK path: \"%s\"\n", sdk_directory);
+    else
+        strm.PutCString ("SDK path: error: unable to locate SDK\n");
+
+    if (IsConnected())
+        strm.Printf("Connected to: %s\n", m_remote_url.c_str());
+    else
+        strm.PutCString("Not connected to a remote device.\n");
+}
+
+
+Error
+PlatformRemoteiOS::ResolveExecutable (const FileSpec &exe_file,
+                                      const ArchSpec &exe_arch,
+                                      lldb::ModuleSP &exe_module_sp)
+{
+    Error error;
+    // Nothing special to do here, just use the actual file and architecture
+
+    FileSpec resolved_exe_file (exe_file);
+    
+    // If we have "ls" as the exe_file, resolve the executable loation based on
+    // the current path variables
+    // TODO: resolve bare executables in the Platform SDK
+//    if (!resolved_exe_file.Exists())
+//        resolved_exe_file.ResolveExecutableLocation ();
+
+    // Resolve any executable within a bundle on MacOSX
+    // TODO: verify that this handles shallow bundles, if not then implement one ourselves
+    Host::ResolveExecutableInBundle (resolved_exe_file);
+
+    if (resolved_exe_file.Exists())
+    {
+        if (exe_arch.IsValid())
+        {
+            error = ModuleList::GetSharedModule (resolved_exe_file, 
+                                                 exe_arch, 
+                                                 NULL,
+                                                 NULL, 
+                                                 0, 
+                                                 exe_module_sp, 
+                                                 NULL, 
+                                                 NULL);
+        
+            if (exe_module_sp->GetObjectFile() == NULL)
+            {
+                exe_module_sp.reset();
+                error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain the architecture %s",
+                                                exe_file.GetDirectory().AsCString(""),
+                                                exe_file.GetDirectory() ? "/" : "",
+                                                exe_file.GetFilename().AsCString(""),
+                                                exe_arch.GetArchitectureName());
+            }
+        }
+        else
+        {
+            // No valid architecture was specified, ask the platform for
+            // the architectures that we should be using (in the correct order)
+            // and see if we can find a match that way
+            StreamString arch_names;
+            ArchSpec platform_arch;
+            for (uint32_t idx = 0; GetSupportedArchitectureAtIndex (idx, platform_arch); ++idx)
+            {
+                error = ModuleList::GetSharedModule (resolved_exe_file, 
+                                                     platform_arch, 
+                                                     NULL,
+                                                     NULL, 
+                                                     0, 
+                                                     exe_module_sp, 
+                                                     NULL, 
+                                                     NULL);
+                // Did we find an executable using one of the 
+                if (error.Success())
+                {
+                    if (exe_module_sp && exe_module_sp->GetObjectFile())
+                        break;
+                    else
+                        error.SetErrorToGenericError();
+                }
+                
+                if (idx > 0)
+                    arch_names.PutCString (", ");
+                arch_names.PutCString (platform_arch.GetArchitectureName());
+            }
+            
+            if (error.Fail() || !exe_module_sp)
+            {
+                error.SetErrorStringWithFormat ("'%s%s%s' doesn't contain any '%s' platform architectures: %s",
+                                                exe_file.GetDirectory().AsCString(""),
+                                                exe_file.GetDirectory() ? "/" : "",
+                                                exe_file.GetFilename().AsCString(""),
+                                                GetShortPluginName(),
+                                                arch_names.GetString().c_str());
+            }
+        }
+    }
+    else
+    {
+        error.SetErrorStringWithFormat ("'%s%s%s' does not exist",
+                                        exe_file.GetDirectory().AsCString(""),
+                                        exe_file.GetDirectory() ? "/" : "",
+                                        exe_file.GetFilename().AsCString(""));
+    }
+
+    return error;
+}
+
+const char *
+PlatformRemoteiOS::GetDeviceSupportDirectory()
+{
+    if (m_device_support_directory.empty())
+    {
+        bool developer_dir_path_valid = false;
+        char developer_dir_path[PATH_MAX];
+        FileSpec temp_file_spec;
+        if (Host::GetLLDBPath (ePathTypeLLDBShlibDir, temp_file_spec))
+        {
+            if (temp_file_spec.GetPath (developer_dir_path, sizeof(developer_dir_path)))
+            {
+                char *lib_priv_frameworks = strstr (developer_dir_path, "/Library/PrivateFrameworks/LLDB.framework");
+                if (lib_priv_frameworks)
+                {
+                    *lib_priv_frameworks = '\0';
+                    developer_dir_path_valid = true;
+                }
+            }
+        }
+        
+        if (!developer_dir_path_valid)
+        {
+            std::string xcode_dir_path;
+            const char *xcode_select_prefix_dir = getenv ("XCODE_SELECT_PREFIX_DIR");
+            if (xcode_select_prefix_dir)
+                xcode_dir_path.append (xcode_select_prefix_dir);
+            xcode_dir_path.append ("/usr/share/xcode-select/xcode_dir_path");
+            temp_file_spec.SetFile(xcode_dir_path.c_str(), false);
+            size_t bytes_read = temp_file_spec.ReadFileContents(0, developer_dir_path, sizeof(developer_dir_path));
+            if (bytes_read > 0)
+            {
+                developer_dir_path[bytes_read] = '\0';
+                while (developer_dir_path[bytes_read-1] == '\r' ||
+                       developer_dir_path[bytes_read-1] == '\n')
+                    developer_dir_path[--bytes_read] = '\0';
+                developer_dir_path_valid = true;
+            }
+        }
+        
+        if (developer_dir_path_valid)
+        {
+            temp_file_spec.SetFile (developer_dir_path, false);
+            if (temp_file_spec.Exists())
+            {
+                m_device_support_directory.assign (developer_dir_path);
+                return m_device_support_directory.c_str();
+            }
+        }
+        // Assign a single NULL character so we know we tried to find the device
+        // support directory and we don't keep trying to find it over and over.
+        m_device_support_directory.assign (1, '\0');
+    }
+
+    // We should have put a single NULL character into m_device_support_directory
+    // or it should have a valid path if the code gets here
+    assert (m_device_support_directory.empty() == false);
+    if (m_device_support_directory[0])
+        return m_device_support_directory.c_str();
+    return NULL;
+}
+
+const char *
+PlatformRemoteiOS::GetDeviceSupportDirectoryForOSVersion()
+{
+    if (m_device_support_directory_for_os_version.empty())
+    {
+        const char *device_support_dir = GetDeviceSupportDirectory();
+        const bool resolve_path = true;
+        if (device_support_dir)
+        {
+            m_device_support_directory_for_os_version.assign (device_support_dir);
+            m_device_support_directory_for_os_version.append ("/Platforms/iPhoneOS.platform/DeviceSupport");
+
+            uint32_t major = 0;
+            uint32_t minor = 0;
+            uint32_t update = 0;
+            FileSpec file_spec;
+            char resolved_path[PATH_MAX];
+            if (GetOSVersion(major, minor, update))
+            {
+                if (major != UINT32_MAX && minor != UINT32_MAX && update != UINT32_MAX)
+                {
+                    ::snprintf (resolved_path, 
+                                sizeof(resolved_path), 
+                                "%s/%i.%i.%i", 
+                                m_device_support_directory_for_os_version.c_str(), 
+                                major, 
+                                minor, 
+                                update);
+                    
+                    file_spec.SetFile(resolved_path, resolve_path);
+                    if (file_spec.Exists() && file_spec.GetPath(resolved_path, sizeof(resolved_path)))
+                    {
+                        m_device_support_directory_for_os_version.assign (resolved_path);
+                        return m_device_support_directory_for_os_version.c_str();
+                    }
+                }
+
+                if (major != UINT32_MAX && minor != UINT32_MAX)
+                {
+                    ::snprintf (resolved_path, 
+                                sizeof(resolved_path), 
+                                "%s/%i.%i", 
+                                m_device_support_directory_for_os_version.c_str(), 
+                                major, 
+                                minor, 
+                                update);
+                    
+                    file_spec.SetFile(resolved_path, resolve_path);
+                    if (file_spec.Exists() && file_spec.GetPath(resolved_path, sizeof(resolved_path)))
+                    {
+                        m_device_support_directory_for_os_version.assign (resolved_path);
+                        return m_device_support_directory_for_os_version.c_str();
+                    }
+                }
+            }
+            else
+            {
+                // Use the default as we have no OS version selected
+                m_device_support_directory_for_os_version.append ("/Latest");
+                file_spec.SetFile(m_device_support_directory_for_os_version.c_str(), resolve_path);
+                
+                if (file_spec.Exists() && file_spec.GetPath(resolved_path, sizeof(resolved_path)))
+                {
+                    if (m_major_os_version == UINT32_MAX)
+                    {
+                        const char *resolved_latest_dirname = file_spec.GetFilename().GetCString();
+                        const char *pos = Args::StringToVersion (resolved_latest_dirname, 
+                                                                 m_major_os_version,
+                                                                 m_minor_os_version,
+                                                                 m_update_os_version);
+
+                        if (m_build_update.empty() && pos[0] == ' ' && pos[1] == '(')
+                        {
+                            const char *end_paren = strchr (pos + 2, ')');
+                            m_build_update.assign (pos + 2, end_paren);
+                        }
+                    }
+                    m_device_support_directory_for_os_version.assign (resolved_path);
+                    return m_device_support_directory_for_os_version.c_str();
+                }
+            }
+        }
+        // Assign a single NULL character so we know we tried to find the device
+        // support directory and we don't keep trying to find it over and over.
+        m_device_support_directory_for_os_version.assign (1, '\0');
+    }
+    // We should have put a single NULL character into m_device_support_directory_for_os_version
+    // or it should have a valid path if the code gets here
+    assert (m_device_support_directory_for_os_version.empty() == false);
+    if (m_device_support_directory_for_os_version[0])
+        return m_device_support_directory_for_os_version.c_str();
+    return NULL;
+}
+
+Error
+PlatformRemoteiOS::GetFile (const FileSpec &platform_file, 
+                            FileSpec &local_file)
+{
+    Error error;
+    char platform_file_path[PATH_MAX];
+    if (platform_file.GetPath(platform_file_path, sizeof(platform_file_path)))
+    {
+        char resolved_path[PATH_MAX];
+    
+        const char * os_version_dir = GetDeviceSupportDirectoryForOSVersion();
+        if (os_version_dir)
+        {
+            ::snprintf (resolved_path, 
+                        sizeof(resolved_path), 
+                        "%s/Symbols.Internal/%s", 
+                        os_version_dir, 
+                        platform_file_path);
+
+            local_file.SetFile(resolved_path, true);
+            if (local_file.Exists())
+                return error;
+            ::snprintf (resolved_path, 
+                        sizeof(resolved_path), 
+                        "%s/Symbols/%s", 
+                        os_version_dir, 
+                        platform_file_path);
+
+            local_file.SetFile(resolved_path, true);
+            if (local_file.Exists())
+                return error;
+
+        }
+        local_file = platform_file;
+        if (local_file.Exists())
+            return error;
+
+        error.SetErrorStringWithFormat ("unable to locate a platform file for '%s' in platform '%s'", 
+                                        platform_file_path,
+                                        GetPluginName());
+    }
+    else
+    {
+        error.SetErrorString ("invalid platform file argument");
+    }
+    return error;
+}
+
+//------------------------------------------------------------------
+/// Default Constructor
+//------------------------------------------------------------------
+PlatformRemoteiOS::PlatformRemoteiOS () :
+    Platform(false),    // This is a remote platform
+    m_device_support_directory (),
+    m_device_support_directory_for_os_version ()
+{
+}
+
+//------------------------------------------------------------------
+/// Destructor.
+///
+/// The destructor is virtual since this class is designed to be
+/// inherited from by the plug-in instance.
+//------------------------------------------------------------------
+PlatformRemoteiOS::~PlatformRemoteiOS()
+{
+}
+
+uint32_t
+PlatformRemoteiOS::FindProcessesByName (const char *name_match, 
+                                        lldb::NameMatchType name_match_type,
+                                        ProcessInfoList &process_infos)
+{
+    // TODO: if connected, send a packet to get the remote process infos by name
+    process_infos.Clear();
+    return 0;
+}
+
+bool
+PlatformRemoteiOS::GetProcessInfo (lldb::pid_t pid, ProcessInfo &process_info)
+{
+    // TODO: if connected, send a packet to get the remote process info
+    process_info.Clear();
+    return false;
+}
+
+bool
+PlatformRemoteiOS::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch)
+{
+    ArchSpec system_arch (GetSystemArchitecture());
+    const ArchSpec::Core system_core = system_arch.GetCore();
+    switch (system_core)
+    {
+    default:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv7-apple-darwin");  return true;
+        case 1: arch.SetTriple ("armv7f-apple-darwin"); return true;
+        case 2: arch.SetTriple ("armv7k-apple-darwin"); return true;
+        case 3: arch.SetTriple ("armv7s-apple-darwin"); return true;
+        case 4: arch.SetTriple ("armv6-apple-darwin");  return true;
+        case 5: arch.SetTriple ("armv5-apple-darwin");  return true;
+        case 6: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 7: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+
+    case ArchSpec::eCore_arm_armv7f:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv7f-apple-darwin"); return true;
+        case 1: arch.SetTriple ("armv7-apple-darwin");  return true;
+        case 2: arch.SetTriple ("armv6-apple-darwin");  return true;
+        case 3: arch.SetTriple ("armv5-apple-darwin");  return true;
+        case 4: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 5: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+
+    case ArchSpec::eCore_arm_armv7k:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv7k-apple-darwin"); return true;
+        case 1: arch.SetTriple ("armv7-apple-darwin");  return true;
+        case 2: arch.SetTriple ("armv6-apple-darwin");  return true;
+        case 3: arch.SetTriple ("armv5-apple-darwin");  return true;
+        case 4: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 5: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+
+    case ArchSpec::eCore_arm_armv7s:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv7s-apple-darwin"); return true;
+        case 1: arch.SetTriple ("armv7-apple-darwin");  return true;
+        case 2: arch.SetTriple ("armv6-apple-darwin");  return true;
+        case 3: arch.SetTriple ("armv5-apple-darwin");  return true;
+        case 4: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 5: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+
+    case ArchSpec::eCore_arm_armv7:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv7-apple-darwin");  return true;
+        case 1: arch.SetTriple ("armv6-apple-darwin");  return true;
+        case 2: arch.SetTriple ("armv5-apple-darwin");  return true;
+        case 3: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 4: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+
+    case ArchSpec::eCore_arm_armv6:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv6-apple-darwin");  return true;
+        case 1: arch.SetTriple ("armv5-apple-darwin");  return true;
+        case 2: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 3: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+
+    case ArchSpec::eCore_arm_armv5:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv5-apple-darwin");  return true;
+        case 1: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 2: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+
+    case ArchSpec::eCore_arm_armv4:
+        switch (idx)
+        {
+        case 0: arch.SetTriple ("armv4-apple-darwin");  return true;
+        case 1: arch.SetTriple ("arm-apple-darwin");    return true;
+        default: break;
+        }
+        break;
+    }
+    arch.Clear();
+    return false;
+}
+
+size_t
+PlatformRemoteiOS::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site)
+{
+    const uint8_t *trap_opcode = NULL;
+    uint32_t trap_opcode_size = 0;
+        
+    llvm::Triple::ArchType machine = target.GetArchitecture().GetMachine();
+    switch (machine)
+    {
+    case llvm::Triple::x86:
+    case llvm::Triple::x86_64:
+        {
+            static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
+            trap_opcode = g_i386_breakpoint_opcode;
+            trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
+        }
+        break;
+        
+    case llvm::Triple::arm:
+        {
+            static const uint8_t g_arm_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
+            static const uint8_t g_thumb_breakpooint_opcode[] = { 0xFE, 0xDE };
+
+            lldb::BreakpointLocationSP bp_loc_sp (bp_site->GetOwnerAtIndex (0));
+            if (bp_loc_sp)
+            {
+                const AddressClass addr_class = bp_loc_sp->GetAddress().GetAddressClass ();
+                if (addr_class == eAddressClassCodeAlternateISA)
+                {
+                    trap_opcode = g_thumb_breakpooint_opcode;
+                    trap_opcode_size = sizeof(g_thumb_breakpooint_opcode);
+                    break;
+                }
+            }
+            trap_opcode = g_arm_breakpoint_opcode;
+            trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
+        }
+        break;
+        
+    case llvm::Triple::ppc:
+    case llvm::Triple::ppc64:
+        {
+            static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
+            trap_opcode = g_ppc_breakpoint_opcode;
+            trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
+        }
+        break;
+        
+    default:
+        assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()");
+        break;
+    }
+    
+    if (trap_opcode && trap_opcode_size)
+    {
+        if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
+            return trap_opcode_size;
+    }
+    return 0;
+
+}

Added: lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h?rev=127934&view=auto
==============================================================================
--- lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h (added)
+++ lldb/trunk/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h Fri Mar 18 20:12:21 2011
@@ -0,0 +1,123 @@
+//===-- PlatformRemoteiOS.h ----------------------------------------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef liblldb_PlatformRemoteiOS_h_
+#define liblldb_PlatformRemoteiOS_h_
+
+// C Includes
+// C++ Includes
+// Other libraries and framework includes
+// Project includes
+#include "lldb/Target/Platform.h"
+
+namespace lldb_private {
+
+    class PlatformRemoteiOS : public Platform
+    {
+    public:
+
+        static Platform* 
+        CreateInstance ();
+
+        static void
+        Initialize ();
+
+        static void
+        Terminate ();
+        
+        PlatformRemoteiOS ();
+
+        virtual
+        ~PlatformRemoteiOS();
+
+        //------------------------------------------------------------
+        // lldb_private::PluginInterface functions
+        //------------------------------------------------------------
+        
+        static const char *
+        GetPluginNameStatic ();
+
+        static const char *
+        GetShortPluginNameStatic();
+
+        static const char *
+        GetDescriptionStatic();
+
+        virtual const char *
+        GetPluginName()
+        {
+            return GetPluginNameStatic();
+        }
+        
+        virtual const char *
+        GetShortPluginName()
+        {
+            return GetShortPluginNameStatic();
+        }
+        
+        virtual uint32_t
+        GetPluginVersion()
+        {
+            return 1;
+        }
+
+        //------------------------------------------------------------
+        // lldb_private::Platform functions
+        //------------------------------------------------------------
+        virtual Error
+        ResolveExecutable (const FileSpec &exe_file,
+                           const ArchSpec &arch,
+                           lldb::ModuleSP &module_sp);
+
+        virtual const char *
+        GetDescription ()
+        {
+            return GetDescriptionStatic();
+        }
+
+        virtual void
+        GetStatus (Stream &strm);
+
+        virtual Error
+        GetFile (const FileSpec &platform_file, FileSpec &local_file);
+
+        virtual uint32_t
+        FindProcessesByName (const char *name_match, 
+                             lldb::NameMatchType name_match_type,
+                             ProcessInfoList &process_infos);
+
+        virtual bool
+        GetProcessInfo (lldb::pid_t pid, ProcessInfo &proc_info);
+
+        virtual bool
+        GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch);
+
+        virtual size_t
+        GetSoftwareBreakpointTrapOpcode (Target &target, 
+                                         BreakpointSite *bp_site);
+
+    protected:
+        std::string m_device_support_directory;
+        std::string m_device_support_directory_for_os_version;
+        std::string m_build_update;
+        //std::vector<FileSpec> m_device_support_os_dirs;
+        
+        const char *
+        GetDeviceSupportDirectory();
+
+        const char *
+        GetDeviceSupportDirectoryForOSVersion();
+
+    private:
+        DISALLOW_COPY_AND_ASSIGN (PlatformRemoteiOS);
+
+    };
+} // namespace lldb_private
+
+#endif  // liblldb_Platform_h_

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp Fri Mar 18 20:12:21 2011
@@ -183,7 +183,7 @@
 const char *
 ProcessMacOSX::GetPluginNameStatic()
 {
-    return "process.macosx";
+    return "macosx-user";
 }
 
 const char *
@@ -455,52 +455,6 @@
     return error;
 }
 
-size_t
-ProcessMacOSX::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
-{
-    const uint8_t *trap_opcode = NULL;
-    uint32_t trap_opcode_size = 0;
-
-    static const uint8_t g_arm_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
-    //static const uint8_t g_thumb_breakpooint_opcode[] = { 0xFE, 0xDE };
-    static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
-    static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
-
-    llvm::Triple::ArchType machine = m_arch_spec.GetMachine();
-    switch (machine)
-    {
-    case llvm::Triple::x86:
-    case llvm::Triple::x86_64:
-        trap_opcode = g_i386_breakpoint_opcode;
-        trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
-        break;
-    
-    case llvm::Triple::arm:
-        // TODO: fill this in for ARM. We need to dig up the symbol for
-        // the address in the breakpoint locaiton and figure out if it is
-        // an ARM or Thumb breakpoint.
-        trap_opcode = g_arm_breakpoint_opcode;
-        trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
-        break;
-    
-    case llvm::Triple::ppc:
-    case llvm::Triple::ppc64:
-        trap_opcode = g_ppc_breakpoint_opcode;
-        trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
-        break;
-
-    default:
-        assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()");
-        break;
-    }
-
-    if (trap_opcode && trap_opcode_size)
-    {
-        if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
-            return trap_opcode_size;
-    }
-    return 0;
-}
 uint32_t
 ProcessMacOSX::UpdateThreadListIfNeeded ()
 {

Modified: lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h (original)
+++ lldb/trunk/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h Fri Mar 18 20:12:21 2011
@@ -192,12 +192,6 @@
     //----------------------------------------------------------------------
     // Process Breakpoints
     //----------------------------------------------------------------------
-    virtual size_t
-    GetSoftwareBreakpointTrapOpcode (lldb_private::BreakpointSite *bp_site);
-
-    //----------------------------------------------------------------------
-    // Process Breakpoints
-    //----------------------------------------------------------------------
     virtual lldb_private::Error
     EnableBreakpoint (lldb_private::BreakpointSite *bp_site);
 

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp Fri Mar 18 20:12:21 2011
@@ -63,7 +63,7 @@
 const char *
 ProcessGDBRemote::GetPluginNameStatic()
 {
-    return "process.gdb-remote";
+    return "gdb-remote";
 }
 
 const char *
@@ -1025,53 +1025,6 @@
     return error;
 }
 
-size_t
-ProcessGDBRemote::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
-{
-    const uint8_t *trap_opcode = NULL;
-    uint32_t trap_opcode_size = 0;
-
-    static const uint8_t g_arm_breakpoint_opcode[] = { 0xFE, 0xDE, 0xFF, 0xE7 };
-    //static const uint8_t g_thumb_breakpooint_opcode[] = { 0xFE, 0xDE };
-    static const uint8_t g_ppc_breakpoint_opcode[] = { 0x7F, 0xC0, 0x00, 0x08 };
-    static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC };
-
-    const llvm::Triple::ArchType machine = GetTarget().GetArchitecture().GetMachine();
-    switch (machine)
-    {
-    case llvm::Triple::x86:
-    case llvm::Triple::x86_64:
-        trap_opcode = g_i386_breakpoint_opcode;
-        trap_opcode_size = sizeof(g_i386_breakpoint_opcode);
-        break;
-    
-    case llvm::Triple::arm:
-        // TODO: fill this in for ARM. We need to dig up the symbol for
-        // the address in the breakpoint locaiton and figure out if it is
-        // an ARM or Thumb breakpoint.
-        trap_opcode = g_arm_breakpoint_opcode;
-        trap_opcode_size = sizeof(g_arm_breakpoint_opcode);
-        break;
-    
-    case llvm::Triple::ppc:
-    case llvm::Triple::ppc64:
-        trap_opcode = g_ppc_breakpoint_opcode;
-        trap_opcode_size = sizeof(g_ppc_breakpoint_opcode);
-        break;
-
-    default:
-        assert(!"Unhandled architecture in ProcessMacOSX::GetSoftwareBreakpointTrapOpcode()");
-        break;
-    }
-
-    if (trap_opcode && trap_opcode_size)
-    {
-        if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size))
-            return trap_opcode_size;
-    }
-    return 0;
-}
-
 uint32_t
 ProcessGDBRemote::UpdateThreadListIfNeeded ()
 {

Modified: lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h (original)
+++ lldb/trunk/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h Fri Mar 18 20:12:21 2011
@@ -189,12 +189,6 @@
     //----------------------------------------------------------------------
     // Process Breakpoints
     //----------------------------------------------------------------------
-    virtual size_t
-    GetSoftwareBreakpointTrapOpcode (lldb_private::BreakpointSite *bp_site);
-
-    //----------------------------------------------------------------------
-    // Process Breakpoints
-    //----------------------------------------------------------------------
     virtual lldb_private::Error
     EnableBreakpoint (lldb_private::BreakpointSite *bp_site);
 

Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
+++ lldb/trunk/source/Symbol/ObjectFile.cpp Fri Mar 18 20:12:21 2011
@@ -102,3 +102,88 @@
     return m_module->SetArchitecture (new_arch);
 }
 
+lldb::AddressClass
+ObjectFile::GetAddressClass (lldb::addr_t file_addr)
+{
+    Symtab *symtab = GetSymtab();
+    if (symtab)
+    {
+        Symbol *symbol = symtab->FindSymbolContainingFileAddress(file_addr);
+        if (symbol)
+        {
+            const AddressRange *range_ptr = symbol->GetAddressRangePtr();
+            if (range_ptr)
+            {
+                const Section *section = range_ptr->GetBaseAddress().GetSection();
+                if (section)
+                {
+                    const lldb::SectionType section_type = section->GetType();
+                    switch (section_type)
+                    {
+                    case eSectionTypeInvalid:               return eAddressClassUnknown;
+                    case eSectionTypeCode:                  return eAddressClassCode;
+                    case eSectionTypeContainer:             return eAddressClassUnknown;
+                    case eSectionTypeData:                  return eAddressClassData;
+                    case eSectionTypeDataCString:           return eAddressClassDataConst;
+                    case eSectionTypeDataCStringPointers:   return eAddressClassData;
+                    case eSectionTypeDataSymbolAddress:     return eAddressClassData;
+                    case eSectionTypeData4:                 return eAddressClassData;
+                    case eSectionTypeData8:                 return eAddressClassData;
+                    case eSectionTypeData16:                return eAddressClassData;
+                    case eSectionTypeDataPointers:          return eAddressClassData;
+                    case eSectionTypeZeroFill:              return eAddressClassData;
+                    case eSectionTypeDataObjCMessageRefs:   return eAddressClassDataConst;
+                    case eSectionTypeDataObjCCFStrings:     return eAddressClassDataConst;
+                    case eSectionTypeDebug:                 return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugAbbrev:      return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugAranges:     return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugFrame:       return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugInfo:        return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugLine:        return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugLoc:         return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugMacInfo:     return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugPubNames:    return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugPubTypes:    return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugRanges:      return eAddressClassDebug;
+                    case eSectionTypeDWARFDebugStr:         return eAddressClassDebug;
+                    case eSectionTypeEHFrame:               return eAddressClassRuntime;
+                    case eSectionTypeOther:                 return eAddressClassUnknown;
+                    }
+                }
+            }
+            
+            const lldb::SymbolType symbol_type = symbol->GetType();
+            switch (symbol_type)
+            {
+            case eSymbolTypeAny:            return eAddressClassUnknown;
+            case eSymbolTypeAbsolute:       return eAddressClassUnknown;
+            case eSymbolTypeExtern:         return eAddressClassUnknown;
+            case eSymbolTypeCode:           return eAddressClassCode;
+            case eSymbolTypeTrampoline:     return eAddressClassCode;
+            case eSymbolTypeData:           return eAddressClassData;
+            case eSymbolTypeRuntime:        return eAddressClassRuntime;
+            case eSymbolTypeException:      return eAddressClassRuntime;
+            case eSymbolTypeSourceFile:     return eAddressClassDebug;
+            case eSymbolTypeHeaderFile:     return eAddressClassDebug;
+            case eSymbolTypeObjectFile:     return eAddressClassDebug;
+            case eSymbolTypeCommonBlock:    return eAddressClassDebug;
+            case eSymbolTypeBlock:          return eAddressClassDebug;
+            case eSymbolTypeLocal:          return eAddressClassData;
+            case eSymbolTypeParam:          return eAddressClassData;
+            case eSymbolTypeVariable:       return eAddressClassData;
+            case eSymbolTypeVariableType:   return eAddressClassDebug;
+            case eSymbolTypeLineEntry:      return eAddressClassDebug;
+            case eSymbolTypeLineHeader:     return eAddressClassDebug;
+            case eSymbolTypeScopeBegin:     return eAddressClassDebug;
+            case eSymbolTypeScopeEnd:       return eAddressClassDebug;
+            case eSymbolTypeAdditional:     return eAddressClassUnknown;
+            case eSymbolTypeCompiler:       return eAddressClassDebug;
+            case eSymbolTypeInstrumentation:return eAddressClassDebug;
+            case eSymbolTypeUndefined:      return eAddressClassUnknown;
+            }
+        }
+    }
+    return eAddressClassUnknown;
+}
+
+

Modified: lldb/trunk/source/Target/Platform.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Platform.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Target/Platform.cpp (original)
+++ lldb/trunk/source/Target/Platform.cpp Fri Mar 18 20:12:21 2011
@@ -16,6 +16,7 @@
 #include "lldb/Core/Error.h"
 #include "lldb/Core/PluginManager.h"
 #include "lldb/Host/FileSpec.h"
+#include "lldb/Host/Host.h"
 #include "lldb/Target/Target.h"
 
 using namespace lldb;
@@ -30,13 +31,6 @@
     return g_default_platform_sp;
 }
 
-static PlatformSP&
-GetSelectedPlatformSP ()
-{
-    static PlatformSP g_selected_platform_sp;
-    return g_selected_platform_sp;
-}
-
 static Mutex &
 GetConnectedPlatformListMutex ()
 {
@@ -74,24 +68,6 @@
     GetDefaultPlatformSP () = platform_sp;
 }
 
-PlatformSP
-Platform::GetSelectedPlatform ()
-{
-    PlatformSP platform_sp (GetSelectedPlatformSP ());
-    if (!platform_sp)
-        platform_sp = GetDefaultPlatform (); 
-    return platform_sp;
-}
-
-void
-Platform::SetSelectedPlatform (const lldb::PlatformSP &platform_sp)
-{
-    // The native platform should use its static void Platform::Initialize()
-    // function to register itself as the native platform.
-    GetSelectedPlatformSP () = platform_sp;
-}
-
-
 Error
 Platform::GetFile (const FileSpec &platform_file, FileSpec &local_file)
 {
@@ -102,26 +78,20 @@
 
 
 PlatformSP
-Platform::ConnectRemote (const char *platform_name, const char *remote_connect_url, Error &error)
+Platform::Create (const char *platform_name, Error &error)
 {
     PlatformCreateInstance create_callback = NULL;
     lldb::PlatformSP platform_sp;
-    if (platform_name)
+    if (platform_name && platform_name[0])
     {
         create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (platform_name);
         if (create_callback)
-        {
             platform_sp.reset(create_callback());
-            if (platform_sp)
-                error = platform_sp->ConnectRemote (remote_connect_url);
-            else
-                error.SetErrorStringWithFormat ("unable to create a platform instance of \"%s\"", platform_name);
-        }
         else
-            error.SetErrorStringWithFormat ("invalid platform name \"%s\"", platform_name);
+            error.SetErrorStringWithFormat ("unable to find a plug-in for the platform named \"%s\"", platform_name);
     }
     else
-        error.SetErrorString ("Empty platform name");
+        error.SetErrorString ("invalid platform name");
     return platform_sp;
 }
 
@@ -147,8 +117,15 @@
 //------------------------------------------------------------------
 /// Default Constructor
 //------------------------------------------------------------------
-Platform::Platform () :
-    m_remote_url ()
+Platform::Platform (bool is_host) :
+    m_is_host (is_host),
+    m_is_connected (is_host), // If this is the default host platform, then we are always connected
+    m_os_version_set_while_connected (false),
+    m_system_arch_set_while_connected (false),
+    m_remote_url (),
+    m_major_os_version (UINT32_MAX),
+    m_minor_os_version (UINT32_MAX),
+    m_update_os_version (UINT32_MAX)
 {
 }
 
@@ -162,6 +139,98 @@
 {
 }
 
+
+bool
+Platform::GetOSVersion (uint32_t &major, 
+                        uint32_t &minor, 
+                        uint32_t &update)
+{
+    bool success = m_major_os_version != UINT32_MAX;
+    if (IsHost())
+    {
+        if (!success)
+        {
+            // We have a local host platform
+            success = Host::GetOSVersion (m_major_os_version, 
+                                          m_minor_os_version, 
+                                          m_update_os_version);
+            m_os_version_set_while_connected = success;
+        }
+    }
+    else 
+    {
+        // We have a remote platform. We can only fetch the remote
+        // OS version if we are connected, and we don't want to do it
+        // more than once.
+        
+        const bool is_connected = IsConnected();
+
+        bool fetch_os_version = false;
+        if (success)
+        {
+            // We have valid OS version info, check to make sure it wasn't
+            // manually set prior to connecting. If it was manually set prior
+            // to connecting, then lets fetch the actual OS version info
+            // if we are now connected.
+            if (is_connected && !m_os_version_set_while_connected)
+                fetch_os_version = true;
+        }
+        else
+        {
+            // We don't have valid OS version info, fetch it if we are connected
+            fetch_os_version = is_connected;
+        }
+
+        if (fetch_os_version)
+        {
+            success = FetchRemoteOSVersion ();
+            m_os_version_set_while_connected = success;
+        }
+    }
+
+    if (success)
+    {
+        major = m_major_os_version;
+        minor = m_minor_os_version;
+        update = m_update_os_version;
+    }
+    return success;
+}
+   
+bool
+Platform::SetOSVersion (uint32_t major, 
+                        uint32_t minor, 
+                        uint32_t update)
+{
+    if (IsHost())
+    {
+        // We don't need anyone setting the OS version for the host platform, 
+        // we should be able to figure it out by calling Host::GetOSVersion(...).
+        return false; 
+    }
+    else
+    {
+        // We have a remote platform, allow setting the target OS version if
+        // we aren't connected, since if we are connected, we should be able to
+        // request the remote OS version from the connected platform.
+        if (IsConnected())
+            return false;
+        else
+        {
+            // We aren't connected and we might want to set the OS version
+            // ahead of time before we connect so we can peruse files and
+            // use a local SDK or PDK cache of support files to disassemble
+            // or do other things.
+            m_major_os_version = major;
+            m_minor_os_version = minor;
+            m_update_os_version = update;
+            return true;
+        }
+    }
+    return false;
+}
+
+
 Error
 Platform::ResolveExecutable (const FileSpec &exe_file,
                              const ArchSpec &exe_arch,
@@ -213,6 +282,53 @@
     return error;
 }
 
+
+const ArchSpec &
+Platform::GetSystemArchitecture()
+{
+    if (IsHost())
+    {
+        if (!m_system_arch.IsValid())
+        {
+            // We have a local host platform
+            m_system_arch = Host::GetArchitecture();
+            m_system_arch_set_while_connected = m_system_arch.IsValid();
+        }
+    }
+    else 
+    {
+        // We have a remote platform. We can only fetch the remote
+        // system architecture if we are connected, and we don't want to do it
+        // more than once.
+        
+        const bool is_connected = IsConnected();
+
+        bool fetch = false;
+        if (m_system_arch.IsValid())
+        {
+            // We have valid OS version info, check to make sure it wasn't
+            // manually set prior to connecting. If it was manually set prior
+            // to connecting, then lets fetch the actual OS version info
+            // if we are now connected.
+            if (is_connected && !m_system_arch_set_while_connected)
+                fetch = true;
+        }
+        else
+        {
+            // We don't have valid OS version info, fetch it if we are connected
+            fetch = is_connected;
+        }
+
+        if (fetch)
+        {
+            m_system_arch = FetchRemoteSystemArchitecture ();
+            m_system_arch_set_while_connected = m_system_arch.IsValid();
+        }
+    }
+    return m_system_arch;
+}
+
+
 Error
 Platform::ConnectRemote (const char *remote_url)
 {

Modified: lldb/trunk/source/Target/Process.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Process.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Target/Process.cpp (original)
+++ lldb/trunk/source/Target/Process.cpp Fri Mar 18 20:12:21 2011
@@ -1037,6 +1037,16 @@
 }
 
 
+
+size_t
+Process::GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site)
+{
+    PlatformSP platform_sp (m_target.GetPlatform());
+    if (platform_sp)
+        return platform_sp->GetSoftwareBreakpointTrapOpcode (m_target, bp_site);
+    return 0;
+}
+
 Error
 Process::EnableSoftwareBreakpoint (BreakpointSite *bp_site)
 {
@@ -1661,7 +1671,7 @@
     // of the current Target, and if not adjust it.
     
     ProcessInfo process_info;
-    PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+    PlatformSP platform_sp (m_target.GetDebugger().GetPlatformList().GetSelectedPlatform ());
     if (platform_sp)
     {
         if (platform_sp->GetProcessInfo (attach_pid, process_info))
@@ -1714,7 +1724,7 @@
     if (!wait_for_launch)
     {
         ProcessInfoList process_infos;
-        PlatformSP platform_sp (Platform::GetSelectedPlatform ());
+        PlatformSP platform_sp (m_target.GetDebugger().GetPlatformList().GetSelectedPlatform ());
         if (platform_sp)
         {
             platform_sp->FindProcessesByName (process_name, eNameMatchEquals, process_infos);

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Fri Mar 18 20:12:21 2011
@@ -39,8 +39,9 @@
 //----------------------------------------------------------------------
 // Target constructor
 //----------------------------------------------------------------------
-Target::Target(Debugger &debugger) :
+Target::Target(Debugger &debugger, const lldb::PlatformSP &platform_sp) :
     Broadcaster("lldb.target"),
+    m_platform_sp (platform_sp),
     TargetInstanceSettings (*GetSettingsController()),
     m_debugger (debugger),
     m_mutex (Mutex::eMutexTypeRecursive), 
@@ -418,33 +419,21 @@
         
         FileSpecList dependent_files;
         ObjectFile *executable_objfile = executable_sp->GetObjectFile();
-        assert (executable_objfile);
-        // TODO: remote assertion above after verifying that it doesn't fire off
-        // after the platform changes. The platform is what should be selecting
-        // the right slice of an executable file, and it also should be the one
-        // to resolve any executables in their bundles.
-//        if (executable_objfile == NULL)
-//        {
-//
-//            FileSpec bundle_executable(executable_sp->GetFileSpec());
-//            if (Host::ResolveExecutableInBundle (bundle_executable))
-//            {
-//                ModuleSP bundle_exe_module_sp(GetSharedModule(bundle_executable,
-//                                                              exe_arch));
-//                SetExecutableModule (bundle_exe_module_sp, get_dependent_files);
-//                if (bundle_exe_module_sp->GetObjectFile() != NULL)
-//                    executable_sp = bundle_exe_module_sp;
-//                return;
-//            }
-//        }
 
         if (executable_objfile)
         {
             executable_objfile->GetDependentModules(dependent_files);
             for (uint32_t i=0; i<dependent_files.GetSize(); i++)
             {
-                ModuleSP image_module_sp(GetSharedModule(dependent_files.GetFileSpecPointerAtIndex(i),
-                                                         exe_arch));
+                FileSpec dependent_file_spec (dependent_files.GetFileSpecPointerAtIndex(i));
+                FileSpec platform_dependent_file_spec;
+                if (m_platform_sp)
+                    m_platform_sp->GetFile (dependent_file_spec, platform_dependent_file_spec);
+                else
+                    platform_dependent_file_spec = dependent_file_spec;
+
+                ModuleSP image_module_sp(GetSharedModule (platform_dependent_file_spec,
+                                                          exe_arch));
                 if (image_module_sp.get())
                 {
                     //image_module_sp->Dump(&s);// REMOVE THIS, DEBUG ONLY

Modified: lldb/trunk/source/Target/TargetList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/TargetList.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/Target/TargetList.cpp (original)
+++ lldb/trunk/source/Target/TargetList.cpp Fri Mar 18 20:12:21 2011
@@ -12,6 +12,7 @@
 // Other libraries and framework includes
 // Project includes
 #include "lldb/Core/Broadcaster.h"
+#include "lldb/Core/Debugger.h"
 #include "lldb/Core/Event.h"
 #include "lldb/Core/State.h"
 #include "lldb/Core/Timer.h"
@@ -60,6 +61,8 @@
                         file.GetFilename().AsCString(),
                         arch.GetArchitectureName());
     Error error;
+
+    PlatformSP platform_sp (debugger.GetPlatformList().GetSelectedPlatform ());
     
     if (file)
     {
@@ -67,7 +70,6 @@
         FileSpec resolved_file(file);
         ArchSpec platform_arch;
         
-        PlatformSP platform_sp (Platform::GetSelectedPlatform ());
         if (platform_sp)
             error = platform_sp->ResolveExecutable (file, arch, exe_module_sp);
 
@@ -92,7 +94,7 @@
                 }
                 return error;
             }
-            target_sp.reset(new Target(debugger));
+            target_sp.reset(new Target(debugger, platform_sp));
             target_sp->SetExecutableModule (exe_module_sp, get_dependent_files);
         }
     }
@@ -100,7 +102,7 @@
     {
         // No file was specified, just create an empty target with any arch
         // if a valid arch was specified
-        target_sp.reset(new Target(debugger));
+        target_sp.reset(new Target(debugger, platform_sp));
         if (arch.IsValid())
             target_sp->SetArchitecture(arch);
     }

Modified: lldb/trunk/source/lldb.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/lldb.cpp?rev=127934&r1=127933&r2=127934&view=diff
==============================================================================
--- lldb/trunk/source/lldb.cpp (original)
+++ lldb/trunk/source/lldb.cpp Fri Mar 18 20:12:21 2011
@@ -46,6 +46,7 @@
 #include "Plugins/Process/MacOSX-User/source/ProcessMacOSX.h"
 #include "Plugins/Process/gdb-remote/ProcessGDBRemote.h"
 #include "Plugins/Platform/MacOSX/PlatformMacOSX.h"
+#include "Plugins/Platform/MacOSX/PlatformRemoteiOS.h"
 #endif
 
 #if defined (__linux__)
@@ -100,6 +101,7 @@
         //ProcessMacOSX::Initialize();
         SymbolVendorMacOSX::Initialize();
         PlatformMacOSX::Initialize();
+        PlatformRemoteiOS::Initialize();
 #endif
 #if defined (__linux__)
         PlatformLinux::Initialize();
@@ -154,6 +156,7 @@
     //ProcessMacOSX::Terminate();
     SymbolVendorMacOSX::Terminate();
     PlatformMacOSX::Terminate();
+    PlatformRemoteiOS::Terminate();
 #endif
 
     Debugger::SettingsTerminate ();





More information about the lldb-commits mailing list