labath created this revision.
labath added reviewers: clayborg, jingham, JDevlieghere.
Herald added a subscriber: emaste.
labath requested review of this revision.
Herald added a project: LLDB.

Platform class has two methods (GetName, GetPluginName) which were
hardwired to return the same thing. This patch removes the hardwiring by
adding a m_instance_name field to the class, and plumbing it through all
the constructors. The idea is that GetPluginName should return the name
of the platform plugin (class), like it does now. OTOH, GetName() would
return a new identifier unique to a particular instance.

Since this touches a fairly large number of files, I've made the patch
NFC(ish) by ensuring that the instance name is always initialized to the
name of the plugin class.

I've also changed the GetName method to return a StringRef, and updated
all the call sites. For those cases, where calling GetName was obivously
wrong in the new world order, I've changed the call to GetPluginName
instead. However, it's certain that a lot of these call sites will need
to be updated again anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119146

Files:
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/lldb-private-interfaces.h
  lldb/source/API/SBPlatform.cpp
  lldb/source/Commands/CommandObjectPlatform.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Interpreter/OptionGroupPlatform.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroid.h
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
  lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
  lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
  lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
  lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
  lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
  lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
  lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
  lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
  lldb/source/Plugins/Platform/Windows/PlatformWindows.h
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
  lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
  lldb/source/Target/Platform.cpp
  lldb/source/Target/Process.cpp
  lldb/source/Target/TargetList.cpp
  lldb/unittests/Expression/DWARFExpressionTest.cpp
  lldb/unittests/Interpreter/TestCommandPaths.cpp
  lldb/unittests/Platform/PlatformSiginfoTest.cpp
  lldb/unittests/Process/ProcessEventDataTest.cpp
  lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp
  lldb/unittests/Target/ExecutionContextTest.cpp
  lldb/unittests/Target/RemoteAwarePlatformTest.cpp
  lldb/unittests/Target/StackFrameRecognizerTest.cpp
  lldb/unittests/Thread/ThreadTest.cpp

Index: lldb/unittests/Thread/ThreadTest.cpp
===================================================================
--- lldb/unittests/Thread/ThreadTest.cpp
+++ 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);
Index: lldb/unittests/Target/StackFrameRecognizerTest.cpp
===================================================================
--- lldb/unittests/Target/StackFrameRecognizerTest.cpp
+++ 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 {
Index: lldb/unittests/Target/RemoteAwarePlatformTest.cpp
===================================================================
--- lldb/unittests/Target/RemoteAwarePlatformTest.cpp
+++ 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<ArchSpec>()));
   EXPECT_CALL(platform, ResolveRemoteExecutable(_, _))
       .WillRepeatedly(Return(std::make_pair(Status(), expected_executable)));
 
-  platform.SetRemotePlatform(std::make_shared<TargetPlatformTester>(false));
+  platform.SetRemotePlatform(
+      std::make_shared<TargetPlatformTester>(false, "test target platform"));
 
   ModuleSP resolved_sp;
   lldb_private::Status status =
Index: lldb/unittests/Target/ExecutionContextTest.cpp
===================================================================
--- lldb/unittests/Target/ExecutionContextTest.cpp
+++ 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);
Index: lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp
===================================================================
--- lldb/unittests/ScriptInterpreter/Lua/ScriptInterpreterTests.cpp
+++ 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();
Index: lldb/unittests/Process/ProcessEventDataTest.cpp
===================================================================
--- lldb/unittests/Process/ProcessEventDataTest.cpp
+++ 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);
Index: lldb/unittests/Platform/PlatformSiginfoTest.cpp
===================================================================
--- lldb/unittests/Platform/PlatformSiginfoTest.cpp
+++ 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();
Index: lldb/unittests/Interpreter/TestCommandPaths.cpp
===================================================================
--- lldb/unittests/Interpreter/TestCommandPaths.cpp
+++ 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);
 
Index: lldb/unittests/Expression/DWARFExpressionTest.cpp
===================================================================
--- lldb/unittests/Expression/DWARFExpressionTest.cpp
+++ 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;
Index: lldb/source/Target/TargetList.cpp
===================================================================
--- lldb/source/Target/TargetList.cpp
+++ 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());
             }
           }
Index: lldb/source/Target/Process.cpp
===================================================================
--- lldb/source/Target/Process.cpp
+++ 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;
Index: lldb/source/Target/Platform.cpp
===================================================================
--- lldb/source/Target/Platform.cpp
+++ lldb/source/Target/Platform.cpp
@@ -280,7 +280,7 @@
 
     std::lock_guard<std::recursive_mutex> 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<ModuleCache>()) {
@@ -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;
 }
 
Index: lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
===================================================================
--- lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ 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 "
Index: lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
===================================================================
--- lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.h
+++ 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;
 
Index: lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
===================================================================
--- lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
+++ 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.
 ///
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.h
===================================================================
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.h
+++ 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) {
Index: lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
===================================================================
--- lldb/source/Plugins/Platform/Windows/PlatformWindows.cpp
+++ 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);
Index: lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
===================================================================
--- lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.h
+++ 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
Index: lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
===================================================================
--- lldb/source/Plugins/Platform/QemuUser/PlatformQemuUser.cpp
+++ 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;
 }
 
Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
===================================================================
--- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.h
+++ 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;
 
Index: lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
===================================================================
--- lldb/source/Plugins/Platform/POSIX/PlatformPOSIX.cpp
+++ 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()) {}
Index: lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
===================================================================
--- lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.h
+++ 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";
Index: lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
===================================================================
--- lldb/source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp
+++ 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() : "<null>",
@@ -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 {
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
===================================================================
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.h
+++ 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";
Index: lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
===================================================================
--- lldb/source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp
+++ 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() : "<null>",
@@ -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);
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h
+++ 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();
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp
+++ 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<ArchSpec> PlatformRemoteiOS::GetSupportedArchitectures() {
   std::vector<ArchSpec> result;
   ARMGetSupportedArchitectures(result, llvm::Triple::IOS);
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.h
+++ 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();
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteMacOSX.cpp
+++ 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<PlatformRemoteMacOSX>();
+    return std::make_shared<PlatformRemoteMacOSX>(name);
   }
 
   LLDB_LOGF(log, "PlatformRemoteMacOSX::%s() aborting creation of platform",
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h
@@ -18,7 +18,7 @@
 
 class PlatformRemoteDarwinDevice : public PlatformDarwin {
 public:
-  PlatformRemoteDarwinDevice();
+  PlatformRemoteDarwinDevice(llvm::StringRef name);
 
   ~PlatformRemoteDarwinDevice() override;
 
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp
+++ 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.
 ///
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h
+++ 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();
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp
+++ 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<ArchSpec> PlatformRemoteAppleWatch::GetSupportedArchitectures() {
   ArchSpec system_arch(GetSystemArchitecture());
 
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h
+++ 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();
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp
+++ 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",
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h
+++ 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();
Index: lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp
+++ 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,
Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ 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());
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h
+++ 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;
 
Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ 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
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.h
===================================================================
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ 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";
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
===================================================================
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ 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() : "<null>",
@@ -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);
Index: lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
===================================================================
--- lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.h
+++ 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";
Index: lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
===================================================================
--- lldb/source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp
+++ 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() : "<null>",
@@ -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);
Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
===================================================================
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.h
+++ 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;
 
Index: lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
===================================================================
--- lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
+++ 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);
Index: lldb/source/Plugins/Platform/Android/PlatformAndroid.h
===================================================================
--- lldb/source/Plugins/Platform/Android/PlatformAndroid.h
+++ 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";
Index: lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
===================================================================
--- lldb/source/Plugins/Platform/Android/PlatformAndroid.cpp
+++ 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)
Index: lldb/source/Interpreter/OptionGroupPlatform.cpp
===================================================================
--- lldb/source/Interpreter/OptionGroupPlatform.cpp
+++ 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;
     }
 
Index: lldb/source/Core/IOHandlerCursesGUI.cpp
===================================================================
--- lldb/source/Core/IOHandlerCursesGUI.cpp
+++ 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<std::string> GetPossiblePluginNames() {
Index: lldb/source/Commands/CommandObjectTarget.cpp
===================================================================
--- lldb/source/Commands/CommandObjectTarget.cpp
+++ 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;
Index: lldb/source/Commands/CommandObjectPlatform.cpp
===================================================================
--- lldb/source/Commands/CommandObjectPlatform.cpp
+++ 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);
Index: lldb/source/API/SBPlatform.cpp
===================================================================
--- lldb/source/API/SBPlatform.cpp
+++ 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;
 }
 
Index: lldb/include/lldb/lldb-private-interfaces.h
===================================================================
--- lldb/include/lldb/lldb-private-interfaces.h
+++ 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,
Index: lldb/include/lldb/Target/Platform.h
===================================================================
--- lldb/include/lldb/Target/Platform.h
+++ 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<std::string> 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;
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to