vsk updated this revision to Diff 329733.
vsk added a comment.

Use a helper function, respect the force argument.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98272/new/

https://reviews.llvm.org/D98272

Files:
  lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp


Index: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -505,6 +505,15 @@
   return process_infos.size();
 }
 
+/// Whether to skip creating a simulator platform.
+static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch) {
+  // If the arch is known not to specify a simulator environment, skip creating
+  // the simulator platform (we can create it later if there's a matching 
arch).
+  // This avoid very slow xcrun queries for non-simulator archs.
+  return !force && arch && arch->IsValid() &&
+         !arch->TripleEnvironmentWasSpecified();
+}
+
 static llvm::StringRef GetXcodeSDKDir(std::string preferred,
                                       std::string secondary) {
   llvm::StringRef sdk;
@@ -530,6 +539,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (shouldSkipSimulatorPlatform(force, arch))
+      return nullptr;
     llvm::StringRef sdk;
     sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("iPhoneSimulator.Internal.sdk"));
     if (sdk.empty())
@@ -578,6 +589,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (shouldSkipSimulatorPlatform(force, arch))
+      return nullptr;
     return PlatformAppleSimulator::CreateInstance(
         "PlatformAppleTVSimulator", g_tvos_description,
         ConstString(g_tvos_plugin_name),
@@ -619,6 +632,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (shouldSkipSimulatorPlatform(force, arch))
+      return nullptr;
     return PlatformAppleSimulator::CreateInstance(
         "PlatformAppleWatchSimulator", g_watchos_description,
         ConstString(g_watchos_plugin_name),


Index: lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
@@ -505,6 +505,15 @@
   return process_infos.size();
 }
 
+/// Whether to skip creating a simulator platform.
+static bool shouldSkipSimulatorPlatform(bool force, const ArchSpec *arch) {
+  // If the arch is known not to specify a simulator environment, skip creating
+  // the simulator platform (we can create it later if there's a matching arch).
+  // This avoid very slow xcrun queries for non-simulator archs.
+  return !force && arch && arch->IsValid() &&
+         !arch->TripleEnvironmentWasSpecified();
+}
+
 static llvm::StringRef GetXcodeSDKDir(std::string preferred,
                                       std::string secondary) {
   llvm::StringRef sdk;
@@ -530,6 +539,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (shouldSkipSimulatorPlatform(force, arch))
+      return nullptr;
     llvm::StringRef sdk;
     sdk = HostInfo::GetXcodeSDKPath(XcodeSDK("iPhoneSimulator.Internal.sdk"));
     if (sdk.empty())
@@ -578,6 +589,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (shouldSkipSimulatorPlatform(force, arch))
+      return nullptr;
     return PlatformAppleSimulator::CreateInstance(
         "PlatformAppleTVSimulator", g_tvos_description,
         ConstString(g_tvos_plugin_name),
@@ -619,6 +632,8 @@
   }
 
   static PlatformSP CreateInstance(bool force, const ArchSpec *arch) {
+    if (shouldSkipSimulatorPlatform(force, arch))
+      return nullptr;
     return PlatformAppleSimulator::CreateInstance(
         "PlatformAppleWatchSimulator", g_watchos_description,
         ConstString(g_watchos_plugin_name),
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to