[Lldb-commits] [PATCH] D85988: Fix the ability to list iOS simulator processes.

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Aug 17 14:36:50 PDT 2020


clayborg updated this revision to Diff 286151.
clayborg added a comment.

Added a "platform process list" test to each simulator test to test this functionality.

The tests all launch processes and the process should be stopped at a breakpoint, so listing the processes for "ios-simulator" is a great way to test this on all simulators.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85988

Files:
  lldb/source/Host/macosx/objcxx/Host.mm
  lldb/test/API/macosx/simulator/TestSimulatorPlatform.py


Index: lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
===================================================================
--- lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
+++ lldb/test/API/macosx/simulator/TestSimulatorPlatform.py
@@ -50,6 +50,14 @@
                                           lldb.SBFileSpec("hello.c"))
         triple_re = '-'.join([arch, 'apple', os + vers+'.*'] + env_list)
         self.expect('image list -b -t', patterns=['a\.out '+triple_re])
+        # Make sure that platform process list works to list simulator
+        # processes for all ios-simulator variants. If there are no processes
+        # then an error message will be output like:
+        # error: no processes were found on the "ios-simulator" platform
+        # Below we check that some processes were found to ensure this
+        # functionality works.
+        self.expect('platform process list',
+                    patterns=['[0-9]+ matching processes were found on'])
         self.check_debugserver(log, os+env, vers)
 
     @skipUnlessDarwin
Index: lldb/source/Host/macosx/objcxx/Host.mm
===================================================================
--- lldb/source/Host/macosx/objcxx/Host.mm
+++ lldb/source/Host/macosx/objcxx/Host.mm
@@ -503,12 +503,12 @@
       uint32_t argc = data.GetU32(&offset);
       llvm::Triple &triple = process_info.GetArchitecture().GetTriple();
       const llvm::Triple::ArchType triple_arch = triple.getArch();
-      const bool check_for_ios_simulator =
+      bool check_for_ios_simulator =
           (triple_arch == llvm::Triple::x86 ||
            triple_arch == llvm::Triple::x86_64);
-      const char *cstr = data.GetCStr(&offset);
-      if (cstr) {
-        process_info.GetExecutableFile().SetFile(cstr, FileSpec::Style::native);
+      llvm::StringRef str(data.GetCStr(&offset));
+      if (!str.empty()) {
+        process_info.GetExecutableFile().SetFile(str, FileSpec::Style::native);
 
         if (match_info_ptr == NULL ||
             NameMatches(
@@ -525,27 +525,29 @@
           // Now extract all arguments
           Args &proc_args = process_info.GetArguments();
           for (int i = 0; i < static_cast<int>(argc); ++i) {
-            cstr = data.GetCStr(&offset);
-            if (cstr)
-              proc_args.AppendArgument(llvm::StringRef(cstr));
+            str = data.GetCStr(&offset);
+            if (!str.empty())
+              proc_args.AppendArgument(str);
           }
 
           Environment &proc_env = process_info.GetEnvironment();
-          while ((cstr = data.GetCStr(&offset))) {
-            if (cstr[0] == '\0')
+          process_info.GetArchitecture().GetTriple().setOS(
+              llvm::Triple::MacOSX);
+          while (true) {
+            str = data.GetCStr(&offset);
+            if (str.empty())
               break;
 
             if (check_for_ios_simulator) {
-              if (strncmp(cstr, "SIMULATOR_UDID=", strlen("SIMULATOR_UDID=")) ==
-                  0)
+              if (str.startswith("SIMULATOR_UDID=")) {
                 process_info.GetArchitecture().GetTriple().setOS(
                     llvm::Triple::IOS);
-              else
-                process_info.GetArchitecture().GetTriple().setOS(
-                    llvm::Triple::MacOSX);
+                process_info.GetArchitecture().GetTriple().setEnvironment(
+                    llvm::Triple::Simulator);
+                check_for_ios_simulator = false;
+              }
             }
-
-            proc_env.insert(cstr);
+            proc_env.insert(str);
           }
           return true;
         }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85988.286151.patch
Type: text/x-patch
Size: 3621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200817/cefd1581/attachment-0001.bin>


More information about the lldb-commits mailing list