summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Clayton <gclayton@apple.com>2012-03-20 18:34:04 +0000
committerGreg Clayton <gclayton@apple.com>2012-03-20 18:34:04 +0000
commitb3a40ba812cde1ab2571754a97d19215645271ff (patch)
tree2009e24d3e69bb5dc099eee6845a9220a24d3593
parent5a6011267adb5770cde18c7807b64baccd7587ad (diff)
downloadbcm5719-llvm-b3a40ba812cde1ab2571754a97d19215645271ff.tar.gz
bcm5719-llvm-b3a40ba812cde1ab2571754a97d19215645271ff.zip
Platforms can now auto-select themselves if you specify a full target triple when doing a "target create" command.
Each platform now knows if it can handle an architecture and a platform can be found using an architecture. Each platform can look at the arch, vendor and OS and know if it should be used or not. llvm-svn: 153104
-rw-r--r--lldb/include/lldb/Interpreter/OptionGroupPlatform.h3
-rw-r--r--lldb/include/lldb/Target/Platform.h13
-rw-r--r--lldb/include/lldb/Target/Target.h8
-rw-r--r--lldb/include/lldb/Target/TargetList.h2
-rw-r--r--lldb/include/lldb/lldb-private-interfaces.h2
-rw-r--r--lldb/source/API/SBDebugger.cpp3
-rw-r--r--lldb/source/Commands/CommandObjectPlatform.cpp2
-rw-r--r--lldb/source/Interpreter/OptionGroupPlatform.cpp38
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp15
-rw-r--r--lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h2
-rw-r--r--lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp14
-rw-r--r--lldb/source/Plugins/Platform/Linux/PlatformLinux.h2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp16
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp26
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h2
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp25
-rw-r--r--lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h2
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp2
-rw-r--r--lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h2
-rw-r--r--lldb/source/Target/Platform.cpp59
-rw-r--r--lldb/source/Target/TargetList.cpp49
-rw-r--r--lldb/source/lldb.cpp2
23 files changed, 235 insertions, 56 deletions
diff --git a/lldb/include/lldb/Interpreter/OptionGroupPlatform.h b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h
index 8305ecc5f63..e987e26e034 100644
--- a/lldb/include/lldb/Interpreter/OptionGroupPlatform.h
+++ b/lldb/include/lldb/Interpreter/OptionGroupPlatform.h
@@ -59,7 +59,8 @@ public:
OptionParsingStarting (CommandInterpreter &interpreter);
lldb::PlatformSP
- CreatePlatformWithOptions (CommandInterpreter &interpreter,
+ CreatePlatformWithOptions (CommandInterpreter &interpreter,
+ const ArchSpec &arch,
bool make_selected,
Error& error) const;
diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h
index 909f86b717b..fa5b3d546d0 100644
--- a/lldb/include/lldb/Target/Platform.h
+++ b/lldb/include/lldb/Target/Platform.h
@@ -57,6 +57,9 @@ namespace lldb_private {
static lldb::PlatformSP
GetDefaultPlatform ();
+ static lldb::PlatformSP
+ GetPlatformForArchitecture (const ArchSpec &arch);
+
static const char *
GetHostPlatformName ();
@@ -66,6 +69,9 @@ namespace lldb_private {
static lldb::PlatformSP
Create (const char *platform_name, Error &error);
+ static lldb::PlatformSP
+ Create (const ArchSpec &arch, Error &error);
+
static uint32_t
GetNumConnectedRemotePlatforms ();
@@ -274,6 +280,13 @@ namespace lldb_private {
LaunchProcess (ProcessLaunchInfo &launch_info);
//------------------------------------------------------------------
+ /// Lets a platform answer if it is compatible with a given
+ /// architecture and the target triple contained within.
+ //------------------------------------------------------------------
+ virtual bool
+ IsCompatibleWithArchitecture (const ArchSpec &arch);
+
+ //------------------------------------------------------------------
/// Not all platforms will support debugging a process by spawning
/// somehow halted for a debugger (specified using the
/// "eLaunchFlagDebug" launch flag) and then attaching. If your
diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h
index 5d440adb61a..351f99fc45c 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -1067,7 +1067,13 @@ public:
{
return m_platform_sp;
}
-
+
+ void
+ SetPlatform (const lldb::PlatformSP &platform_sp)
+ {
+ m_platform_sp = platform_sp;
+ }
+
SourceManager &
GetSourceManager ()
{
diff --git a/lldb/include/lldb/Target/TargetList.h b/lldb/include/lldb/Target/TargetList.h
index d617f9a77bd..27663a5731d 100644
--- a/lldb/include/lldb/Target/TargetList.h
+++ b/lldb/include/lldb/Target/TargetList.h
@@ -115,7 +115,7 @@ public:
const FileSpec& file_spec,
const ArchSpec& arch,
bool get_dependent_modules,
- const lldb::PlatformSP &platform_sp,
+ lldb::PlatformSP &platform_sp,
lldb::TargetSP &target_sp);
//------------------------------------------------------------------
diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h
index aa8b5f9a5f4..830985898a9 100644
--- a/lldb/include/lldb/lldb-private-interfaces.h
+++ b/lldb/include/lldb/lldb-private-interfaces.h
@@ -26,7 +26,7 @@ namespace lldb_private
typedef EmulateInstruction * (*EmulateInstructionCreateInstance) (const ArchSpec &arch, InstructionType inst_type);
typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force);
typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language);
- typedef Platform* (*PlatformCreateInstance) ();
+ typedef Platform* (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
typedef lldb::ProcessSP (*ProcessCreateInstance) (Target &target, Listener &listener, const FileSpec *crash_file_path);
typedef SymbolFile* (*SymbolFileCreateInstance) (ObjectFile* obj_file);
typedef SymbolVendor* (*SymbolVendorCreateInstance) (const lldb::ModuleSP &module_sp); // Module can be NULL for default system symbol vendor
diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp
index ac6fc208d23..b61acd75f62 100644
--- a/lldb/source/API/SBDebugger.cpp
+++ b/lldb/source/API/SBDebugger.cpp
@@ -612,11 +612,12 @@ SBDebugger::CreateTarget (const char *filename)
Error error;
const bool add_dependent_modules = true;
+ PlatformSP platform_sp(m_opaque_sp->GetPlatformList().GetSelectedPlatform());
error = m_opaque_sp->GetTargetList().CreateTarget (*m_opaque_sp,
file,
arch,
add_dependent_modules,
- m_opaque_sp->GetPlatformList().GetSelectedPlatform(),
+ platform_sp,
target_sp);
if (error.Success())
diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp
index 855d8fb06d8..9618c6cecb4 100644
--- a/lldb/source/Commands/CommandObjectPlatform.cpp
+++ b/lldb/source/Commands/CommandObjectPlatform.cpp
@@ -63,7 +63,7 @@ public:
const bool select = true;
m_platform_options.SetPlatformName (platform_name);
Error error;
- PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, select, error));
+ PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, ArchSpec(), select, error));
if (platform_sp)
{
platform_sp->GetStatus (result.GetOutputStream());
diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp
index 4e54c39c24f..ca2f3ffc937 100644
--- a/lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp
@@ -21,30 +21,36 @@ using namespace lldb;
using namespace lldb_private;
PlatformSP
-OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter, bool make_selected, Error& error) const
+OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter, const ArchSpec &arch, bool make_selected, Error& error) const
{
PlatformSP platform_sp;
+
if (!m_platform_name.empty())
{
platform_sp = Platform::Create (m_platform_name.c_str(), error);
-
- if (platform_sp)
+ }
+ else if (arch.IsValid())
+ {
+ platform_sp = Platform::Create (arch, error);
+ }
+
+ if (platform_sp)
+ {
+ interpreter.GetDebugger().GetPlatformList().Append (platform_sp, make_selected);
+ if (m_os_version_major != UINT32_MAX)
{
- interpreter.GetDebugger().GetPlatformList().Append (platform_sp, make_selected);
- if (m_os_version_major != UINT32_MAX)
- {
- platform_sp->SetOSVersion (m_os_version_major,
- m_os_version_minor,
- m_os_version_update);
- }
-
- if (m_sdk_sysroot)
- platform_sp->SetSDKRootDirectory (m_sdk_sysroot);
-
- if (m_sdk_build)
- platform_sp->SetSDKBuild (m_sdk_build);
+ platform_sp->SetOSVersion (m_os_version_major,
+ m_os_version_minor,
+ m_os_version_update);
}
+
+ if (m_sdk_sysroot)
+ platform_sp->SetSDKRootDirectory (m_sdk_sysroot);
+
+ if (m_sdk_build)
+ platform_sp->SetSDKBuild (m_sdk_build);
}
+
return platform_sp;
}
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
index ecc96c34b48..f64235da80c 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
@@ -25,9 +25,20 @@ using namespace lldb;
using namespace lldb_private;
Platform *
-PlatformFreeBSD::CreateInstance ()
+PlatformFreeBSD::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
{
- return new PlatformFreeBSD (true);
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ const llvm::Triple::OSType os = triple.getOS();
+ if (os == llvm::Triple::FreeBSD || os == llvm::Triple::KFreeBSD)
+ create = true;
+ }
+ if (create)
+ return new PlatformFreeBSD (true);
+ return NULL;
+
}
const char *
diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
index 438a0e6f1e4..80c4a63e0a8 100644
--- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
@@ -25,7 +25,7 @@ public:
// Class functions
//------------------------------------------------------------
static lldb_private::Platform*
- CreateInstance ();
+ CreateInstance (bool force, const lldb_private::ArchSpec *arch);
static void
Initialize ();
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
index 80c9a86a973..58200da5182 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -33,9 +33,19 @@ using namespace lldb_private;
static uint32_t g_initialize_count = 0;
Platform *
-PlatformLinux::CreateInstance ()
+PlatformLinux::CreateInstance (bool force, const ArchSpec *arch)
{
- return new PlatformLinux(true);
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ const llvm::Triple::OSType os = triple.getOS();
+ if (os == llvm::Triple::Linux)
+ create = true;
+ }
+ if (create)
+ return new PlatformLinux(true);
+ return NULL;
}
const char *
diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
index 59dde3ec170..8b43def165b 100644
--- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -37,7 +37,7 @@ namespace lldb_private {
// lldb_private::PluginInterface functions
//------------------------------------------------------------
static Platform *
- CreateInstance ();
+ CreateInstance (bool force, const lldb_private::ArchSpec *arch);
static const char *
GetPluginNameStatic();
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
index 6262c59c133..f7c2374da2c 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -61,12 +61,24 @@ PlatformMacOSX::Terminate ()
}
Platform*
-PlatformMacOSX::CreateInstance ()
+PlatformMacOSX::CreateInstance (bool force, const ArchSpec *arch)
{
// The only time we create an instance is when we are creating a remote
// macosx platform
const bool is_host = false;
- return new PlatformMacOSX (is_host);
+
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ const llvm::Triple::OSType os = triple.getOS();
+ const llvm::Triple::VendorType vendor = triple.getVendor();
+ if (os == llvm::Triple::Darwin && vendor == llvm::Triple::Apple)
+ create = true;
+ }
+ if (create)
+ return new PlatformMacOSX (is_host);
+ return NULL;
}
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
index 4a47b7fb50c..3a5eaf0072a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
@@ -24,7 +24,7 @@ public:
// Class functions
//------------------------------------------------------------
static lldb_private::Platform*
- CreateInstance ();
+ CreateInstance (bool force, const lldb_private::ArchSpec *arch);
static void
Initialize ();
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
index ad495731129..61caafceccd 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
@@ -60,9 +60,31 @@ PlatformRemoteiOS::Terminate ()
}
Platform*
-PlatformRemoteiOS::CreateInstance ()
+PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
{
- return new PlatformRemoteiOS ();
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ switch (arch->GetMachine())
+ {
+ case llvm::Triple::arm:
+ case llvm::Triple::thumb:
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ const llvm::Triple::OSType os = triple.getOS();
+ const llvm::Triple::VendorType vendor = triple.getVendor();
+ if (os == llvm::Triple::Darwin && vendor == llvm::Triple::Apple)
+ create = true;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (create)
+ return new PlatformRemoteiOS ();
+ return NULL;
}
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
index 9aa33f896bf..051b5846dc8 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
@@ -24,7 +24,7 @@ public:
// Class Functions
//------------------------------------------------------------
static lldb_private::Platform*
- CreateInstance ();
+ CreateInstance (bool force, const lldb_private::ArchSpec *arch);
static void
Initialize ();
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
index 18cd4eb8f88..7a8884eba0a 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp
@@ -60,9 +60,30 @@ PlatformiOSSimulator::Terminate ()
}
Platform*
-PlatformiOSSimulator::CreateInstance ()
+PlatformiOSSimulator::CreateInstance (bool force, const ArchSpec *arch)
{
- return new PlatformiOSSimulator ();
+ bool create = force;
+ if (create == false && arch && arch->IsValid())
+ {
+ switch (arch->GetMachine())
+ {
+ // Currently simulator is i386 only...
+ case llvm::Triple::x86:
+ {
+ const llvm::Triple &triple = arch->GetTriple();
+ const llvm::Triple::OSType os = triple.getOS();
+ const llvm::Triple::VendorType vendor = triple.getVendor();
+ if (os == llvm::Triple::Darwin && vendor == llvm::Triple::Apple)
+ create = true;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ if (create)
+ return new PlatformiOSSimulator ();
+ return NULL;
}
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
index d0986428018..3973c2f515b 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformiOSSimulator.h
@@ -24,7 +24,7 @@ public:
// Class Functions
//------------------------------------------------------------
static lldb_private::Platform*
- CreateInstance ();
+ CreateInstance (bool force, const lldb_private::ArchSpec *arch);
static void
Initialize ();
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
index 248475af9c3..4d9cd96def4 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
@@ -56,7 +56,7 @@ PlatformRemoteGDBServer::Terminate ()
}
Platform*
-PlatformRemoteGDBServer::CreateInstance ()
+PlatformRemoteGDBServer::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
{
return new PlatformRemoteGDBServer ();
}
diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
index 48f36136aef..ad2ffa53194 100644
--- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
@@ -30,7 +30,7 @@ public:
Terminate ();
static lldb_private::Platform*
- CreateInstance ();
+ CreateInstance (bool force, const lldb_private::ArchSpec *arch);
static const char *
GetShortPluginNameStatic();
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index 403b10e19bb..cc8070d437c 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -110,7 +110,6 @@ Platform::GetSharedModule (const ModuleSpec &module_spec,
always_create);
}
-
PlatformSP
Platform::Create (const char *platform_name, Error &error)
{
@@ -120,7 +119,7 @@ Platform::Create (const char *platform_name, Error &error)
{
create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (platform_name);
if (create_callback)
- platform_sp.reset(create_callback());
+ platform_sp.reset(create_callback(true, NULL));
else
error.SetErrorStringWithFormat ("unable to find a plug-in for the platform named \"%s\"", platform_name);
}
@@ -129,6 +128,27 @@ Platform::Create (const char *platform_name, Error &error)
return platform_sp;
}
+
+PlatformSP
+Platform::Create (const ArchSpec &arch, Error &error)
+{
+ lldb::PlatformSP platform_sp;
+ if (arch.IsValid())
+ {
+ PlatformCreateInstance create_callback;
+ for (uint32_t idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
+ {
+ if (create_callback)
+ platform_sp.reset(create_callback(false, &arch));
+ if (platform_sp && platform_sp->IsCompatibleWithArchitecture(arch))
+ break;
+ }
+ }
+ else
+ error.SetErrorString ("invalid platform name");
+ return platform_sp;
+}
+
uint32_t
Platform::GetNumConnectedRemotePlatforms ()
{
@@ -592,3 +612,38 @@ Platform::DebugProcess (ProcessLaunchInfo &launch_info,
}
return process_sp;
}
+
+
+lldb::PlatformSP
+Platform::GetPlatformForArchitecture (const ArchSpec &arch)
+{
+ lldb::PlatformSP platform_sp;
+ Error error;
+ if (arch.IsValid())
+ platform_sp = Platform::Create (arch, error);
+ return platform_sp;
+}
+
+
+//------------------------------------------------------------------
+/// Lets a platform answer if it is compatible with a given
+/// architecture and the target triple contained within.
+//------------------------------------------------------------------
+bool
+Platform::IsCompatibleWithArchitecture (const ArchSpec &arch)
+{
+ // If the architecture is invalid, we must answer true...
+ if (!arch.IsValid())
+ return true;
+
+ ArchSpec platform_arch;
+ for (uint32_t arch_idx=0; GetSupportedArchitectureAtIndex (arch_idx, platform_arch); ++arch_idx)
+ {
+ if (arch == platform_arch)
+ return true;
+ }
+ return false;
+
+}
+
+
diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp
index 38240e12318..d9879139dc5 100644
--- a/lldb/source/Target/TargetList.cpp
+++ b/lldb/source/Target/TargetList.cpp
@@ -17,6 +17,7 @@
#include "lldb/Core/State.h"
#include "lldb/Core/Timer.h"
#include "lldb/Host/Host.h"
+#include "lldb/Interpreter/CommandInterpreter.h"
#include "lldb/Interpreter/OptionGroupPlatform.h"
#include "lldb/Target/Platform.h"
#include "lldb/Target/Process.h"
@@ -63,12 +64,30 @@ TargetList::CreateTarget (Debugger &debugger,
{
Error error;
PlatformSP platform_sp;
+
+ // This is purposely left empty unless it is specified by triple_cstr.
+ // If not initialized via triple_cstr, then the currently selected platform
+ // will set the architecture correctly.
+ ArchSpec arch;
+
+ if (triple_cstr)
+ {
+ arch.SetTriple(triple_cstr, platform_sp.get());
+ if (!arch.IsValid())
+ {
+ error.SetErrorStringWithFormat("invalid triple '%s'", triple_cstr);
+ return error;
+ }
+ }
+
+ CommandInterpreter &interpreter = debugger.GetCommandInterpreter();
if (platform_options)
{
if (platform_options->PlatformWasSpecified ())
{
const bool select_platform = true;
- platform_sp = platform_options->CreatePlatformWithOptions (debugger.GetCommandInterpreter(),
+ platform_sp = platform_options->CreatePlatformWithOptions (interpreter,
+ arch,
select_platform,
error);
if (!platform_sp)
@@ -77,22 +96,17 @@ TargetList::CreateTarget (Debugger &debugger,
}
if (!platform_sp)
- platform_sp = debugger.GetPlatformList().GetSelectedPlatform ();
-
- // This is purposely left empty unless it is specified by triple_cstr.
- // If not initialized via triple_cstr, then the currently selected platform
- // will set the architecture correctly.
- ArchSpec arch;
-
- if (triple_cstr)
{
- arch.SetTriple(triple_cstr, platform_sp.get());
- if (!arch.IsValid())
+ // Get the current platform and make sure it is compatible with the
+ // current architecture if we have a valid architecture.
+ platform_sp = debugger.GetPlatformList().GetSelectedPlatform ();
+
+ if (arch.IsValid() && !platform_sp->IsCompatibleWithArchitecture(arch))
{
- error.SetErrorStringWithFormat("invalid triple '%s'", triple_cstr);
- return error;
+ platform_sp = Platform::GetPlatformForArchitecture(arch);
}
}
+
error = TargetList::CreateTarget (debugger,
file,
arch,
@@ -119,7 +133,7 @@ TargetList::CreateTarget
const FileSpec& file,
const ArchSpec& arch,
bool get_dependent_files,
- const PlatformSP &platform_sp,
+ PlatformSP &platform_sp,
TargetSP &target_sp
)
{
@@ -142,6 +156,13 @@ TargetList::CreateTarget
error = platform_sp->ResolveExecutable (file, arch,
exe_module_sp,
executable_search_paths.GetSize() ? &executable_search_paths : NULL);
+
+ if (exe_module_sp)
+ {
+ const ArchSpec &arch = exe_module_sp->GetArchitecture();
+ if (arch.IsValid() && !platform_sp->IsCompatibleWithArchitecture(arch))
+ platform_sp = Platform::GetPlatformForArchitecture(arch);
+ }
}
if (error.Success() && exe_module_sp)
diff --git a/lldb/source/lldb.cpp b/lldb/source/lldb.cpp
index 3c7b7688fdb..fb377b2228a 100644
--- a/lldb/source/lldb.cpp
+++ b/lldb/source/lldb.cpp
@@ -126,8 +126,8 @@ lldb_private::Initialize ()
ProcessGDBRemote::Initialize();
ProcessMachCore::Initialize();
SymbolVendorMacOSX::Initialize();
- PlatformMacOSX::Initialize();
PlatformRemoteiOS::Initialize();
+ PlatformMacOSX::Initialize();
PlatformiOSSimulator::Initialize();
#endif
#if defined (__linux__)
OpenPOWER on IntegriCloud