diff options
| author | Greg Clayton <gclayton@apple.com> | 2011-03-19 01:12:21 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2011-03-19 01:12:21 +0000 |
| commit | ded470d31aa3a3b1c6b06fc8ae191d210ae089d5 (patch) | |
| tree | 57af3b30c78261da0625d9ed4def8ccb212dc078 | |
| parent | 5366ff18659c58ac54ab55db5c6f3cf5d0e01034 (diff) | |
| download | bcm5719-llvm-ded470d31aa3a3b1c6b06fc8ae191d210ae089d5.tar.gz bcm5719-llvm-ded470d31aa3a3b1c6b06fc8ae191d210ae089d5.zip | |
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.
llvm-svn: 127934
44 files changed, 2086 insertions, 382 deletions
diff --git a/lldb/include/lldb/Core/Address.h b/lldb/include/lldb/Core/Address.h index 01f036216c6..c26e80e2c0c 100644 --- a/lldb/include/lldb/Core/Address.h +++ b/lldb/include/lldb/Core/Address.h @@ -246,6 +246,9 @@ public: DumpStyle fallback_style = DumpStyleInvalid, uint32_t addr_byte_size = UINT32_MAX) const; + lldb::AddressClass + GetAddressClass () const; + //------------------------------------------------------------------ /// Get the file address. /// diff --git a/lldb/include/lldb/Core/ArchSpec.h b/lldb/include/lldb/Core/ArchSpec.h index 69fff9fb2fa..98413c0eab9 100644 --- a/lldb/include/lldb/Core/ArchSpec.h +++ b/lldb/include/lldb/Core/ArchSpec.h @@ -43,6 +43,9 @@ public: eCore_arm_armv5t, eCore_arm_armv6, eCore_arm_armv7, + eCore_arm_armv7f, + eCore_arm_armv7k, + eCore_arm_armv7s, eCore_arm_xscale, eCore_ppc_generic, diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 06e5b90b9dc..de0a91d0f59 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -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 @@ public: } 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 @@ public: /// @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 @@ protected: 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; diff --git a/lldb/include/lldb/Host/Host.h b/lldb/include/lldb/Host/Host.h index a1c85fe4250..cbb573df82a 100644 --- a/lldb/include/lldb/Host/Host.h +++ b/lldb/include/lldb/Host/Host.h @@ -96,6 +96,11 @@ public: static lldb::ByteOrder GetByteOrder (); + static bool + GetOSVersion (uint32_t &major, + uint32_t &minor, + uint32_t &update); + //------------------------------------------------------------------ /// Gets the host architecture. /// diff --git a/lldb/include/lldb/Interpreter/Args.h b/lldb/include/lldb/Interpreter/Args.h index 1f1b92b924a..5e5dafc0a2c 100644 --- a/lldb/include/lldb/Interpreter/Args.h +++ b/lldb/include/lldb/Interpreter/Args.h @@ -357,6 +357,9 @@ public: 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 diff --git a/lldb/include/lldb/Symbol/ObjectFile.h b/lldb/include/lldb/Symbol/ObjectFile.h index 5631bfc35dd..2b011525d0d 100644 --- a/lldb/include/lldb/Symbol/ObjectFile.h +++ b/lldb/include/lldb/Symbol/ObjectFile.h @@ -143,6 +143,23 @@ public: 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 diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index f878666a887..5ac7b3d519a 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -58,44 +58,19 @@ namespace lldb_private { 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 @@ namespace lldb_private { 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 @@ namespace lldb_private { /// @return /// An error object. //------------------------------------------------------------------ +public: virtual Error GetFile (const FileSpec &platform_file, FileSpec &local_file); @@ -176,6 +190,10 @@ namespace lldb_private { 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 @@ namespace lldb_private { 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 @@ namespace lldb_private { } 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 @@ namespace lldb_private { 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); diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index f995c56c648..f5797d0b686 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1726,8 +1726,8 @@ public: //---------------------------------------------------------------------- // Process Breakpoints //---------------------------------------------------------------------- - virtual size_t - GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site) = 0; + size_t + GetSoftwareBreakpointTrapOpcode (BreakpointSite* bp_site); virtual Error EnableBreakpoint (BreakpointSite *bp_site) = 0; diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index df3f02bc4b3..497308578f7 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -101,7 +101,6 @@ public: m_execution_os_type = execution_os_type; } - protected: void @@ -175,7 +174,7 @@ private: /// /// @see TargetList::CreateTarget(const FileSpec*, const ArchSpec*) //------------------------------------------------------------------ - Target(Debugger &debugger); + Target(Debugger &debugger, const lldb::PlatformSP &platform_sp); public: ~Target(); @@ -641,6 +640,12 @@ public: return (*pos).second; } + lldb::PlatformSP + GetPlatform () + { + return m_platform_sp; + } + //------------------------------------------------------------------ // Target::SettingsController //------------------------------------------------------------------ @@ -694,6 +699,7 @@ protected: // 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). diff --git a/lldb/include/lldb/lldb-enumerations.h b/lldb/include/lldb/lldb-enumerations.h index d4454b74bb0..08f31c34d8c 100644 --- a/lldb/include/lldb/lldb-enumerations.h +++ b/lldb/include/lldb/lldb-enumerations.h @@ -77,6 +77,21 @@ typedef enum AddressType 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 //---------------------------------------------------------------------- diff --git a/lldb/include/lldb/lldb-forward.h b/lldb/include/lldb/lldb-forward.h index 9e916c916c0..3d23afafef7 100644 --- a/lldb/include/lldb/lldb-forward.h +++ b/lldb/include/lldb/lldb-forward.h @@ -65,7 +65,6 @@ class DWARFExpression; class DataBuffer; class DataExtractor; class Debugger; -class Debugger; class Declaration; class Disassembler; class DynamicLoader; diff --git a/lldb/lldb.xcodeproj/project.pbxproj b/lldb/lldb.xcodeproj/project.pbxproj index 702964cfc9c..535dfa09fda 100644 --- a/lldb/lldb.xcodeproj/project.pbxproj +++ b/lldb/lldb.xcodeproj/project.pbxproj @@ -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", diff --git a/lldb/source/Breakpoint/Breakpoint.cpp b/lldb/source/Breakpoint/Breakpoint.cpp index 7f404585429..0709c187b1d 100644 --- a/lldb/source/Breakpoint/Breakpoint.cpp +++ b/lldb/source/Breakpoint/Breakpoint.cpp @@ -412,7 +412,7 @@ Breakpoint::GetDescription (Stream *s, lldb::DescriptionLevel level, bool show_l // Verbose mode does a debug dump of the breakpoint Dump (s); s->EOL (); - s->Indent(); + //s->Indent(); GetOptions()->GetDescription(s, level); break; diff --git a/lldb/source/Breakpoint/BreakpointLocationList.cpp b/lldb/source/Breakpoint/BreakpointLocationList.cpp index b4fcc586612..89742a60901 100644 --- a/lldb/source/Breakpoint/BreakpointLocationList.cpp +++ b/lldb/source/Breakpoint/BreakpointLocationList.cpp @@ -133,7 +133,7 @@ void 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(); diff --git a/lldb/source/Breakpoint/BreakpointSiteList.cpp b/lldb/source/Breakpoint/BreakpointSiteList.cpp index 155c8a7d7bc..f3f10f06ed7 100644 --- a/lldb/source/Breakpoint/BreakpointSiteList.cpp +++ b/lldb/source/Breakpoint/BreakpointSiteList.cpp @@ -168,7 +168,7 @@ void 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; diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 1616eccf145..0bc30f43e40 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -319,7 +319,8 @@ public: 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 @@ public: flat_output = false; max_depth = UINT32_MAX; ptr_depth = 0; + format = eFormatDefault; globals.clear(); } @@ -393,6 +395,7 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ CommandObjectFrameVariable::CommandOptions::g_option_table[] = { 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 diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp new file mode 100644 index 00000000000..97eb0a4e5fc --- /dev/null +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -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() +{ +} diff --git a/lldb/source/Commands/CommandObjectPlatform.h b/lldb/source/Commands/CommandObjectPlatform.h new file mode 100644 index 00000000000..994052e6001 --- /dev/null +++ b/lldb/source/Commands/CommandObjectPlatform.h @@ -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_ diff --git a/lldb/source/Commands/CommandObjectProcess.cpp b/lldb/source/Commands/CommandObjectProcess.cpp index 0dbc9b82873..ece8fe10aaf 100644 --- a/lldb/source/Commands/CommandObjectProcess.cpp +++ b/lldb/source/Commands/CommandObjectProcess.cpp @@ -523,7 +523,7 @@ public: 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 @@ public: 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); diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index 67d2c2ea304..12de3aaaeb0 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -808,3 +808,16 @@ Address::ResolveLinkedAddress () } } } + +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; +} diff --git a/lldb/source/Core/ArchSpec.cpp b/lldb/source/Core/ArchSpec.cpp index f15f02a2ad6..512b5f030de 100644 --- a/lldb/source/Core/ArchSpec.cpp +++ b/lldb/source/Core/ArchSpec.cpp @@ -49,6 +49,9 @@ static const CoreDefinition g_core_definitions[ArchSpec::kNumCores] = { 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 @@ static const ArchDefinitionEntry g_macho_arch_entries[] = { 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 }, diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 0718a2de67f..89ceab95006 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -225,6 +225,7 @@ Debugger::Debugger () : 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 @@ Debugger::Debugger () : { 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 @@ Debugger::SetAsyncExecution (bool async_execution) 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 @@ Debugger::SetErrorFileHandle (FILE *fh, bool tranfer_ownership) 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 @@ Debugger::GetSelectedExecutionContext () } -SourceManager & -Debugger::GetSourceManager () -{ - return m_source_manager; -} - - -TargetList& -Debugger::GetTargetList () -{ - return m_target_list; -} - InputReaderSP Debugger::GetCurrentInputReader () { diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index 12bb4868652..b7ee57dc991 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -226,50 +226,19 @@ struct ABIInstance 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 @@ PluginManager::RegisterPlugin 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 @@ PluginManager::UnregisterPlugin (ABICreateInstance create_callback) { 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 @@ PluginManager::UnregisterPlugin (ABICreateInstance create_callback) 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 @@ PluginManager::GetABICreateCallbackForPluginName (const char *name) { 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 @@ struct PlatformInstance 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 @@ PluginManager::RegisterPlugin (const char *name, { 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 @@ PluginManager::RegisterPlugin (const char *name, 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 @@ PluginManager::UnregisterPlugin (PlatformCreateInstance create_callback) { 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 @@ PluginManager::UnregisterPlugin (PlatformCreateInstance create_callback) 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 @@ PluginManager::GetPlatformCreateCallbackForPluginName (const char *name) { 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; diff --git a/lldb/source/Host/macosx/Host.mm b/lldb/source/Host/macosx/Host.mm index e7df53dd9d9..a537c67937a 100644 --- a/lldb/source/Host/macosx/Host.mm +++ b/lldb/source/Host/macosx/Host.mm @@ -830,3 +830,48 @@ Host::GetEnvironment (StringList &env) 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; + +} + + diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index e0c04f467c9..d278873b813 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -754,6 +754,47 @@ Args::StringToBoolean (const char *s, bool fail_value, bool *success_ptr) 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) { diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp index 461c54383ac..6f1c74fde9e 100644 --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -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 @@ CommandInterpreter::LoadCommandDictionary () 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)); diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp index 9f2ddd845e7..3b10a343209 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.cpp @@ -31,8 +31,8 @@ using namespace lldb; 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 @@ static int IPRegisterReader(uint64_t *value, unsigned regID, void* arg) 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::CreateInstance(const ArchSpec &arch) 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 @@ DisassemblerLLVM::DecodeInstructions { 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); diff --git a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h index 69ac743fcf2..842c03d5dcd 100644 --- a/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h +++ b/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVM.h @@ -100,6 +100,7 @@ protected: } EDDisassemblerRef m_disassembler; + EDDisassemblerRef m_disassembler_thumb; }; #endif // liblldb_DisassemblerLLVM_h_ diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 56d3daf6d5e..72c21fede3a 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -29,6 +29,7 @@ using namespace lldb; using namespace lldb_private; using namespace llvm::MachO; +#define MACHO_NLIST_ARM_SYMBOL_IS_THUMB 0x0008 void ObjectFileMachO::Initialize() @@ -201,6 +202,108 @@ ObjectFileMachO::GetAddressByteSize () const 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() diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h index c079fe419de..bd25062c38e 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h @@ -74,6 +74,9 @@ public: virtual size_t GetAddressByteSize () const; + virtual lldb::AddressClass + GetAddressClass (lldb::addr_t file_addr); + virtual lldb_private::Symtab * GetSymtab(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp index b1df7ba6bb8..8c1ef1d5c9d 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -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 @@ PlatformMacOSX::Initialize () { #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 @@ PlatformMacOSX::Terminate () { } - Error PlatformMacOSX::ResolveExecutable (const FileSpec &exe_file, const ArchSpec &exe_arch, @@ -142,11 +146,58 @@ PlatformMacOSX::GetFile (const FileSpec &platform_file, FileSpec &local_file) } +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 @@ PlatformMacOSX::GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch) } 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; + +} diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h index 037cac28e74..4b0db1584a4 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h @@ -45,7 +45,7 @@ namespace lldb_private { virtual const char * GetShortPluginName() { - return "platform.macosx"; + return "local-macosx"; } virtual uint32_t @@ -63,6 +63,15 @@ namespace lldb_private { 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 @@ namespace lldb_private { virtual bool GetSupportedArchitectureAtIndex (uint32_t idx, ArchSpec &arch); - protected: - - + virtual size_t + GetSoftwareBreakpointTrapOpcode (Target &target, + BreakpointSite *bp_site); + private: DISALLOW_COPY_AND_ASSIGN (PlatformMacOSX); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp new file mode 100644 index 00000000000..03af1ddfb1f --- /dev/null +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -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; + +} diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h new file mode 100644 index 00000000000..5c0f075b41c --- /dev/null +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h @@ -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_ diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp index 3106e34565c..baa12e14e06 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.cpp @@ -183,7 +183,7 @@ using namespace lldb_private; const char * ProcessMacOSX::GetPluginNameStatic() { - return "process.macosx"; + return "macosx-user"; } const char * @@ -455,52 +455,6 @@ ProcessMacOSX::DoResume () 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 () { diff --git a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h index 85ce15104b6..a1d28178115 100644 --- a/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h +++ b/lldb/source/Plugins/Process/MacOSX-User/source/ProcessMacOSX.h @@ -192,12 +192,6 @@ public: //---------------------------------------------------------------------- // Process Breakpoints //---------------------------------------------------------------------- - virtual size_t - GetSoftwareBreakpointTrapOpcode (lldb_private::BreakpointSite *bp_site); - - //---------------------------------------------------------------------- - // Process Breakpoints - //---------------------------------------------------------------------- virtual lldb_private::Error EnableBreakpoint (lldb_private::BreakpointSite *bp_site); diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index 2ae589d551c..d88c240f30c 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -63,7 +63,7 @@ get_random_port () const char * ProcessGDBRemote::GetPluginNameStatic() { - return "process.gdb-remote"; + return "gdb-remote"; } const char * @@ -1025,53 +1025,6 @@ ProcessGDBRemote::DoResume () 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 () { diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h index 4bb337fb6d9..6273041825a 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.h @@ -189,12 +189,6 @@ public: //---------------------------------------------------------------------- // Process Breakpoints //---------------------------------------------------------------------- - virtual size_t - GetSoftwareBreakpointTrapOpcode (lldb_private::BreakpointSite *bp_site); - - //---------------------------------------------------------------------- - // Process Breakpoints - //---------------------------------------------------------------------- virtual lldb_private::Error EnableBreakpoint (lldb_private::BreakpointSite *bp_site); diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 1dbea48a2b2..fde35a0d36b 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -102,3 +102,88 @@ ObjectFile::SetModulesArchitecture (const ArchSpec &new_arch) 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; +} + + diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp index 497df2478cc..32ac194b66c 100644 --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -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 @@ GetDefaultPlatformSP () 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 @@ Platform::SetDefaultPlatform (const lldb::PlatformSP &platform_sp) 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 @@ Platform::GetFile (const FileSpec &platform_file, FileSpec &local_file) 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 @@ Platform::GetConnectedRemotePlatformAtIndex (uint32_t idx) //------------------------------------------------------------------ /// 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 @@ Platform::~Platform() { } + +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 @@ Platform::ResolveExecutable (const FileSpec &exe_file, 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) { diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index bbee9567289..a8bd19e1beb 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -1037,6 +1037,16 @@ Process::RemoveBreakpointOpcodesFromBuffer (addr_t bp_addr, size_t size, uint8_t } + +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 @@ Process::Attach (lldb::pid_t attach_pid) // 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 @@ Process::Attach (const char *process_name, bool wait_for_launch) 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); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index 3d8849fe9ec..60f2e2d7d5f 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -39,8 +39,9 @@ using namespace lldb_private; //---------------------------------------------------------------------- // 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 @@ Target::SetExecutableModule (ModuleSP& executable_sp, bool get_dependent_files) 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 diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index 25b768f2e51..34520bbfaea 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -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 @@ TargetList::CreateTarget file.GetFilename().AsCString(), arch.GetArchitectureName()); Error error; + + PlatformSP platform_sp (debugger.GetPlatformList().GetSelectedPlatform ()); if (file) { @@ -67,7 +70,6 @@ TargetList::CreateTarget 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 @@ TargetList::CreateTarget } 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 @@ TargetList::CreateTarget { // 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); } diff --git a/lldb/source/lldb.cpp b/lldb/source/lldb.cpp index 061a3d8ee68..b2c2de9bc1d 100644 --- a/lldb/source/lldb.cpp +++ b/lldb/source/lldb.cpp @@ -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 @@ lldb_private::Initialize () //ProcessMacOSX::Initialize(); SymbolVendorMacOSX::Initialize(); PlatformMacOSX::Initialize(); + PlatformRemoteiOS::Initialize(); #endif #if defined (__linux__) PlatformLinux::Initialize(); @@ -154,6 +156,7 @@ lldb_private::Terminate () //ProcessMacOSX::Terminate(); SymbolVendorMacOSX::Terminate(); PlatformMacOSX::Terminate(); + PlatformRemoteiOS::Terminate(); #endif Debugger::SettingsTerminate (); |

