diff --git a/lldb/source/Host/macosx/objcxx/Host.mm b/lldb/source/Host/macosx/objcxx/Host.mm --- a/lldb/source/Host/macosx/objcxx/Host.mm +++ b/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(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; } diff --git a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py b/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py --- a/lldb/test/API/macosx/simulator/TestSimulatorPlatform.py +++ b/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