mirror of
https://github.com/intel/llvm.git
synced 2026-01-23 07:58:23 +08:00
Test suite runs better again after recent fixes that would select a platform if a "file a.out" auto selected a different platform than the selected one.
Changes include: - fix it so you can select the "host" platform using "platform select host" - change all callbacks that create platforms to returns shared pointers - fix TestImageListMultiArchitecture.py to restore the "host" platform by running "platform select host" - Add a new "PlatformSP Platform::Find(const ConstString &name)" method to get a cached platform - cache platforms that are created and re-use them instead of always creating a new one llvm-svn: 218145
This commit is contained in:
@@ -62,7 +62,7 @@ namespace lldb_private {
|
||||
/// or attaching to processes unless another platform is specified.
|
||||
//------------------------------------------------------------------
|
||||
static lldb::PlatformSP
|
||||
GetDefaultPlatform ();
|
||||
GetHostPlatform ();
|
||||
|
||||
static lldb::PlatformSP
|
||||
GetPlatformForArchitecture (const ArchSpec &arch,
|
||||
@@ -72,10 +72,14 @@ namespace lldb_private {
|
||||
GetHostPlatformName ();
|
||||
|
||||
static void
|
||||
SetDefaultPlatform (const lldb::PlatformSP &platform_sp);
|
||||
SetHostPlatform (const lldb::PlatformSP &platform_sp);
|
||||
|
||||
// Find an existing platform plug-in by name
|
||||
static lldb::PlatformSP
|
||||
Find (const ConstString &name);
|
||||
|
||||
static lldb::PlatformSP
|
||||
Create (const char *platform_name, Error &error);
|
||||
Create (const ConstString &name, Error &error);
|
||||
|
||||
static lldb::PlatformSP
|
||||
Create (const ArchSpec &arch, ArchSpec *platform_arch_ptr, Error &error);
|
||||
@@ -114,8 +118,8 @@ namespace lldb_private {
|
||||
/// An optional name of a specific platform plug-in that
|
||||
/// should be used. If NULL, pick the best plug-in.
|
||||
//------------------------------------------------------------------
|
||||
static Platform*
|
||||
FindPlugin (Process *process, const ConstString &plugin_name);
|
||||
// static lldb::PlatformSP
|
||||
// FindPlugin (Process *process, const ConstString &plugin_name);
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Set the target's executable based off of the existing
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace lldb_private
|
||||
typedef OperatingSystem* (*OperatingSystemCreateInstance) (Process *process, bool force);
|
||||
typedef LanguageRuntime *(*LanguageRuntimeCreateInstance) (Process *process, lldb::LanguageType language);
|
||||
typedef SystemRuntime *(*SystemRuntimeCreateInstance) (Process *process);
|
||||
typedef Platform* (*PlatformCreateInstance) (bool force, const ArchSpec *arch);
|
||||
typedef lldb::PlatformSP (*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, lldb_private::Stream *feedback_strm); // Module can be NULL for default system symbol vendor
|
||||
|
||||
@@ -1186,18 +1186,41 @@ SBDebugger::GetID()
|
||||
|
||||
|
||||
SBError
|
||||
SBDebugger::SetCurrentPlatform (const char *platform_name)
|
||||
SBDebugger::SetCurrentPlatform (const char *platform_name_cstr)
|
||||
{
|
||||
SBError sb_error;
|
||||
if (m_opaque_sp)
|
||||
{
|
||||
PlatformSP platform_sp (Platform::Create (platform_name, sb_error.ref()));
|
||||
|
||||
if (platform_sp)
|
||||
if (platform_name_cstr && platform_name_cstr[0])
|
||||
{
|
||||
bool make_selected = true;
|
||||
m_opaque_sp->GetPlatformList().Append (platform_sp, make_selected);
|
||||
ConstString platform_name (platform_name_cstr);
|
||||
PlatformSP platform_sp (Platform::Find (platform_name));
|
||||
|
||||
if (platform_sp)
|
||||
{
|
||||
// Already have a platform with this name, just select it
|
||||
m_opaque_sp->GetPlatformList().SetSelectedPlatform(platform_sp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We don't have a platform by this name yet, create one
|
||||
platform_sp = Platform::Create (platform_name, sb_error.ref());
|
||||
if (platform_sp)
|
||||
{
|
||||
// We created the platform, now append and select it
|
||||
bool make_selected = true;
|
||||
m_opaque_sp->GetPlatformList().Append (platform_sp, make_selected);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_error.ref().SetErrorString("invalid platform name");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sb_error.ref().SetErrorString("invalid debugger");
|
||||
}
|
||||
return sb_error;
|
||||
}
|
||||
|
||||
@@ -269,7 +269,8 @@ SBPlatform::SBPlatform (const char *platform_name) :
|
||||
m_opaque_sp ()
|
||||
{
|
||||
Error error;
|
||||
m_opaque_sp = Platform::Create (platform_name, error);
|
||||
if (platform_name && platform_name[0])
|
||||
m_opaque_sp = Platform::Create (ConstString(platform_name), error);
|
||||
}
|
||||
|
||||
SBPlatform::~SBPlatform()
|
||||
|
||||
@@ -302,7 +302,7 @@ protected:
|
||||
Stream &ostrm = result.GetOutputStream();
|
||||
ostrm.Printf("Available platforms:\n");
|
||||
|
||||
PlatformSP host_platform_sp (Platform::GetDefaultPlatform());
|
||||
PlatformSP host_platform_sp (Platform::GetHostPlatform());
|
||||
ostrm.Printf ("%s: %s\n",
|
||||
host_platform_sp->GetPluginName().GetCString(),
|
||||
host_platform_sp->GetDescription());
|
||||
|
||||
@@ -645,7 +645,7 @@ Debugger::Debugger(lldb::LogOutputCallback log_callback, void *baton) :
|
||||
m_log_callback_stream_sp.reset (new StreamCallback (log_callback, baton));
|
||||
m_command_interpreter_ap->Initialize ();
|
||||
// Always add our default platform to the platform list
|
||||
PlatformSP default_platform_sp (Platform::GetDefaultPlatform());
|
||||
PlatformSP default_platform_sp (Platform::GetHostPlatform());
|
||||
assert (default_platform_sp.get());
|
||||
m_platform_list.Append (default_platform_sp, true);
|
||||
|
||||
|
||||
@@ -1039,7 +1039,7 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
Error error;
|
||||
char exe_path[PATH_MAX];
|
||||
|
||||
PlatformSP host_platform_sp (Platform::GetDefaultPlatform ());
|
||||
PlatformSP host_platform_sp (Platform::GetHostPlatform ());
|
||||
|
||||
const ArchSpec &arch_spec = launch_info.GetArchitecture();
|
||||
|
||||
|
||||
@@ -1305,7 +1305,7 @@ Host::LaunchProcess (ProcessLaunchInfo &launch_info)
|
||||
{
|
||||
Error error;
|
||||
char exe_path[PATH_MAX];
|
||||
PlatformSP host_platform_sp (Platform::GetDefaultPlatform ());
|
||||
PlatformSP host_platform_sp (Platform::GetHostPlatform ());
|
||||
|
||||
const ArchSpec &arch_spec = launch_info.GetArchitecture();
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ OptionGroupPlatform::CreatePlatformWithOptions (CommandInterpreter &interpreter,
|
||||
|
||||
if (!m_platform_name.empty())
|
||||
{
|
||||
platform_sp = Platform::Create (m_platform_name.c_str(), error);
|
||||
platform_sp = Platform::Create (ConstString(m_platform_name.c_str()), error);
|
||||
if (platform_sp)
|
||||
{
|
||||
if (platform_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch))
|
||||
|
||||
@@ -467,7 +467,8 @@ DynamicLoaderDarwinKernel::DynamicLoaderDarwinKernel (Process* process, lldb::ad
|
||||
m_mutex(Mutex::eMutexTypeRecursive),
|
||||
m_break_id (LLDB_INVALID_BREAK_ID)
|
||||
{
|
||||
PlatformSP platform_sp(Platform::FindPlugin (process, PlatformDarwinKernel::GetPluginNameStatic ()));
|
||||
Error error;
|
||||
PlatformSP platform_sp(Platform::Create(PlatformDarwinKernel::GetPluginNameStatic(), error));
|
||||
// Only select the darwin-kernel Platform if we've been asked to load kexts.
|
||||
// It can take some time to scan over all of the kext info.plists and that
|
||||
// shouldn't be done if kext loading is explicitly disabled.
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
using namespace lldb;
|
||||
using namespace lldb_private;
|
||||
|
||||
Platform *
|
||||
PlatformSP
|
||||
PlatformFreeBSD::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
|
||||
{
|
||||
// The only time we create an instance is when we are creating a remote
|
||||
@@ -84,8 +84,8 @@ PlatformFreeBSD::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
|
||||
}
|
||||
}
|
||||
if (create)
|
||||
return new PlatformFreeBSD (is_host);
|
||||
return NULL;
|
||||
return PlatformSP(new PlatformFreeBSD (is_host));
|
||||
return PlatformSP();
|
||||
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ PlatformFreeBSD::Initialize ()
|
||||
// Force a host flag to true for the default platform object.
|
||||
PlatformSP default_platform_sp (new PlatformFreeBSD(true));
|
||||
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
|
||||
Platform::SetDefaultPlatform (default_platform_sp);
|
||||
Platform::SetHostPlatform (default_platform_sp);
|
||||
#endif
|
||||
PluginManager::RegisterPlugin(PlatformFreeBSD::GetPluginNameStatic(false),
|
||||
PlatformFreeBSD::GetDescriptionStatic(false),
|
||||
@@ -404,7 +404,7 @@ PlatformFreeBSD::ConnectRemote (Args& args)
|
||||
else
|
||||
{
|
||||
if (!m_remote_platform_sp)
|
||||
m_remote_platform_sp = Platform::Create ("remote-gdb-server", error);
|
||||
m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
|
||||
|
||||
if (m_remote_platform_sp)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
//------------------------------------------------------------
|
||||
// Class functions
|
||||
//------------------------------------------------------------
|
||||
static lldb_private::Platform*
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static void
|
||||
|
||||
@@ -32,7 +32,7 @@ using namespace lldb_private;
|
||||
|
||||
static uint32_t g_initialize_count = 0;
|
||||
|
||||
Platform *
|
||||
PlatformSP
|
||||
PlatformKalimba::CreateInstance (bool force, const ArchSpec *arch)
|
||||
{
|
||||
bool create = force;
|
||||
@@ -50,8 +50,8 @@ PlatformKalimba::CreateInstance (bool force, const ArchSpec *arch)
|
||||
}
|
||||
}
|
||||
if (create)
|
||||
return new PlatformKalimba(false);
|
||||
return NULL;
|
||||
return PlatformSP(new PlatformKalimba(false));
|
||||
return PlatformSP();
|
||||
}
|
||||
|
||||
lldb_private::ConstString
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace lldb_private {
|
||||
//------------------------------------------------------------
|
||||
// lldb_private::PluginInterface functions
|
||||
//------------------------------------------------------------
|
||||
static Platform *
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static lldb_private::ConstString
|
||||
|
||||
@@ -118,7 +118,7 @@ PlatformLinux::DebuggerInitialize (lldb_private::Debugger &debugger)
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
||||
Platform *
|
||||
PlatformSP
|
||||
PlatformLinux::CreateInstance (bool force, const ArchSpec *arch)
|
||||
{
|
||||
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_PLATFORM));
|
||||
@@ -183,13 +183,13 @@ PlatformLinux::CreateInstance (bool force, const ArchSpec *arch)
|
||||
{
|
||||
if (log)
|
||||
log->Printf ("PlatformLinux::%s() creating remote-linux platform", __FUNCTION__);
|
||||
return new PlatformLinux(false);
|
||||
return PlatformSP(new PlatformLinux(false));
|
||||
}
|
||||
|
||||
if (log)
|
||||
log->Printf ("PlatformLinux::%s() aborting creation of remote-linux platform", __FUNCTION__);
|
||||
|
||||
return NULL;
|
||||
return PlatformSP();
|
||||
}
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ PlatformLinux::Initialize ()
|
||||
#if defined(__linux__)
|
||||
PlatformSP default_platform_sp (new PlatformLinux(true));
|
||||
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
|
||||
Platform::SetDefaultPlatform (default_platform_sp);
|
||||
Platform::SetHostPlatform (default_platform_sp);
|
||||
#endif
|
||||
PluginManager::RegisterPlugin(PlatformLinux::GetPluginNameStatic(false),
|
||||
PlatformLinux::GetPluginDescriptionStatic(false),
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace lldb_private {
|
||||
//------------------------------------------------------------
|
||||
// lldb_private::PluginInterface functions
|
||||
//------------------------------------------------------------
|
||||
static Platform *
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static lldb_private::ConstString
|
||||
|
||||
@@ -72,14 +72,14 @@ PlatformDarwinKernel::Terminate ()
|
||||
}
|
||||
}
|
||||
|
||||
Platform*
|
||||
PlatformSP
|
||||
PlatformDarwinKernel::CreateInstance (bool force, const ArchSpec *arch)
|
||||
{
|
||||
// This is a special plugin that we don't want to activate just based on an ArchSpec for normal
|
||||
// userlnad debugging. It is only useful in kernel debug sessions and the DynamicLoaderDarwinPlugin
|
||||
// (or a user doing 'platform select') will force the creation of this Platform plugin.
|
||||
if (force == false)
|
||||
return NULL;
|
||||
return PlatformSP();
|
||||
|
||||
bool create = force;
|
||||
LazyBool is_ios_debug_session = eLazyBoolCalculate;
|
||||
@@ -143,8 +143,8 @@ PlatformDarwinKernel::CreateInstance (bool force, const ArchSpec *arch)
|
||||
}
|
||||
}
|
||||
if (create)
|
||||
return new PlatformDarwinKernel (is_ios_debug_session);
|
||||
return NULL;
|
||||
return PlatformSP(new PlatformDarwinKernel (is_ios_debug_session));
|
||||
return PlatformSP();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ public:
|
||||
//------------------------------------------------------------
|
||||
// Class Functions
|
||||
//------------------------------------------------------------
|
||||
static lldb_private::Platform*
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static void
|
||||
|
||||
@@ -45,7 +45,7 @@ PlatformMacOSX::Initialize ()
|
||||
#if defined (__APPLE__)
|
||||
PlatformSP default_platform_sp (new PlatformMacOSX(true));
|
||||
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
|
||||
Platform::SetDefaultPlatform (default_platform_sp);
|
||||
Platform::SetHostPlatform (default_platform_sp);
|
||||
#endif
|
||||
PluginManager::RegisterPlugin (PlatformMacOSX::GetPluginNameStatic(false),
|
||||
PlatformMacOSX::GetDescriptionStatic(false),
|
||||
@@ -66,7 +66,7 @@ PlatformMacOSX::Terminate ()
|
||||
}
|
||||
}
|
||||
|
||||
Platform*
|
||||
PlatformSP
|
||||
PlatformMacOSX::CreateInstance (bool force, const ArchSpec *arch)
|
||||
{
|
||||
// The only time we create an instance is when we are creating a remote
|
||||
@@ -117,8 +117,8 @@ PlatformMacOSX::CreateInstance (bool force, const ArchSpec *arch)
|
||||
}
|
||||
}
|
||||
if (create)
|
||||
return new PlatformMacOSX (is_host);
|
||||
return NULL;
|
||||
return PlatformSP(new PlatformMacOSX (is_host));
|
||||
return PlatformSP();
|
||||
}
|
||||
|
||||
lldb_private::ConstString
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
//------------------------------------------------------------
|
||||
// Class functions
|
||||
//------------------------------------------------------------
|
||||
static lldb_private::Platform*
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static void
|
||||
|
||||
@@ -83,7 +83,7 @@ PlatformRemoteiOS::Terminate ()
|
||||
}
|
||||
}
|
||||
|
||||
Platform*
|
||||
PlatformSP
|
||||
PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
|
||||
{
|
||||
bool create = force;
|
||||
@@ -144,8 +144,8 @@ PlatformRemoteiOS::CreateInstance (bool force, const ArchSpec *arch)
|
||||
}
|
||||
|
||||
if (create)
|
||||
return new PlatformRemoteiOS ();
|
||||
return NULL;
|
||||
return lldb::PlatformSP(new PlatformRemoteiOS ());
|
||||
return lldb::PlatformSP();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
//------------------------------------------------------------
|
||||
// Class Functions
|
||||
//------------------------------------------------------------
|
||||
static lldb_private::Platform*
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static void
|
||||
|
||||
@@ -61,7 +61,7 @@ PlatformiOSSimulator::Terminate ()
|
||||
}
|
||||
}
|
||||
|
||||
Platform*
|
||||
PlatformSP
|
||||
PlatformiOSSimulator::CreateInstance (bool force, const ArchSpec *arch)
|
||||
{
|
||||
bool create = force;
|
||||
@@ -120,8 +120,8 @@ PlatformiOSSimulator::CreateInstance (bool force, const ArchSpec *arch)
|
||||
}
|
||||
}
|
||||
if (create)
|
||||
return new PlatformiOSSimulator ();
|
||||
return NULL;
|
||||
return PlatformSP(new PlatformiOSSimulator ());
|
||||
return PlatformSP();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
//------------------------------------------------------------
|
||||
// Class Functions
|
||||
//------------------------------------------------------------
|
||||
static lldb_private::Platform*
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static void
|
||||
|
||||
@@ -699,7 +699,7 @@ PlatformPOSIX::ConnectRemote (Args& args)
|
||||
else
|
||||
{
|
||||
if (!m_remote_platform_sp)
|
||||
m_remote_platform_sp = Platform::Create ("remote-gdb-server", error);
|
||||
m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
|
||||
|
||||
if (m_remote_platform_sp && error.Success())
|
||||
error = m_remote_platform_sp->ConnectRemote (args);
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
Platform *
|
||||
PlatformSP
|
||||
PlatformWindows::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
|
||||
{
|
||||
// The only time we create an instance is when we are creating a remote
|
||||
@@ -109,8 +109,8 @@ PlatformWindows::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
|
||||
}
|
||||
}
|
||||
if (create)
|
||||
return new PlatformWindows (is_host);
|
||||
return NULL;
|
||||
return PlatformSP(new PlatformWindows (is_host));
|
||||
return PlatformSP();
|
||||
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ PlatformWindows::Initialize(void)
|
||||
// Force a host flag to true for the default platform object.
|
||||
PlatformSP default_platform_sp (new PlatformWindows(true));
|
||||
default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture());
|
||||
Platform::SetDefaultPlatform (default_platform_sp);
|
||||
Platform::SetHostPlatform (default_platform_sp);
|
||||
#endif
|
||||
PluginManager::RegisterPlugin(PlatformWindows::GetPluginNameStatic(false),
|
||||
PlatformWindows::GetPluginDescriptionStatic(false),
|
||||
@@ -417,7 +417,7 @@ PlatformWindows::ConnectRemote (Args& args)
|
||||
else
|
||||
{
|
||||
if (!m_remote_platform_sp)
|
||||
m_remote_platform_sp = Platform::Create ("remote-gdb-server", error);
|
||||
m_remote_platform_sp = Platform::Create (ConstString("remote-gdb-server"), error);
|
||||
|
||||
if (m_remote_platform_sp)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ public:
|
||||
//------------------------------------------------------------
|
||||
// lldb_private::PluginInterface functions
|
||||
//------------------------------------------------------------
|
||||
static lldb_private::Platform*
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ PlatformRemoteGDBServer::Terminate ()
|
||||
}
|
||||
}
|
||||
|
||||
Platform*
|
||||
PlatformSP
|
||||
PlatformRemoteGDBServer::CreateInstance (bool force, const lldb_private::ArchSpec *arch)
|
||||
{
|
||||
bool create = force;
|
||||
@@ -65,8 +65,8 @@ PlatformRemoteGDBServer::CreateInstance (bool force, const lldb_private::ArchSpe
|
||||
create = !arch->TripleVendorWasSpecified() && !arch->TripleOSWasSpecified();
|
||||
}
|
||||
if (create)
|
||||
return new PlatformRemoteGDBServer ();
|
||||
return NULL;
|
||||
return PlatformSP(new PlatformRemoteGDBServer());
|
||||
return PlatformSP();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
static void
|
||||
Terminate ();
|
||||
|
||||
static lldb_private::Platform*
|
||||
static lldb::PlatformSP
|
||||
CreateInstance (bool force, const lldb_private::ArchSpec *arch);
|
||||
|
||||
static lldb_private::ConstString
|
||||
|
||||
@@ -1278,7 +1278,7 @@ NativeProcessLinux::AttachToProcess (
|
||||
|
||||
// Grab the current platform architecture. This should be Linux,
|
||||
// since this code is only intended to run on a Linux host.
|
||||
PlatformSP platform_sp (Platform::GetDefaultPlatform ());
|
||||
PlatformSP platform_sp (Platform::GetHostPlatform ());
|
||||
if (!platform_sp)
|
||||
return Error("failed to get a valid default platform");
|
||||
|
||||
@@ -1412,7 +1412,7 @@ NativeProcessLinux::AttachToInferior (lldb::pid_t pid, lldb_private::Error &erro
|
||||
log->Printf ("NativeProcessLinux::%s (pid = %" PRIi64 ")", __FUNCTION__, pid);
|
||||
|
||||
// We can use the Host for everything except the ResolveExecutable portion.
|
||||
PlatformSP platform_sp = Platform::GetDefaultPlatform ();
|
||||
PlatformSP platform_sp = Platform::GetHostPlatform ();
|
||||
if (!platform_sp)
|
||||
{
|
||||
if (log)
|
||||
|
||||
@@ -71,7 +71,7 @@ namespace
|
||||
//----------------------------------------------------------------------
|
||||
GDBRemoteCommunicationServer::GDBRemoteCommunicationServer(bool is_platform) :
|
||||
GDBRemoteCommunication ("gdb-remote.server", "gdb-remote.server.rx_packet", is_platform),
|
||||
m_platform_sp (Platform::GetDefaultPlatform ()),
|
||||
m_platform_sp (Platform::GetHostPlatform ()),
|
||||
m_async_thread (LLDB_INVALID_HOST_THREAD),
|
||||
m_process_launch_info (),
|
||||
m_process_launch_error (),
|
||||
|
||||
@@ -32,26 +32,12 @@ using namespace lldb_private;
|
||||
// Use a singleton function for g_local_platform_sp to avoid init
|
||||
// constructors since LLDB is often part of a shared library
|
||||
static PlatformSP&
|
||||
GetDefaultPlatformSP ()
|
||||
GetHostPlatformSP ()
|
||||
{
|
||||
static PlatformSP g_default_platform_sp;
|
||||
return g_default_platform_sp;
|
||||
static PlatformSP g_platform_sp;
|
||||
return g_platform_sp;
|
||||
}
|
||||
|
||||
static Mutex &
|
||||
GetConnectedPlatformListMutex ()
|
||||
{
|
||||
static Mutex g_remote_connected_platforms_mutex (Mutex::eMutexTypeRecursive);
|
||||
return g_remote_connected_platforms_mutex;
|
||||
}
|
||||
static std::vector<PlatformSP> &
|
||||
GetConnectedPlatformList ()
|
||||
{
|
||||
static std::vector<PlatformSP> g_remote_connected_platforms;
|
||||
return g_remote_connected_platforms;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
Platform::GetHostPlatformName ()
|
||||
{
|
||||
@@ -69,17 +55,37 @@ Platform::GetHostPlatformName ()
|
||||
/// or attaching to processes unless another platform is specified.
|
||||
//------------------------------------------------------------------
|
||||
PlatformSP
|
||||
Platform::GetDefaultPlatform ()
|
||||
Platform::GetHostPlatform ()
|
||||
{
|
||||
return GetDefaultPlatformSP ();
|
||||
return GetHostPlatformSP ();
|
||||
}
|
||||
|
||||
static std::vector<PlatformSP> &
|
||||
GetPlatformList()
|
||||
{
|
||||
static std::vector<PlatformSP> g_platform_list;
|
||||
return g_platform_list;
|
||||
}
|
||||
|
||||
static Mutex &
|
||||
GetPlatformListMutex ()
|
||||
{
|
||||
static Mutex g_mutex(Mutex::eMutexTypeRecursive);
|
||||
return g_mutex;
|
||||
}
|
||||
|
||||
void
|
||||
Platform::SetDefaultPlatform (const lldb::PlatformSP &platform_sp)
|
||||
Platform::SetHostPlatform (const lldb::PlatformSP &platform_sp)
|
||||
{
|
||||
// The native platform should use its static void Platform::Initialize()
|
||||
// function to register itself as the native platform.
|
||||
GetDefaultPlatformSP () = platform_sp;
|
||||
GetHostPlatformSP () = platform_sp;
|
||||
|
||||
if (platform_sp)
|
||||
{
|
||||
Mutex::Locker locker(GetPlatformListMutex ());
|
||||
GetPlatformList().push_back(platform_sp);
|
||||
}
|
||||
}
|
||||
|
||||
Error
|
||||
@@ -98,36 +104,36 @@ Platform::LocateExecutableScriptingResources (Target *target, Module &module, St
|
||||
return FileSpecList();
|
||||
}
|
||||
|
||||
Platform*
|
||||
Platform::FindPlugin (Process *process, const ConstString &plugin_name)
|
||||
{
|
||||
PlatformCreateInstance create_callback = NULL;
|
||||
if (plugin_name)
|
||||
{
|
||||
create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (plugin_name);
|
||||
if (create_callback)
|
||||
{
|
||||
ArchSpec arch;
|
||||
if (process)
|
||||
{
|
||||
arch = process->GetTarget().GetArchitecture();
|
||||
}
|
||||
std::unique_ptr<Platform> instance_ap(create_callback(process, &arch));
|
||||
if (instance_ap.get())
|
||||
return instance_ap.release();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (uint32_t idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex(idx)) != NULL; ++idx)
|
||||
{
|
||||
std::unique_ptr<Platform> instance_ap(create_callback(process, nullptr));
|
||||
if (instance_ap.get())
|
||||
return instance_ap.release();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
//PlatformSP
|
||||
//Platform::FindPlugin (Process *process, const ConstString &plugin_name)
|
||||
//{
|
||||
// PlatformCreateInstance create_callback = NULL;
|
||||
// if (plugin_name)
|
||||
// {
|
||||
// create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (plugin_name);
|
||||
// if (create_callback)
|
||||
// {
|
||||
// ArchSpec arch;
|
||||
// if (process)
|
||||
// {
|
||||
// arch = process->GetTarget().GetArchitecture();
|
||||
// }
|
||||
// PlatformSP platform_sp(create_callback(process, &arch));
|
||||
// if (platform_sp)
|
||||
// return platform_sp;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// for (uint32_t idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex(idx)) != NULL; ++idx)
|
||||
// {
|
||||
// PlatformSP platform_sp(create_callback(process, nullptr));
|
||||
// if (platform_sp)
|
||||
// return platform_sp;
|
||||
// }
|
||||
// }
|
||||
// return PlatformSP();
|
||||
//}
|
||||
|
||||
Error
|
||||
Platform::GetSharedModule (const ModuleSpec &module_spec,
|
||||
@@ -153,21 +159,50 @@ Platform::GetSharedModule (const ModuleSpec &module_spec,
|
||||
}
|
||||
|
||||
PlatformSP
|
||||
Platform::Create (const char *platform_name, Error &error)
|
||||
Platform::Find (const ConstString &name)
|
||||
{
|
||||
if (name)
|
||||
{
|
||||
static ConstString g_host_platform_name ("host");
|
||||
if (name == g_host_platform_name)
|
||||
return GetHostPlatform();
|
||||
|
||||
Mutex::Locker locker(GetPlatformListMutex ());
|
||||
for (const auto &platform_sp : GetPlatformList())
|
||||
{
|
||||
if (platform_sp->GetName() == name)
|
||||
return platform_sp;
|
||||
}
|
||||
}
|
||||
return PlatformSP();
|
||||
}
|
||||
|
||||
PlatformSP
|
||||
Platform::Create (const ConstString &name, Error &error)
|
||||
{
|
||||
PlatformCreateInstance create_callback = NULL;
|
||||
lldb::PlatformSP platform_sp;
|
||||
if (platform_name && platform_name[0])
|
||||
if (name)
|
||||
{
|
||||
ConstString const_platform_name (platform_name);
|
||||
create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (const_platform_name);
|
||||
static ConstString g_host_platform_name ("host");
|
||||
if (name == g_host_platform_name)
|
||||
return GetHostPlatform();
|
||||
|
||||
create_callback = PluginManager::GetPlatformCreateCallbackForPluginName (name);
|
||||
if (create_callback)
|
||||
platform_sp.reset(create_callback(true, NULL));
|
||||
platform_sp = create_callback(true, NULL);
|
||||
else
|
||||
error.SetErrorStringWithFormat ("unable to find a plug-in for the platform named \"%s\"", platform_name);
|
||||
error.SetErrorStringWithFormat ("unable to find a plug-in for the platform named \"%s\"", name.GetCString());
|
||||
}
|
||||
else
|
||||
error.SetErrorString ("invalid platform name");
|
||||
|
||||
if (platform_sp)
|
||||
{
|
||||
Mutex::Locker locker(GetPlatformListMutex ());
|
||||
GetPlatformList().push_back(platform_sp);
|
||||
}
|
||||
|
||||
return platform_sp;
|
||||
}
|
||||
|
||||
@@ -178,28 +213,52 @@ Platform::Create (const ArchSpec &arch, ArchSpec *platform_arch_ptr, Error &erro
|
||||
lldb::PlatformSP platform_sp;
|
||||
if (arch.IsValid())
|
||||
{
|
||||
uint32_t idx;
|
||||
PlatformCreateInstance create_callback;
|
||||
// First try exact arch matches across all platform plug-ins
|
||||
bool exact = true;
|
||||
for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
|
||||
// Scope for locker
|
||||
{
|
||||
if (create_callback)
|
||||
// First try exact arch matches across all platforms already created
|
||||
Mutex::Locker locker(GetPlatformListMutex ());
|
||||
for (const auto &platform_sp : GetPlatformList())
|
||||
{
|
||||
platform_sp.reset(create_callback(false, &arch));
|
||||
if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, exact, platform_arch_ptr))
|
||||
if (platform_sp->IsCompatibleArchitecture(arch, true, platform_arch_ptr))
|
||||
return platform_sp;
|
||||
}
|
||||
|
||||
// Next try compatible arch matches across all platforms already created
|
||||
for (const auto &platform_sp : GetPlatformList())
|
||||
{
|
||||
if (platform_sp->IsCompatibleArchitecture(arch, false, platform_arch_ptr))
|
||||
return platform_sp;
|
||||
}
|
||||
}
|
||||
// Next try compatible arch matches across all platform plug-ins
|
||||
exact = false;
|
||||
|
||||
PlatformCreateInstance create_callback;
|
||||
// First try exact arch matches across all platform plug-ins
|
||||
uint32_t idx;
|
||||
for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
|
||||
{
|
||||
if (create_callback)
|
||||
{
|
||||
platform_sp.reset(create_callback(false, &arch));
|
||||
if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, exact, platform_arch_ptr))
|
||||
platform_sp = create_callback(false, &arch);
|
||||
if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, true, platform_arch_ptr))
|
||||
{
|
||||
Mutex::Locker locker(GetPlatformListMutex ());
|
||||
GetPlatformList().push_back(platform_sp);
|
||||
return platform_sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Next try compatible arch matches across all platform plug-ins
|
||||
for (idx = 0; (create_callback = PluginManager::GetPlatformCreateCallbackAtIndex (idx)); ++idx)
|
||||
{
|
||||
if (create_callback)
|
||||
{
|
||||
platform_sp = create_callback(false, &arch);
|
||||
if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, false, platform_arch_ptr))
|
||||
{
|
||||
Mutex::Locker locker(GetPlatformListMutex ());
|
||||
GetPlatformList().push_back(platform_sp);
|
||||
return platform_sp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -211,25 +270,6 @@ Platform::Create (const ArchSpec &arch, ArchSpec *platform_arch_ptr, Error &erro
|
||||
return platform_sp;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
Platform::GetNumConnectedRemotePlatforms ()
|
||||
{
|
||||
Mutex::Locker locker (GetConnectedPlatformListMutex ());
|
||||
return GetConnectedPlatformList().size();
|
||||
}
|
||||
|
||||
PlatformSP
|
||||
Platform::GetConnectedRemotePlatformAtIndex (uint32_t idx)
|
||||
{
|
||||
PlatformSP platform_sp;
|
||||
{
|
||||
Mutex::Locker locker (GetConnectedPlatformListMutex ());
|
||||
if (idx < GetConnectedPlatformList().size())
|
||||
platform_sp = GetConnectedPlatformList ()[idx];
|
||||
}
|
||||
return platform_sp;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
/// Default Constructor
|
||||
//------------------------------------------------------------------
|
||||
|
||||
@@ -170,7 +170,7 @@ TargetList::CreateTarget (Debugger &debugger,
|
||||
|
||||
typedef std::vector<PlatformSP> PlatformList;
|
||||
PlatformList platforms;
|
||||
PlatformSP host_platform_sp = Platform::GetDefaultPlatform();
|
||||
PlatformSP host_platform_sp = Platform::GetHostPlatform();
|
||||
for (size_t i=0; i<num_specs; ++i)
|
||||
{
|
||||
ModuleSpec module_spec;
|
||||
|
||||
@@ -36,6 +36,8 @@ class TestImageListMultiArchitecture(TestBase):
|
||||
|
||||
self.runCmd("file {}".format(file_name))
|
||||
self.match("image list -t -A", [expected_triple_and_arch_regex])
|
||||
# Revert to the host platform after all of this is done
|
||||
self.runCmd("platform select host")
|
||||
|
||||
if __name__ == '__main__':
|
||||
import atexit
|
||||
|
||||
@@ -142,12 +142,12 @@ dump_available_platforms (FILE *output_file)
|
||||
fprintf (output_file, "%s\t%s\n", plugin_name, plugin_desc);
|
||||
}
|
||||
|
||||
if ( Platform::GetDefaultPlatform () )
|
||||
if ( Platform::GetHostPlatform () )
|
||||
{
|
||||
// add this since the default platform doesn't necessarily get registered by
|
||||
// the plugin name (e.g. 'host' doesn't show up as a
|
||||
// registered platform plugin even though it's the default).
|
||||
fprintf (output_file, "%s\tDefault platform for this host.\n", Platform::GetDefaultPlatform ()->GetPluginName ().AsCString ());
|
||||
fprintf (output_file, "%s\tDefault platform for this host.\n", Platform::GetHostPlatform ()->GetPluginName ().AsCString ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ setup_platform (const std::string platform_name)
|
||||
if (platform_name.empty())
|
||||
{
|
||||
printf ("using the default platform: ");
|
||||
platform_sp = Platform::GetDefaultPlatform ();
|
||||
platform_sp = Platform::GetHostPlatform ();
|
||||
printf ("%s\n", platform_sp->GetPluginName ().AsCString ());
|
||||
return platform_sp;
|
||||
}
|
||||
@@ -186,9 +186,9 @@ setup_platform (const std::string platform_name)
|
||||
// the host platform isn't registered with that name (at
|
||||
// least, not always. Check if the given name matches
|
||||
// the default platform name. If so, use it.
|
||||
if ( Platform::GetDefaultPlatform () && ( Platform::GetDefaultPlatform ()->GetPluginName () == ConstString (platform_name.c_str()) ) )
|
||||
if ( Platform::GetHostPlatform () && ( Platform::GetHostPlatform ()->GetPluginName () == ConstString (platform_name.c_str()) ) )
|
||||
{
|
||||
platform_sp = Platform::GetDefaultPlatform ();
|
||||
platform_sp = Platform::GetHostPlatform ();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user