diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -71,7 +71,7 @@ class Platform : public PluginInterface { public: /// Default Constructor - Platform(bool is_host_platform); + Platform(bool is_host_platform, llvm::StringRef name); /// The destructor is virtual since this class is designed to be inherited /// from by the plug-in instance. @@ -217,7 +217,7 @@ llvm::Optional GetOSKernelDescription(); // Returns the name of the platform - ConstString GetName(); + llvm::StringRef GetName() { return m_instance_name; } virtual const char *GetHostname(); @@ -508,17 +508,17 @@ virtual uint64_t ReadFile(lldb::user_id_t fd, uint64_t offset, void *dst, uint64_t dst_len, Status &error) { - error.SetErrorStringWithFormat( - "Platform::ReadFile() is not supported in the %s platform", - GetName().GetCString()); + error.SetErrorStringWithFormatv( + "Platform::ReadFile() is not supported in the {0} platform", + GetPluginName()); return -1; } virtual uint64_t WriteFile(lldb::user_id_t fd, uint64_t offset, const void *src, uint64_t src_len, Status &error) { - error.SetErrorStringWithFormat( - "Platform::WriteFile() is not supported in the %s platform", - GetName().GetCString()); + error.SetErrorStringWithFormatv( + "Platform::WriteFile() is not supported in the {0} platform", + GetPluginName()); return -1; } @@ -886,6 +886,7 @@ // the once we call HostInfo::GetOSVersion(). bool m_os_version_set_while_connected; bool m_system_arch_set_while_connected; + const std::string m_instance_name; ConstString m_sdk_sysroot; // the root location of where the SDK files are all located ConstString m_sdk_build; diff --git a/lldb/include/lldb/lldb-private-interfaces.h b/lldb/include/lldb/lldb-private-interfaces.h --- a/lldb/include/lldb/lldb-private-interfaces.h +++ b/lldb/include/lldb/lldb-private-interfaces.h @@ -75,6 +75,7 @@ Target *target); typedef SystemRuntime *(*SystemRuntimeCreateInstance)(Process *process); typedef lldb::PlatformSP (*PlatformCreateInstance)(bool force, + llvm::StringRef name, const ArchSpec *arch); typedef lldb::ProcessSP (*ProcessCreateInstance)( lldb::TargetSP target_sp, lldb::ListenerSP listener_sp, diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -342,7 +342,7 @@ PlatformSP platform_sp(GetSP()); if (platform_sp) - return platform_sp->GetName().GetCString(); + return ConstString(platform_sp->GetName()).AsCString(); return nullptr; } diff --git a/lldb/source/Commands/CommandObjectPlatform.cpp b/lldb/source/Commands/CommandObjectPlatform.cpp --- a/lldb/source/Commands/CommandObjectPlatform.cpp +++ b/lldb/source/Commands/CommandObjectPlatform.cpp @@ -1303,16 +1303,15 @@ result.AppendErrorWithFormatv( "no processes were found that {0} \"{1}\" on the \"{2}\" " "platform\n", - match_desc, match_name, platform_sp->GetPluginName()); + match_desc, match_name, platform_sp->GetName()); else result.AppendErrorWithFormatv( "no processes were found on the \"{0}\" platform\n", - platform_sp->GetPluginName()); + platform_sp->GetName()); } else { - result.AppendMessageWithFormat( - "%u matching process%s found on \"%s\"", matches, - matches > 1 ? "es were" : " was", - platform_sp->GetName().GetCString()); + result.AppendMessageWithFormatv( + "{0} matching process{1} found on \"{2}\"", matches, + matches > 1 ? "es were" : " was", platform_sp->GetName()); if (match_desc) result.AppendMessageWithFormat(" whose name %s \"%s\"", match_desc, match_name); diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -84,8 +84,8 @@ } PlatformSP platform_sp(target->GetPlatform()); if (platform_sp) - strm.Printf("%splatform=%s", properties++ > 0 ? ", " : " ( ", - platform_sp->GetName().GetCString()); + strm.Format("{0}platform={1}", properties++ > 0 ? ", " : " ( ", + platform_sp->GetName()); ProcessSP process_sp(target->GetProcessSP()); bool show_process_status = false; diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -1609,7 +1609,7 @@ // Returns the index of the choice. int GetChoice() { return m_choice; } - void SetChoice(const std::string &choice) { + void SetChoice(llvm::StringRef choice) { for (int i = 0; i < GetNumberOfChoices(); i++) { if (choice == m_choices[i]) { m_choice = i; @@ -1634,7 +1634,7 @@ : ChoicesFieldDelegate("Platform Plugin", 3, GetPossiblePluginNames()) { PlatformSP platform_sp = debugger.GetPlatformList().GetSelectedPlatform(); if (platform_sp) - SetChoice(platform_sp->GetName().AsCString()); + SetChoice(platform_sp->GetPluginName()); } std::vector GetPossiblePluginNames() { diff --git a/lldb/source/Interpreter/OptionGroupPlatform.cpp b/lldb/source/Interpreter/OptionGroupPlatform.cpp --- a/lldb/source/Interpreter/OptionGroupPlatform.cpp +++ b/lldb/source/Interpreter/OptionGroupPlatform.cpp @@ -25,9 +25,9 @@ if (platform_sp) { if (platform_arch.IsValid() && !platform_sp->IsCompatibleArchitecture(arch, false, &platform_arch)) { - error.SetErrorStringWithFormat("platform '%s' doesn't support '%s'", - platform_sp->GetName().GetCString(), - arch.GetTriple().getTriple().c_str()); + error.SetErrorStringWithFormatv("platform '{0}' doesn't support '{1}'", + platform_sp->GetPluginName(), + arch.GetTriple().getTriple()); platform_sp.reset(); return platform_sp; } @@ -122,7 +122,7 @@ const lldb::PlatformSP &platform_sp) const { if (platform_sp) { if (!m_platform_name.empty()) { - if (platform_sp->GetName() != ConstString(m_platform_name.c_str())) + if (platform_sp->GetName() != m_platform_name) return false; } diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.h b/lldb/source/Plugins/Platform/Android/PlatformAndroid.h --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.h +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.h @@ -21,14 +21,15 @@ class PlatformAndroid : public platform_linux::PlatformLinux { public: - PlatformAndroid(bool is_host); + PlatformAndroid(bool is_host, llvm::StringRef name); static void Initialize(); static void Terminate(); // lldb_private::PluginInterface functions - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch); static llvm::StringRef GetPluginNameStatic(bool is_host) { return is_host ? Platform::GetHostPlatformName() : "remote-android"; diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp --- a/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp @@ -37,7 +37,8 @@ if (g_initialize_count++ == 0) { #if defined(__ANDROID__) - PlatformSP default_platform_sp(new PlatformAndroid(true)); + PlatformSP default_platform_sp( + new PlatformAndroid(true, Platform::GetHostPlatformName())); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform(default_platform_sp); #endif @@ -58,7 +59,8 @@ PlatformLinux::Terminate(); } -PlatformSP PlatformAndroid::CreateInstance(bool force, const ArchSpec *arch) { +PlatformSP PlatformAndroid::CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); if (log) { const char *arch_name; @@ -117,7 +119,7 @@ if (create) { LLDB_LOGF(log, "PlatformAndroid::%s() creating remote-android platform", __FUNCTION__); - return PlatformSP(new PlatformAndroid(false)); + return PlatformSP(new PlatformAndroid(false, name)); } LLDB_LOGF( @@ -127,8 +129,8 @@ return PlatformSP(); } -PlatformAndroid::PlatformAndroid(bool is_host) - : PlatformLinux(is_host), m_sdk_version(0) {} +PlatformAndroid::PlatformAndroid(bool is_host, llvm::StringRef name) + : PlatformLinux(is_host, name), m_sdk_version(0) {} llvm::StringRef PlatformAndroid::GetPluginDescriptionStatic(bool is_host) { if (is_host) @@ -143,7 +145,8 @@ return Status("can't connect to the host platform, always connected"); if (!m_remote_platform_sp) - m_remote_platform_sp = PlatformSP(new PlatformAndroidRemoteGDBServer()); + m_remote_platform_sp = + PlatformSP(new PlatformAndroidRemoteGDBServer(GetName())); const char *url = args.GetArgumentAtIndex(0); if (!url) diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h --- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h @@ -24,7 +24,7 @@ class PlatformAndroidRemoteGDBServer : public platform_gdb_server::PlatformRemoteGDBServer { public: - PlatformAndroidRemoteGDBServer(); + using PlatformRemoteGDBServer::PlatformRemoteGDBServer; ~PlatformAndroidRemoteGDBServer() override; diff --git a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp --- a/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp @@ -74,8 +74,6 @@ return error; } -PlatformAndroidRemoteGDBServer::PlatformAndroidRemoteGDBServer() = default; - PlatformAndroidRemoteGDBServer::~PlatformAndroidRemoteGDBServer() { for (const auto &it : m_port_forwards) DeleteForwardPortWithAdb(it.second, m_device_id); diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h @@ -17,14 +17,15 @@ class PlatformFreeBSD : public PlatformPOSIX { public: - PlatformFreeBSD(bool is_host); + PlatformFreeBSD(bool is_host, llvm::StringRef name); static void Initialize(); static void Terminate(); // lldb_private::PluginInterface functions - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch); static llvm::StringRef GetPluginNameStatic(bool is_host) { return is_host ? Platform::GetHostPlatformName() : "remote-freebsd"; diff --git a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp --- a/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ b/lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -44,8 +44,8 @@ static uint32_t g_initialize_count = 0; - -PlatformSP PlatformFreeBSD::CreateInstance(bool force, const ArchSpec *arch) { +PlatformSP PlatformFreeBSD::CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, arch ? arch->GetArchitectureName() : "", @@ -72,7 +72,7 @@ } LLDB_LOG(log, "create = {0}", create); if (create) { - return PlatformSP(new PlatformFreeBSD(false)); + return PlatformSP(new PlatformFreeBSD(false, name)); } return PlatformSP(); } @@ -88,7 +88,8 @@ if (g_initialize_count++ == 0) { #if defined(__FreeBSD__) - PlatformSP default_platform_sp(new PlatformFreeBSD(true)); + PlatformSP default_platform_sp( + new PlatformFreeBSD(true, Platform::GetHostPlatformName())); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform(default_platform_sp); #endif @@ -110,9 +111,8 @@ } /// Default Constructor -PlatformFreeBSD::PlatformFreeBSD(bool is_host) - : PlatformPOSIX(is_host) // This is the local host platform -{ +PlatformFreeBSD::PlatformFreeBSD(bool is_host, llvm::StringRef name) + : PlatformPOSIX(is_host, name) { if (is_host) { ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); m_supported_architectures.push_back(hostArch); diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h @@ -17,14 +17,15 @@ class PlatformLinux : public PlatformPOSIX { public: - PlatformLinux(bool is_host); + PlatformLinux(bool is_host, llvm::StringRef name); static void Initialize(); static void Terminate(); // lldb_private::PluginInterface functions - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch); static llvm::StringRef GetPluginNameStatic(bool is_host) { return is_host ? Platform::GetHostPlatformName() : "remote-linux"; diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -41,8 +41,8 @@ static uint32_t g_initialize_count = 0; - -PlatformSP PlatformLinux::CreateInstance(bool force, const ArchSpec *arch) { +PlatformSP PlatformLinux::CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, arch ? arch->GetArchitectureName() : "", @@ -70,7 +70,7 @@ LLDB_LOG(log, "create = {0}", create); if (create) { - return PlatformSP(new PlatformLinux(false)); + return PlatformSP(new PlatformLinux(false, name)); } return PlatformSP(); } @@ -86,7 +86,8 @@ if (g_initialize_count++ == 0) { #if defined(__linux__) && !defined(__ANDROID__) - PlatformSP default_platform_sp(new PlatformLinux(true)); + PlatformSP default_platform_sp( + new PlatformLinux(true, Platform::GetHostPlatformName())); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform(default_platform_sp); #endif @@ -108,9 +109,8 @@ } /// Default Constructor -PlatformLinux::PlatformLinux(bool is_host) - : PlatformPOSIX(is_host) // This is the local host platform -{ +PlatformLinux::PlatformLinux(bool is_host, llvm::StringRef name) + : PlatformPOSIX(is_host, name) { if (is_host) { ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); m_supported_architectures.push_back(hostArch); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -24,7 +24,7 @@ class PlatformDarwin : public PlatformPOSIX { public: - PlatformDarwin(bool is_host); + using PlatformPOSIX::PlatformPOSIX; ~PlatformDarwin() override; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -48,9 +48,6 @@ using namespace lldb; using namespace lldb_private; -/// Default Constructor -PlatformDarwin::PlatformDarwin(bool is_host) : PlatformPOSIX(is_host) {} - /// Destructor. /// /// The destructor is virtual since this class is designed to be diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp --- a/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -83,7 +83,8 @@ } /// Default Constructor -PlatformMacOSX::PlatformMacOSX() : PlatformDarwin(true) {} +PlatformMacOSX::PlatformMacOSX() + : PlatformDarwin(true, Platform::GetHostPlatformName()) {} ConstString PlatformMacOSX::GetSDKDirectory(lldb_private::Target &target) { ModuleSP exe_module_sp(target.GetExecutableModule()); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h @@ -19,10 +19,10 @@ class PlatformRemoteAppleBridge : public PlatformRemoteDarwinDevice { public: - PlatformRemoteAppleBridge(); + PlatformRemoteAppleBridge(llvm::StringRef name); // Class Functions - static lldb::PlatformSP CreateInstance(bool force, + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, const lldb_private::ArchSpec *arch); static void Initialize(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp @@ -29,8 +29,8 @@ using namespace lldb_private; /// Default Constructor -PlatformRemoteAppleBridge::PlatformRemoteAppleBridge() - : PlatformRemoteDarwinDevice () {} +PlatformRemoteAppleBridge::PlatformRemoteAppleBridge(llvm::StringRef name) + : PlatformRemoteDarwinDevice(name) {} // Static Variables static uint32_t g_initialize_count = 0; @@ -57,7 +57,8 @@ } PlatformSP PlatformRemoteAppleBridge::CreateInstance(bool force, - const ArchSpec *arch) { + llvm::StringRef name, + const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); if (log) { const char *arch_name; @@ -124,7 +125,7 @@ LLDB_LOGF(log, "PlatformRemoteAppleBridge::%s() creating platform", __FUNCTION__); - return lldb::PlatformSP(new PlatformRemoteAppleBridge()); + return lldb::PlatformSP(new PlatformRemoteAppleBridge(name)); } LLDB_LOGF(log, diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h @@ -19,10 +19,10 @@ class PlatformRemoteAppleTV : public PlatformRemoteDarwinDevice { public: - PlatformRemoteAppleTV(); + using PlatformRemoteDarwinDevice::PlatformRemoteDarwinDevice; // Class Functions - static lldb::PlatformSP CreateInstance(bool force, + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, const lldb_private::ArchSpec *arch); static void Initialize(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -29,10 +29,6 @@ using namespace lldb; using namespace lldb_private; -/// Default Constructor -PlatformRemoteAppleTV::PlatformRemoteAppleTV() - : PlatformRemoteDarwinDevice () {} - // Static Variables static uint32_t g_initialize_count = 0; @@ -58,6 +54,7 @@ } PlatformSP PlatformRemoteAppleTV::CreateInstance(bool force, + llvm::StringRef name, const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); if (log) { @@ -120,7 +117,7 @@ LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() creating platform", __FUNCTION__); - return lldb::PlatformSP(new PlatformRemoteAppleTV()); + return lldb::PlatformSP(new PlatformRemoteAppleTV(name)); } LLDB_LOGF(log, "PlatformRemoteAppleTV::%s() aborting creation of platform", diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h @@ -20,10 +20,10 @@ class PlatformRemoteAppleWatch : public PlatformRemoteDarwinDevice { public: - PlatformRemoteAppleWatch(); + using PlatformRemoteDarwinDevice::PlatformRemoteDarwinDevice; // Class Functions - static lldb::PlatformSP CreateInstance(bool force, + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, const lldb_private::ArchSpec *arch); static void Initialize(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -55,6 +55,7 @@ } PlatformSP PlatformRemoteAppleWatch::CreateInstance(bool force, + llvm::StringRef name, const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); if (log) { @@ -127,7 +128,7 @@ LLDB_LOGF(log, "PlatformRemoteAppleWatch::%s() creating platform", __FUNCTION__); - return lldb::PlatformSP(new PlatformRemoteAppleWatch()); + return lldb::PlatformSP(new PlatformRemoteAppleWatch(name)); } LLDB_LOGF(log, "PlatformRemoteAppleWatch::%s() aborting creation of platform", @@ -140,10 +141,6 @@ return "Remote Apple Watch platform plug-in."; } -/// Default Constructor -PlatformRemoteAppleWatch::PlatformRemoteAppleWatch() - : PlatformRemoteDarwinDevice() {} - std::vector PlatformRemoteAppleWatch::GetSupportedArchitectures() { ArchSpec system_arch(GetSystemArchitecture()); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h @@ -18,7 +18,7 @@ class PlatformRemoteDarwinDevice : public PlatformDarwin { public: - PlatformRemoteDarwinDevice(); + PlatformRemoteDarwinDevice(llvm::StringRef name); ~PlatformRemoteDarwinDevice() override; diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp @@ -37,10 +37,10 @@ } /// Default Constructor -PlatformRemoteDarwinDevice::PlatformRemoteDarwinDevice() - : PlatformDarwin(false), // This is a remote platform - m_sdk_directory_infos(), m_device_support_directory(), - m_device_support_directory_for_os_version(), m_build_update() {} +PlatformRemoteDarwinDevice::PlatformRemoteDarwinDevice(llvm::StringRef name) + : PlatformDarwin(/*is_host=*/false, name), m_sdk_directory_infos(), + m_device_support_directory(), m_device_support_directory_for_os_version(), + m_build_update() {} /// Destructor. /// diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h @@ -20,9 +20,9 @@ class PlatformRemoteMacOSX : public virtual PlatformRemoteDarwinDevice { public: - PlatformRemoteMacOSX(); + PlatformRemoteMacOSX(llvm::StringRef name); - static lldb::PlatformSP CreateInstance(bool force, + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, const lldb_private::ArchSpec *arch); static void Initialize(); diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp @@ -31,7 +31,8 @@ using namespace lldb_private; /// Default Constructor -PlatformRemoteMacOSX::PlatformRemoteMacOSX() : PlatformRemoteDarwinDevice() {} +PlatformRemoteMacOSX::PlatformRemoteMacOSX(llvm::StringRef name) + : PlatformRemoteDarwinDevice(name) {} // Static Variables static uint32_t g_initialize_count = 0; @@ -58,6 +59,7 @@ } PlatformSP PlatformRemoteMacOSX::CreateInstance(bool force, + llvm::StringRef name, const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); if (log) { @@ -116,7 +118,7 @@ if (create) { LLDB_LOGF(log, "PlatformRemoteMacOSX::%s() creating platform", __FUNCTION__); - return std::make_shared(); + return std::make_shared(name); } LLDB_LOGF(log, "PlatformRemoteMacOSX::%s() aborting creation of platform", diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h @@ -18,10 +18,10 @@ class PlatformRemoteiOS : public PlatformRemoteDarwinDevice { public: - PlatformRemoteiOS(); + using PlatformRemoteDarwinDevice::PlatformRemoteDarwinDevice; // Class Functions - static lldb::PlatformSP CreateInstance(bool force, + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, 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 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -52,7 +52,8 @@ PlatformDarwin::Terminate(); } -PlatformSP PlatformRemoteiOS::CreateInstance(bool force, const ArchSpec *arch) { +PlatformSP PlatformRemoteiOS::CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); if (log) { const char *arch_name; @@ -116,7 +117,7 @@ if (log) LLDB_LOGF(log, "PlatformRemoteiOS::%s() creating platform", __FUNCTION__); - return lldb::PlatformSP(new PlatformRemoteiOS()); + return lldb::PlatformSP(new PlatformRemoteiOS(name)); } if (log) @@ -130,10 +131,6 @@ return "Remote iOS platform plug-in."; } -/// Default Constructor -PlatformRemoteiOS::PlatformRemoteiOS() - : PlatformRemoteDarwinDevice() {} - std::vector PlatformRemoteiOS::GetSupportedArchitectures() { std::vector result; ARMGetSupportedArchitectures(result, llvm::Triple::IOS); diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h @@ -17,14 +17,15 @@ class PlatformNetBSD : public PlatformPOSIX { public: - PlatformNetBSD(bool is_host); + PlatformNetBSD(bool is_host, llvm::StringRef name); static void Initialize(); static void Terminate(); // lldb_private::PluginInterface functions - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch); static llvm::StringRef GetPluginNameStatic(bool is_host) { return is_host ? Platform::GetHostPlatformName() : "remote-netbsd"; diff --git a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp --- a/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ b/lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -39,8 +39,8 @@ static uint32_t g_initialize_count = 0; - -PlatformSP PlatformNetBSD::CreateInstance(bool force, const ArchSpec *arch) { +PlatformSP PlatformNetBSD::CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, arch ? arch->GetArchitectureName() : "", @@ -61,7 +61,7 @@ LLDB_LOG(log, "create = {0}", create); if (create) { - return PlatformSP(new PlatformNetBSD(false)); + return PlatformSP(new PlatformNetBSD(false, name)); } return PlatformSP(); } @@ -77,7 +77,8 @@ if (g_initialize_count++ == 0) { #if defined(__NetBSD__) - PlatformSP default_platform_sp(new PlatformNetBSD(true)); + PlatformSP default_platform_sp( + new PlatformNetBSD(true, Platform::GetHostPlatformName())); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform(default_platform_sp); #endif @@ -99,9 +100,8 @@ } /// Default Constructor -PlatformNetBSD::PlatformNetBSD(bool is_host) - : PlatformPOSIX(is_host) // This is the local host platform -{ +PlatformNetBSD::PlatformNetBSD(bool is_host, llvm::StringRef name) + : PlatformPOSIX(is_host, name) { if (is_host) { ArchSpec hostArch = HostInfo::GetArchitecture(HostInfo::eArchKindDefault); m_supported_architectures.push_back(hostArch); diff --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h --- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h +++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h @@ -16,14 +16,15 @@ class PlatformOpenBSD : public PlatformPOSIX { public: - PlatformOpenBSD(bool is_host); + PlatformOpenBSD(bool is_host, llvm::StringRef name); static void Initialize(); static void Terminate(); // lldb_private::PluginInterface functions - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch); static llvm::StringRef GetPluginNameStatic(bool is_host) { return is_host ? Platform::GetHostPlatformName() : "remote-openbsd"; diff --git a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp --- a/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp +++ b/lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp @@ -39,8 +39,8 @@ static uint32_t g_initialize_count = 0; - -PlatformSP PlatformOpenBSD::CreateInstance(bool force, const ArchSpec *arch) { +PlatformSP PlatformOpenBSD::CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch) { Log *log = GetLog(LLDBLog::Platform); LLDB_LOG(log, "force = {0}, arch=({1}, {2})", force, arch ? arch->GetArchitectureName() : "", @@ -67,7 +67,7 @@ } LLDB_LOG(log, "create = {0}", create); if (create) { - return PlatformSP(new PlatformOpenBSD(false)); + return PlatformSP(new PlatformOpenBSD(false, name)); } return PlatformSP(); } @@ -83,7 +83,8 @@ if (g_initialize_count++ == 0) { #if defined(__OpenBSD__) - PlatformSP default_platform_sp(new PlatformOpenBSD(true)); + PlatformSP default_platform_sp( + new PlatformOpenBSD(true, Platform::GetHostPlatformName())); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform(default_platform_sp); #endif @@ -105,9 +106,8 @@ } /// Default Constructor -PlatformOpenBSD::PlatformOpenBSD(bool is_host) - : PlatformPOSIX(is_host) // This is the local host platform -{ +PlatformOpenBSD::PlatformOpenBSD(bool is_host, llvm::StringRef name) + : PlatformPOSIX(is_host, name) { if (is_host) { m_supported_architectures.push_back(HostInfo::GetArchitecture()); } else { diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h @@ -17,7 +17,7 @@ class PlatformPOSIX : public lldb_private::RemoteAwarePlatform { public: - PlatformPOSIX(bool is_host); + PlatformPOSIX(bool is_host, llvm::StringRef name); ~PlatformPOSIX() override; diff --git a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp --- a/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ b/lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -37,8 +37,8 @@ using namespace lldb_private; /// Default Constructor -PlatformPOSIX::PlatformPOSIX(bool is_host) - : RemoteAwarePlatform(is_host), // This is the local host platform +PlatformPOSIX::PlatformPOSIX(bool is_host, llvm::StringRef name) + : RemoteAwarePlatform(is_host, name), m_option_group_platform_rsync(new OptionGroupPlatformRSync()), m_option_group_platform_ssh(new OptionGroupPlatformSSH()), m_option_group_platform_caching(new OptionGroupPlatformCaching()) {} diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h @@ -56,10 +56,11 @@ } private: - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch); static void DebuggerInitialize(Debugger &debugger); - PlatformQemuUser() : Platform(/*is_host=*/false) {} + PlatformQemuUser(llvm::StringRef name) : Platform(/*is_host=*/false, name) {} }; } // namespace lldb_private diff --git a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp --- a/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp +++ b/lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp @@ -100,9 +100,10 @@ } } -PlatformSP PlatformQemuUser::CreateInstance(bool force, const ArchSpec *arch) { +PlatformSP PlatformQemuUser::CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch) { if (force) - return PlatformSP(new PlatformQemuUser()); + return PlatformSP(new PlatformQemuUser(name)); return nullptr; } diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.h +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.h @@ -15,14 +15,14 @@ class PlatformWindows : public RemoteAwarePlatform { public: - PlatformWindows(bool is_host); + PlatformWindows(bool is_host, llvm::StringRef name); static void Initialize(); static void Terminate(); // lldb_private::PluginInterface functions - static lldb::PlatformSP CreateInstance(bool force, + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, const lldb_private::ArchSpec *arch); static llvm::StringRef GetPluginNameStatic(bool is_host) { diff --git a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp --- a/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp +++ b/lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp @@ -40,7 +40,7 @@ static uint32_t g_initialize_count = 0; -PlatformSP PlatformWindows::CreateInstance(bool force, +PlatformSP PlatformWindows::CreateInstance(bool force, llvm::StringRef name, const lldb_private::ArchSpec *arch) { // The only time we create an instance is when we are creating a remote // windows platform @@ -78,7 +78,7 @@ } } if (create) - return PlatformSP(new PlatformWindows(is_host)); + return PlatformSP(new PlatformWindows(is_host, name)); return PlatformSP(); } @@ -93,7 +93,8 @@ if (g_initialize_count++ == 0) { #if defined(_WIN32) // Force a host flag to true for the default platform object. - PlatformSP default_platform_sp(new PlatformWindows(true)); + PlatformSP default_platform_sp( + new PlatformWindows(true, Platform::GetHostPlatformName())); default_platform_sp->SetSystemArchitecture(HostInfo::GetArchitecture()); Platform::SetHostPlatform(default_platform_sp); #endif @@ -115,7 +116,8 @@ } /// Default Constructor -PlatformWindows::PlatformWindows(bool is_host) : RemoteAwarePlatform(is_host) { +PlatformWindows::PlatformWindows(bool is_host, llvm::StringRef name) + : RemoteAwarePlatform(is_host, name) { const auto &AddArch = [&](const ArchSpec &spec) { if (llvm::any_of(m_supported_architectures, [spec](const ArchSpec &rhs) { return spec.IsExactMatch(rhs); diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h @@ -25,13 +25,14 @@ static void Terminate(); - static lldb::PlatformSP CreateInstance(bool force, const ArchSpec *arch); + static lldb::PlatformSP CreateInstance(bool force, llvm::StringRef name, + const ArchSpec *arch); static llvm::StringRef GetPluginNameStatic() { return "remote-gdb-server"; } static llvm::StringRef GetDescriptionStatic(); - PlatformRemoteGDBServer(); + PlatformRemoteGDBServer(llvm::StringRef name); ~PlatformRemoteGDBServer() override; diff --git a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp --- a/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ b/lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -63,13 +63,14 @@ } PlatformSP PlatformRemoteGDBServer::CreateInstance(bool force, + llvm::StringRef name, const ArchSpec *arch) { bool create = force; if (!create) { create = !arch->TripleVendorWasSpecified() && !arch->TripleOSWasSpecified(); } if (create) - return PlatformSP(new PlatformRemoteGDBServer()); + return PlatformSP(new PlatformRemoteGDBServer(name)); return PlatformSP(); } @@ -127,9 +128,8 @@ return Status(); } -/// Default Constructor -PlatformRemoteGDBServer::PlatformRemoteGDBServer() - : Platform(/*is_host=*/false) {} +PlatformRemoteGDBServer::PlatformRemoteGDBServer(llvm::StringRef name) + : Platform(/*is_host=*/false, name) {} /// Destructor. /// diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -2404,9 +2404,8 @@ m_public_state.GetValue() != eStateRunning) { PlatformSP platform_sp = GetTarget().GetPlatform(); - if (platform_sp && platform_sp->GetName() && - platform_sp->GetName().GetStringRef() == - PlatformRemoteiOS::GetPluginNameStatic()) { + if (platform_sp && platform_sp->GetPluginName() == + PlatformRemoteiOS::GetPluginNameStatic()) { if (m_destroy_tried_resuming) { if (log) log->PutCString("ProcessGDBRemote::DoDestroy() - Tried resuming to " diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp --- a/lldb/source/Target/Platform.cpp +++ b/lldb/source/Target/Platform.cpp @@ -280,7 +280,7 @@ std::lock_guard guard(GetPlatformListMutex()); for (const auto &platform_sp : GetPlatformList()) { - if (platform_sp->GetName() == name) + if (platform_sp->GetName() == name.GetStringRef()) return platform_sp; } } @@ -298,7 +298,7 @@ create_callback = PluginManager::GetPlatformCreateCallbackForPluginName( name.GetStringRef()); if (create_callback) - platform_sp = create_callback(true, nullptr); + platform_sp = create_callback(true, name.GetStringRef(), nullptr); else error.SetErrorStringWithFormat( "unable to find a plug-in for the platform named \"%s\"", @@ -343,7 +343,8 @@ PluginManager::GetPlatformCreateCallbackAtIndex(idx)); ++idx) { if (create_callback) { - platform_sp = create_callback(false, &arch); + platform_sp = create_callback( + false, PluginManager::GetPlatformPluginNameAtIndex(idx), &arch); if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, true, platform_arch_ptr)) { @@ -358,7 +359,8 @@ PluginManager::GetPlatformCreateCallbackAtIndex(idx)); ++idx) { if (create_callback) { - platform_sp = create_callback(false, &arch); + platform_sp = create_callback( + false, PluginManager::GetPlatformPluginNameAtIndex(idx), &arch); if (platform_sp && platform_sp->IsCompatibleArchitecture(arch, false, platform_arch_ptr)) { @@ -383,11 +385,11 @@ } /// Default Constructor -Platform::Platform(bool is_host) +Platform::Platform(bool is_host, llvm::StringRef name) : m_is_host(is_host), m_os_version_set_while_connected(false), - m_system_arch_set_while_connected(false), m_max_uid_name_len(0), - m_max_gid_name_len(0), m_supports_rsync(false), m_rsync_opts(), - m_rsync_prefix(), m_supports_ssh(false), m_ssh_opts(), + m_system_arch_set_while_connected(false), m_instance_name(name), + m_max_uid_name_len(0), m_max_gid_name_len(0), m_supports_rsync(false), + m_rsync_opts(), m_rsync_prefix(), m_supports_ssh(false), m_ssh_opts(), m_ignores_remote_hostname(false), m_trap_handlers(), m_calculated_trap_handlers(false), m_module_cache(std::make_unique()) { @@ -786,8 +788,6 @@ } } -ConstString Platform::GetName() { return ConstString(GetPluginName()); } - const char *Platform::GetHostname() { if (IsHost()) return "127.0.0.1"; @@ -1728,7 +1728,7 @@ FileSpec Platform::GetModuleCacheRoot() { auto dir_spec = GetGlobalPlatformProperties().GetModuleCacheDirectory(); - dir_spec.AppendPathComponent(GetName().AsCString()); + dir_spec.AppendPathComponent(GetPluginName()); return dir_spec; } diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -2873,11 +2873,10 @@ if (platform_sp) { GetTarget().SetPlatform(platform_sp); GetTarget().SetArchitecture(platform_arch); - LLDB_LOGF(log, - "Process::%s switching platform to %s and architecture " - "to %s based on info from attach", - __FUNCTION__, platform_sp->GetName().AsCString(""), - platform_arch.GetTriple().getTriple().c_str()); + LLDB_LOG(log, + "switching platform to {0} and architecture to {1} based on " + "info from attach", + platform_sp->GetName(), platform_arch.GetTriple().getTriple()); } } else if (!process_arch.IsValid()) { ProcessInstanceInfo process_info; diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -242,7 +242,7 @@ platform_set.end()) { if (!platform_set.empty()) error_strm.PutCString(", "); - error_strm.PutCString(the_platform_sp->GetName().GetCString()); + error_strm.PutCString(the_platform_sp->GetName()); platform_set.insert(the_platform_sp.get()); } } diff --git a/lldb/unittests/Expression/DWARFExpressionTest.cpp b/lldb/unittests/Expression/DWARFExpressionTest.cpp --- a/lldb/unittests/Expression/DWARFExpressionTest.cpp +++ b/lldb/unittests/Expression/DWARFExpressionTest.cpp @@ -331,8 +331,8 @@ // Set up a mock process. ArchSpec arch("i386-pc-linux"); - Platform::SetHostPlatform( - platform_linux::PlatformLinux::CreateInstance(true, &arch)); + Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); lldb::DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp); lldb::TargetSP target_sp; diff --git a/lldb/unittests/Interpreter/TestCommandPaths.cpp b/lldb/unittests/Interpreter/TestCommandPaths.cpp --- a/lldb/unittests/Interpreter/TestCommandPaths.cpp +++ b/lldb/unittests/Interpreter/TestCommandPaths.cpp @@ -107,8 +107,9 @@ TEST_F(VerifyUserMultiwordCmdPathTest, TestErrors) { ArchSpec arch("x86_64-apple-macosx-"); - Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch)); - + Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); + DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp); diff --git a/lldb/unittests/Platform/PlatformSiginfoTest.cpp b/lldb/unittests/Platform/PlatformSiginfoTest.cpp --- a/lldb/unittests/Platform/PlatformSiginfoTest.cpp +++ b/lldb/unittests/Platform/PlatformSiginfoTest.cpp @@ -82,21 +82,21 @@ void InitializeSiginfo(const std::string &triple) { ArchSpec arch(triple); + PlatformCreateInstance factory = nullptr; switch (arch.GetTriple().getOS()) { case llvm::Triple::FreeBSD: - platform_sp = - platform_freebsd::PlatformFreeBSD::CreateInstance(true, &arch); + factory = platform_freebsd::PlatformFreeBSD::CreateInstance; break; case llvm::Triple::Linux: - platform_sp = platform_linux::PlatformLinux::CreateInstance(true, &arch); + factory = platform_linux::PlatformLinux::CreateInstance; break; case llvm::Triple::NetBSD: - platform_sp = - platform_netbsd::PlatformNetBSD::CreateInstance(true, &arch); + factory = platform_netbsd::PlatformNetBSD::CreateInstance; break; default: llvm_unreachable("unknown ostype in triple"); } + platform_sp = factory(true, Platform::GetHostPlatformName(), &arch); Platform::SetHostPlatform(platform_sp); debugger_sp = Debugger::CreateInstance(); diff --git a/lldb/unittests/Process/ProcessEventDataTest.cpp b/lldb/unittests/Process/ProcessEventDataTest.cpp --- a/lldb/unittests/Process/ProcessEventDataTest.cpp +++ b/lldb/unittests/Process/ProcessEventDataTest.cpp @@ -146,7 +146,8 @@ TEST_F(ProcessEventDataTest, DoOnRemoval) { ArchSpec arch("x86_64-apple-macosx-"); - Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch)); + Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp); @@ -186,7 +187,8 @@ TEST_F(ProcessEventDataTest, ShouldStop) { ArchSpec arch("x86_64-apple-macosx-"); - Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance(true, &arch)); + Platform::SetHostPlatform(PlatformRemoteMacOSX::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp); diff --git a/lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp b/lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp --- a/lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp +++ b/lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp @@ -31,8 +31,8 @@ // Pretend Linux is the host platform. platform_linux::PlatformLinux::Initialize(); ArchSpec arch("powerpc64-pc-linux"); - Platform::SetHostPlatform( - platform_linux::PlatformLinux::CreateInstance(true, &arch)); + Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); } void TearDown() override { platform_linux::PlatformLinux::Terminate(); diff --git a/lldb/unittests/Target/ExecutionContextTest.cpp b/lldb/unittests/Target/ExecutionContextTest.cpp --- a/lldb/unittests/Target/ExecutionContextTest.cpp +++ b/lldb/unittests/Target/ExecutionContextTest.cpp @@ -74,8 +74,8 @@ TEST_F(ExecutionContextTest, GetByteOrderTarget) { ArchSpec arch("powerpc64-pc-linux"); - Platform::SetHostPlatform( - platform_linux::PlatformLinux::CreateInstance(true, &arch)); + Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp); @@ -96,8 +96,8 @@ TEST_F(ExecutionContextTest, GetByteOrderProcess) { ArchSpec arch("powerpc64-pc-linux"); - Platform::SetHostPlatform( - platform_linux::PlatformLinux::CreateInstance(true, &arch)); + Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp); diff --git a/lldb/unittests/Target/RemoteAwarePlatformTest.cpp b/lldb/unittests/Target/RemoteAwarePlatformTest.cpp --- a/lldb/unittests/Target/RemoteAwarePlatformTest.cpp +++ b/lldb/unittests/Target/RemoteAwarePlatformTest.cpp @@ -72,13 +72,14 @@ ModuleSpec executable_spec; ModuleSP expected_executable(new Module(executable_spec)); - RemoteAwarePlatformTester platform(false); + RemoteAwarePlatformTester platform(false, "test remote platform"); EXPECT_CALL(platform, GetSupportedArchitectures()) .WillRepeatedly(Return(std::vector())); EXPECT_CALL(platform, ResolveRemoteExecutable(_, _)) .WillRepeatedly(Return(std::make_pair(Status(), expected_executable))); - platform.SetRemotePlatform(std::make_shared(false)); + platform.SetRemotePlatform( + std::make_shared(false, "test target platform")); ModuleSP resolved_sp; lldb_private::Status status = diff --git a/lldb/unittests/Target/StackFrameRecognizerTest.cpp b/lldb/unittests/Target/StackFrameRecognizerTest.cpp --- a/lldb/unittests/Target/StackFrameRecognizerTest.cpp +++ b/lldb/unittests/Target/StackFrameRecognizerTest.cpp @@ -34,8 +34,8 @@ // Pretend Linux is the host platform. platform_linux::PlatformLinux::Initialize(); ArchSpec arch("powerpc64-pc-linux"); - Platform::SetHostPlatform( - platform_linux::PlatformLinux::CreateInstance(true, &arch)); + Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); } void TearDown() override { diff --git a/lldb/unittests/Thread/ThreadTest.cpp b/lldb/unittests/Thread/ThreadTest.cpp --- a/lldb/unittests/Thread/ThreadTest.cpp +++ b/lldb/unittests/Thread/ThreadTest.cpp @@ -93,8 +93,8 @@ TEST_F(ThreadTest, SetStopInfo) { ArchSpec arch("powerpc64-pc-linux"); - Platform::SetHostPlatform( - platform_linux::PlatformLinux::CreateInstance(true, &arch)); + Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp); @@ -128,8 +128,8 @@ TEST_F(ThreadTest, GetPrivateStopInfo) { ArchSpec arch("powerpc64-pc-linux"); - Platform::SetHostPlatform( - platform_linux::PlatformLinux::CreateInstance(true, &arch)); + Platform::SetHostPlatform(platform_linux::PlatformLinux::CreateInstance( + true, Platform::GetHostPlatformName(), &arch)); DebuggerSP debugger_sp = Debugger::CreateInstance(); ASSERT_TRUE(debugger_sp);